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