1pub mod iface;
2pub struct NetworkClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> NetworkClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/network"),
14 }
15 }
16}
17impl<T> NetworkClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Revert network configuration changes."]
22 pub fn delete(&self) -> Result<(), T::Error> {
23 let path = self.path.to_string();
24 self.client.delete(&path, &())
25 }
26}
27impl<T> NetworkClient<T>
28where
29 T: crate::client::Client,
30{
31 #[doc = "List available networks"]
32 pub fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
33 let path = self.path.to_string();
34 self.client.get(&path, ¶ms)
35 }
36}
37impl<T> NetworkClient<T>
38where
39 T: crate::client::Client,
40{
41 #[doc = "Create network device configuration"]
42 pub fn post(&self, params: PostParams) -> Result<(), T::Error> {
43 let path = self.path.to_string();
44 self.client.post(&path, ¶ms)
45 }
46}
47impl<T> NetworkClient<T>
48where
49 T: crate::client::Client,
50{
51 #[doc = "Reload network configuration"]
52 pub fn put(&self) -> Result<String, T::Error> {
53 let path = self.path.to_string();
54 self.client.put(&path, &())
55 }
56}
57#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
58pub struct GetOutputItems {
59 #[serde(
60 flatten,
61 default,
62 skip_serializing_if = "::std::collections::HashMap::is_empty"
63 )]
64 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
65}
66#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
67pub struct GetParams {
68 #[serde(rename = "type")]
69 #[serde(skip_serializing_if = "Option::is_none", default)]
70 #[doc = "Only list specific interface types."]
71 pub ty: Option<Type>,
72 #[serde(
73 flatten,
74 default,
75 skip_serializing_if = "::std::collections::HashMap::is_empty"
76 )]
77 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
78}
79impl PostParams {
80 pub fn new(iface: String, ty: Type) -> Self {
81 Self {
82 iface,
83 ty,
84 address: Default::default(),
85 address6: Default::default(),
86 autostart: Default::default(),
87 bond_primary: Default::default(),
88 bond_mode: Default::default(),
89 bond_xmit_hash_policy: Default::default(),
90 bridge_ports: Default::default(),
91 bridge_vlan_aware: Default::default(),
92 cidr: Default::default(),
93 cidr6: Default::default(),
94 comments: Default::default(),
95 comments6: Default::default(),
96 gateway: Default::default(),
97 gateway6: Default::default(),
98 mtu: Default::default(),
99 netmask: Default::default(),
100 netmask6: Default::default(),
101 ovs_bonds: Default::default(),
102 ovs_bridge: Default::default(),
103 ovs_options: Default::default(),
104 ovs_ports: Default::default(),
105 ovs_tag: Default::default(),
106 slaves: Default::default(),
107 vlan_id: Default::default(),
108 vlan_raw_device: Default::default(),
109 additional_properties: Default::default(),
110 }
111 }
112}
113#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
114pub struct PostParams {
115 #[serde(skip_serializing_if = "Option::is_none", default)]
116 #[doc = "IP address."]
117 pub address: Option<::std::net::Ipv4Addr>,
118 #[serde(skip_serializing_if = "Option::is_none", default)]
119 #[doc = "IP address."]
120 pub address6: Option<::std::net::Ipv6Addr>,
121 #[serde(
122 serialize_with = "crate::types::serialize_bool_optional",
123 deserialize_with = "crate::types::deserialize_bool_optional"
124 )]
125 #[serde(skip_serializing_if = "Option::is_none", default)]
126 #[doc = "Automatically start interface on boot."]
127 pub autostart: Option<bool>,
128 #[serde(rename = "bond-primary")]
129 #[serde(skip_serializing_if = "Option::is_none", default)]
130 #[doc = "Specify the primary interface for active-backup bond."]
131 pub bond_primary: Option<String>,
132 #[serde(skip_serializing_if = "Option::is_none", default)]
133 #[doc = "Bonding mode."]
134 pub bond_mode: Option<BondMode>,
135 #[serde(skip_serializing_if = "Option::is_none", default)]
136 #[doc = "Selects the transmit hash policy to use for slave selection in balance-xor and 802.3ad modes."]
137 pub bond_xmit_hash_policy: Option<BondXmitHashPolicy>,
138 #[serde(skip_serializing_if = "Option::is_none", default)]
139 #[doc = "Specify the interfaces you want to add to your bridge."]
140 pub bridge_ports: Option<String>,
141 #[serde(
142 serialize_with = "crate::types::serialize_bool_optional",
143 deserialize_with = "crate::types::deserialize_bool_optional"
144 )]
145 #[serde(skip_serializing_if = "Option::is_none", default)]
146 #[doc = "Enable bridge vlan support."]
147 pub bridge_vlan_aware: Option<bool>,
148 #[serde(skip_serializing_if = "Option::is_none", default)]
149 #[doc = "IPv4 CIDR."]
150 pub cidr: Option<String>,
151 #[serde(skip_serializing_if = "Option::is_none", default)]
152 #[doc = "IPv6 CIDR."]
153 pub cidr6: Option<String>,
154 #[serde(skip_serializing_if = "Option::is_none", default)]
155 #[doc = "Comments"]
156 pub comments: Option<String>,
157 #[serde(skip_serializing_if = "Option::is_none", default)]
158 #[doc = "Comments"]
159 pub comments6: Option<String>,
160 #[serde(skip_serializing_if = "Option::is_none", default)]
161 #[doc = "Default gateway address."]
162 pub gateway: Option<::std::net::Ipv4Addr>,
163 #[serde(skip_serializing_if = "Option::is_none", default)]
164 #[doc = "Default ipv6 gateway address."]
165 pub gateway6: Option<::std::net::Ipv6Addr>,
166 #[doc = "Network interface name."]
167 pub iface: String,
168 #[serde(
169 serialize_with = "crate::types::serialize_int_optional",
170 deserialize_with = "crate::types::deserialize_int_optional"
171 )]
172 #[serde(skip_serializing_if = "Option::is_none", default)]
173 #[doc = "MTU."]
174 pub mtu: Option<u64>,
175 #[serde(skip_serializing_if = "Option::is_none", default)]
176 #[doc = "Network mask."]
177 pub netmask: Option<String>,
178 #[serde(
179 serialize_with = "crate::types::serialize_int_optional",
180 deserialize_with = "crate::types::deserialize_int_optional"
181 )]
182 #[serde(skip_serializing_if = "Option::is_none", default)]
183 #[doc = "Network mask."]
184 pub netmask6: Option<u64>,
185 #[serde(skip_serializing_if = "Option::is_none", default)]
186 #[doc = "Specify the interfaces used by the bonding device."]
187 pub ovs_bonds: Option<String>,
188 #[serde(skip_serializing_if = "Option::is_none", default)]
189 #[doc = "The OVS bridge associated with a OVS port. This is required when you create an OVS port."]
190 pub ovs_bridge: Option<String>,
191 #[serde(skip_serializing_if = "Option::is_none", default)]
192 #[doc = "OVS interface options."]
193 pub ovs_options: Option<String>,
194 #[serde(skip_serializing_if = "Option::is_none", default)]
195 #[doc = "Specify the interfaces you want to add to your bridge."]
196 pub ovs_ports: Option<String>,
197 #[serde(
198 serialize_with = "crate::types::serialize_int_optional",
199 deserialize_with = "crate::types::deserialize_int_optional"
200 )]
201 #[serde(skip_serializing_if = "Option::is_none", default)]
202 #[doc = "Specify a VLan tag (used by OVSPort, OVSIntPort, OVSBond)"]
203 pub ovs_tag: Option<u64>,
204 #[serde(skip_serializing_if = "Option::is_none", default)]
205 #[doc = "Specify the interfaces used by the bonding device."]
206 pub slaves: Option<String>,
207 #[serde(rename = "type")]
208 #[doc = "Network interface type"]
209 pub ty: Type,
210 #[serde(rename = "vlan-id")]
211 #[serde(
212 serialize_with = "crate::types::serialize_int_optional",
213 deserialize_with = "crate::types::deserialize_int_optional"
214 )]
215 #[serde(skip_serializing_if = "Option::is_none", default)]
216 #[doc = "vlan-id for a custom named vlan interface (ifupdown2 only)."]
217 pub vlan_id: Option<u64>,
218 #[serde(rename = "vlan-raw-device")]
219 #[serde(skip_serializing_if = "Option::is_none", default)]
220 #[doc = "Specify the raw interface for the vlan interface."]
221 pub vlan_raw_device: Option<String>,
222 #[serde(
223 flatten,
224 default,
225 skip_serializing_if = "::std::collections::HashMap::is_empty"
226 )]
227 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
228}
229#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
230pub enum BondMode {
231 #[serde(rename = "802.3ad")]
232 _8023ad,
233 #[serde(rename = "active-backup")]
234 ActiveBackup,
235 #[serde(rename = "balance-alb")]
236 BalanceAlb,
237 #[serde(rename = "balance-rr")]
238 BalanceRr,
239 #[serde(rename = "balance-slb")]
240 BalanceSlb,
241 #[serde(rename = "balance-tlb")]
242 BalanceTlb,
243 #[serde(rename = "balance-xor")]
244 BalanceXor,
245 #[serde(rename = "broadcast")]
246 Broadcast,
247 #[serde(rename = "lacp-balance-slb")]
248 LacpBalanceSlb,
249 #[serde(rename = "lacp-balance-tcp")]
250 LacpBalanceTcp,
251}
252#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
253pub enum BondXmitHashPolicy {
254 #[serde(rename = "layer2")]
255 Layer2,
256 #[serde(rename = "layer2+3")]
257 Layer23,
258 #[serde(rename = "layer3+4")]
259 Layer34,
260}
261#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
262pub enum Type {
263 OVSBond,
264 OVSBridge,
265 OVSIntPort,
266 OVSPort,
267 #[serde(rename = "alias")]
268 Alias,
269 #[serde(rename = "any_bridge")]
270 AnyBridge,
271 #[serde(rename = "any_local_bridge")]
272 AnyLocalBridge,
273 #[serde(rename = "bond")]
274 Bond,
275 #[serde(rename = "bridge")]
276 Bridge,
277 #[serde(rename = "eth")]
278 Eth,
279 #[serde(rename = "unknown")]
280 Unknown,
281 #[serde(rename = "vlan")]
282 Vlan,
283}
284impl<T> NetworkClient<T>
285where
286 T: crate::client::Client,
287{
288 pub fn iface(&self, iface: &str) -> iface::IfaceClient<T> {
289 iface::IfaceClient::<T>::new(self.client.clone(), &self.path, iface)
290 }
291}