|
1 | | -pub mod request { |
2 | | - use serde::Serialize; |
3 | | - |
4 | | - use crate::domain_record_changer::RecordType; |
5 | | - |
6 | | - #[derive(Serialize)] |
7 | | - pub struct CreateRecord { |
8 | | - pub name: String, |
9 | | - pub content: String, |
10 | | - #[serde(rename = "type")] |
11 | | - pub record_type: RecordType, |
12 | | - pub proxied: bool, |
13 | | - pub ttl: u32, |
14 | | - } |
15 | | - |
16 | | - #[derive(Serialize)] |
17 | | - pub struct UpdateRecord { |
18 | | - pub name: String, |
19 | | - pub content: String, |
20 | | - #[serde(rename = "type")] |
21 | | - pub record_type: RecordType, |
22 | | - pub proxied: bool, |
23 | | - pub ttl: u32, |
24 | | - } |
25 | | -} |
26 | | - |
27 | | -pub mod response { |
28 | | - use crate::domain_record_changer::RecordType; |
29 | | - use serde::Deserialize; |
30 | | - |
31 | | - #[derive(Deserialize, Debug)] |
32 | | - pub struct RecordDetail { |
33 | | - pub content: String, |
34 | | - pub name: String, |
35 | | - pub proxied: bool, |
36 | | - #[serde(rename = "type")] |
37 | | - pub record_type: RecordType, |
38 | | - pub id: String, |
39 | | - pub locked: Option<bool>, |
40 | | - pub proxiable: bool, |
41 | | - pub ttl: u32, |
42 | | - pub zone_name: String, |
43 | | - } |
44 | | - |
45 | | - #[derive(Deserialize, Debug)] |
46 | | - pub struct CodeMessagePair { |
47 | | - code: u32, |
48 | | - message: String, |
49 | | - } |
50 | | - |
51 | | - #[derive(Deserialize, Debug)] |
52 | | - pub struct ResultInfo { |
53 | | - pub count: u32, |
54 | | - pub page: u32, |
55 | | - pub per_page: u32, |
56 | | - pub total_count: u32, |
57 | | - } |
58 | | - |
59 | | - #[derive(Deserialize, Debug)] |
60 | | - pub struct DescribeRecord { |
61 | | - pub result: Vec<RecordDetail>, |
62 | | - pub errors: Vec<CodeMessagePair>, |
63 | | - pub messages: Vec<CodeMessagePair>, |
64 | | - pub success: bool, |
65 | | - pub result_info: ResultInfo, |
66 | | - } |
67 | | - |
68 | | - #[derive(Deserialize)] |
69 | | - pub struct CreateRecord { |
70 | | - pub result: RecordDetail, |
71 | | - pub errors: Vec<CodeMessagePair>, |
72 | | - pub messages: Vec<CodeMessagePair>, |
73 | | - pub success: bool, |
74 | | - } |
75 | | - |
76 | | - #[derive(Deserialize)] |
77 | | - pub struct UpdateRecord { |
78 | | - pub result: RecordDetail, |
79 | | - pub errors: Vec<CodeMessagePair>, |
80 | | - pub messages: Vec<CodeMessagePair>, |
81 | | - pub success: bool, |
82 | | - } |
83 | | - |
84 | | - impl std::fmt::Display for CodeMessagePair { |
85 | | - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
86 | | - write!(f, "Code {}: {}", self.code, self.message) |
87 | | - } |
88 | | - } |
89 | | -} |
| 1 | +pub mod request { |
| 2 | + use crate::RecordType; |
| 3 | + use serde::Serialize; |
| 4 | + |
| 5 | + #[derive(Serialize)] |
| 6 | + pub struct CreateRecord { |
| 7 | + pub name: String, |
| 8 | + pub content: String, |
| 9 | + #[serde(rename = "type")] |
| 10 | + pub record_type: RecordType, |
| 11 | + pub proxied: bool, |
| 12 | + pub ttl: u32, |
| 13 | + } |
| 14 | + |
| 15 | + #[derive(Serialize)] |
| 16 | + pub struct UpdateRecord { |
| 17 | + pub name: String, |
| 18 | + pub content: String, |
| 19 | + #[serde(rename = "type")] |
| 20 | + pub record_type: RecordType, |
| 21 | + pub proxied: bool, |
| 22 | + pub ttl: u32, |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +pub mod response { |
| 27 | + use crate::RecordType; |
| 28 | + use serde::Deserialize; |
| 29 | + |
| 30 | + #[derive(Deserialize, Debug)] |
| 31 | + pub struct CodeMessagePair { |
| 32 | + pub code: u32, |
| 33 | + pub message: String, |
| 34 | + } |
| 35 | + |
| 36 | + #[derive(Deserialize, Debug)] |
| 37 | + pub struct MetaInfo { |
| 38 | + pub auto_added: Option<bool>, |
| 39 | + pub source: Option<String>, |
| 40 | + } |
| 41 | + |
| 42 | + #[derive(Deserialize, Debug)] |
| 43 | + pub struct ResultInfo { |
| 44 | + pub count: u32, |
| 45 | + pub page: u32, |
| 46 | + pub per_page: u32, |
| 47 | + pub total_count: u32, |
| 48 | + } |
| 49 | + |
| 50 | + #[derive(Deserialize, Debug)] |
| 51 | + pub struct RecordDetail { |
| 52 | + pub content: String, |
| 53 | + pub name: String, |
| 54 | + pub proxied: Option<bool>, |
| 55 | + #[serde(rename = "type")] |
| 56 | + pub record_type: RecordType, |
| 57 | + pub comment: Option<String>, |
| 58 | + pub created_on: String, |
| 59 | + pub id: String, |
| 60 | + pub meta: Option<MetaInfo>, |
| 61 | + pub modified_on: String, |
| 62 | + pub proxiable: bool, |
| 63 | + pub tags: Vec<String>, |
| 64 | + pub ttl: u32, |
| 65 | + pub zone_name: String, |
| 66 | + } |
| 67 | + |
| 68 | + #[derive(Deserialize, Debug)] |
| 69 | + pub struct DescribeRecord { |
| 70 | + pub result: Vec<RecordDetail>, |
| 71 | + pub errors: Vec<CodeMessagePair>, |
| 72 | + pub messages: Vec<CodeMessagePair>, |
| 73 | + pub success: bool, |
| 74 | + pub result_info: ResultInfo, |
| 75 | + } |
| 76 | + |
| 77 | + #[derive(Deserialize, Debug)] |
| 78 | + pub struct CreateRecord { |
| 79 | + // if success is false, the result may be null! |
| 80 | + pub result: Option<RecordDetail>, |
| 81 | + pub errors: Vec<CodeMessagePair>, |
| 82 | + pub messages: Vec<CodeMessagePair>, |
| 83 | + pub success: bool, |
| 84 | + } |
| 85 | + |
| 86 | + #[derive(Deserialize, Debug)] |
| 87 | + pub struct UpdateRecord { |
| 88 | + // if success is false, the result may be null! |
| 89 | + pub result: Option<RecordDetail>, |
| 90 | + pub errors: Vec<CodeMessagePair>, |
| 91 | + pub messages: Vec<CodeMessagePair>, |
| 92 | + pub success: bool, |
| 93 | + } |
| 94 | + |
| 95 | + impl std::fmt::Display for CodeMessagePair { |
| 96 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 97 | + write!(f, "Code {}: {}", self.code, self.message) |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments