1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use crate::endpoints::{account::Account, plan::Plan};
use crate::framework::{
endpoint::{Endpoint, Method},
response::ApiResult,
};
use crate::framework::{OrderDirection, SearchMatch};
use chrono::offset::Utc;
use chrono::DateTime;
pub struct ListZones {
pub params: ListZonesParams,
}
impl Endpoint<Vec<Zone>, ListZonesParams> for ListZones {
fn method(&self) -> Method {
Method::Get
}
fn path(&self) -> String {
"zones".to_string()
}
fn query(&self) -> Option<ListZonesParams> {
Some(self.params.clone())
}
}
pub struct ZoneDetails<'a> {
pub identifier: &'a str,
}
impl<'a> Endpoint<Zone> for ZoneDetails<'a> {
fn method(&self) -> Method {
Method::Get
}
fn path(&self) -> String {
format!("zones/{}", self.identifier)
}
}
#[derive(Serialize, Clone, Debug, Default)]
pub struct ListZonesParams {
pub name: Option<String>,
pub status: Option<Status>,
pub page: Option<u32>,
pub per_page: Option<u32>,
pub order: Option<ListZonesOrder>,
pub direction: Option<OrderDirection>,
#[serde(rename = "match")]
pub search_match: Option<SearchMatch>,
}
#[derive(Serialize, Clone, Debug)]
#[serde(rename_all = "lowercase")]
pub enum ListZonesOrder {
Name,
Status,
Email,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename = "status", rename_all = "lowercase")]
pub enum Status {
Active,
Pending,
Initializing,
Moved,
Deleted,
Deactivated,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum Owner {
User { id: String, email: String },
Organization { id: String, name: String },
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum Type {
Full,
Partial,
}
#[derive(Deserialize, Debug)]
pub struct HostingPartner {
pub name: String,
pub website: String,
}
#[derive(Deserialize, Debug)]
pub struct Meta {
pub custom_certificate_quota: u32,
pub page_rule_quota: u32,
pub wildcard_proxiable: bool,
pub phishing_detected: bool,
pub multiple_railguns_allowed: bool,
}
#[derive(Deserialize, Debug)]
pub struct Zone {
pub id: String,
pub name: String,
pub account: Account,
pub betas: Option<Vec<String>>,
pub created_on: DateTime<Utc>,
pub deactivation_reason: Option<String>,
pub development_mode: i32,
pub host: Option<HostingPartner>,
pub meta: Meta,
pub modified_on: DateTime<Utc>,
pub name_servers: Vec<String>,
pub original_dnshost: Option<String>,
pub original_name_servers: Option<Vec<String>>,
pub original_registrar: Option<String>,
pub owner: Owner,
pub paused: bool,
pub permissions: Vec<String>,
pub plan: Option<Plan>,
pub plan_pending: Option<Plan>,
pub status: Status,
#[serde(rename = "type")]
pub zone_type: Type,
}
impl ApiResult for Zone {}
impl ApiResult for Vec<Zone> {}