pub mod cidr;
pub struct NameClient<T> {
client: T,
path: String,
}
impl<T> NameClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str, name: &str) -> Self {
Self {
client,
path: format!("{}/{}", parent_path, name),
}
}
}
impl<T> NameClient<T>
where
T: crate::client::Client,
{
#[doc = "Delete IPSet"]
pub fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.delete(&path, ¶ms)
}
}
impl<T> NameClient<T>
where
T: crate::client::Client,
{
#[doc = "List IPSet content"]
pub fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
let path = self.path.to_string();
self.client.get(&path, &())
}
}
impl<T> NameClient<T>
where
T: crate::client::Client,
{
#[doc = "Add IP or Network to IPSet."]
pub fn post(&self, params: PostParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms)
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct DeleteParams {
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Delete all members of the IPSet, if there are any."]
pub force: Option<bool>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl GetOutputItems {
pub fn new(cidr: String, digest: String) -> Self {
Self {
cidr,
digest,
comment: Default::default(),
nomatch: Default::default(),
additional_properties: Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutputItems {
pub cidr: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub comment: Option<String>,
#[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
pub digest: String,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nomatch: Option<bool>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl PostParams {
pub fn new(cidr: String) -> Self {
Self {
cidr,
comment: Default::default(),
nomatch: Default::default(),
additional_properties: Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct PostParams {
#[doc = "Network/IP specification in CIDR format."]
pub cidr: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub comment: Option<String>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nomatch: Option<bool>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl<T> NameClient<T>
where
T: crate::client::Client,
{
pub fn cidr(&self, cidr: &str) -> cidr::CidrClient<T> {
cidr::CidrClient::<T>::new(self.client.clone(), &self.path, cidr)
}
}