use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::imp::serde::dz_hashmap;
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct NetworkIpam {
#[serde(rename = "Driver")]
pub driver: Option<String>,
#[serde(rename = "Config")]
pub config: Vec<NetworkIpamConfig>,
#[serde(rename = "Options", deserialize_with = "dz_hashmap")]
pub options: HashMap<String, String>
}
impl NetworkIpam {
pub fn driver<V>(mut self, v: V) -> Self
where V: Into<String>
{
self.driver = Some(v.into());
self
}
pub fn config(mut self, v: NetworkIpamConfig) -> Self {
self.config.push(v);
self
}
pub fn option<K, V>(mut self, k: K, v: V) -> Self
where
K: Into<String>,
V: Into<String>
{
self.options.insert(k.into(), v.into());
self
}
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct NetworkIpamConfig {
#[serde(rename = "Subnet", skip_serializing_if = "Option::is_none")]
pub subnet: Option<String>,
#[serde(rename = "IPRange", skip_serializing_if = "Option::is_none")]
pub ip_range: Option<String>,
#[serde(rename = "Gateway", skip_serializing_if = "Option::is_none")]
pub gateway: Option<String>,
#[serde(rename = "AuxAddress", skip_serializing_if = "Option::is_none")]
pub aux_address: Option<String>,
}
impl NetworkIpamConfig {
pub fn subnet<V>(mut self, v: V) -> Self
where V: Into<String>
{
self.subnet = Some(v.into());
self
}
pub fn ip_range<V>(mut self, v: V) -> Self
where V: Into<String>
{
self.ip_range = Some(v.into());
self
}
pub fn gateway<V>(mut self, v: V) -> Self
where V: Into<String>
{
self.gateway = Some(v.into());
self
}
pub fn aux_address<V>(mut self, v: V) -> Self
where V: Into<String>
{
self.aux_address = Some(v.into());
self
}
}