sacloud_rs/api/
interface.rs

1//! https://manual.sakura.ad.jp/cloud-api/1.1/interface/index.html
2//!
3//! API                                                 Parameters              Response
4//! ------------------------------------------------------------------------------------
5//! POST    /interface                                  -                       -
6//! PUT     /interface/:interfaceid/to/switch/shared    -                       -
7
8use serde::{Deserialize, Serialize};
9
10pub mod parameter {
11    use super::*;
12
13    #[derive(Serialize, Default)]
14    #[serde(rename_all = "PascalCase")]
15    struct Server {
16        #[serde(skip_serializing_if = "Option::is_none")]
17        i_d: Option<String>,
18    }
19
20    #[derive(Serialize, Default)]
21    #[serde(rename_all = "PascalCase")]
22    struct Interface {
23        #[serde(skip_serializing_if = "Option::is_none")]
24        server: Option<Server>,
25    }
26
27    #[derive(Serialize, Default)]
28    #[serde(rename_all = "PascalCase")]
29    pub struct Params {
30        #[serde(skip_serializing_if = "Option::is_none")]
31        interface: Option<Interface>,
32    }
33
34    impl Params {
35        pub fn server_id<S: ToString>(mut self, id: S) -> Self {
36            let server = Server {
37                i_d: Some(id.to_string()),
38            };
39            let interface = Interface {
40                server: Some(server),
41            };
42            self.interface.replace(interface);
43            self
44        }
45
46        // pub fn config(mut self, config: Config) -> Self {
47        //     self.config.replace(config);
48        //     self
49        // }
50    }
51}
52
53create_struct!(Interface, "PascalCase",
54    i_d: String,
55    i_p_address: Option<String>
56);
57
58create_struct!(InterfaceCreated, "PascalCase",
59    interface: Interface,
60    success: bool
61);