Skip to main content

proxmox_api/generated/nodes/node/qemu/vmid/firewall/aliases/
name.rs

1#[derive(Debug, Clone)]
2pub struct NameClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> NameClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str, name: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}/{}", parent_path, name),
14        }
15    }
16}
17impl<T> NameClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Remove IP or Network alias."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Config.Network\"])"]
24    pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
25        let path = self.path.to_string();
26        self.client.delete(&path, &params).await
27    }
28}
29impl<T> NameClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Read alias."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
36    pub async fn get(&self) -> Result<GetOutput, T::Error> {
37        let path = self.path.to_string();
38        self.client.get(&path, &()).await
39    }
40}
41impl<T> NameClient<T>
42where
43    T: crate::client::Client,
44{
45    #[doc = "Update IP or Network alias."]
46    #[doc = ""]
47    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Config.Network\"])"]
48    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49        let path = self.path.to_string();
50        self.client.put(&path, &params).await
51    }
52}
53#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
54pub struct DeleteParams {
55    #[serde(skip_serializing_if = "Option::is_none", default)]
56    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
57    #[doc = ""]
58    pub digest: Option<DigestStr>,
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 GetOutput {
68    #[serde(
69        flatten,
70        default,
71        skip_serializing_if = "::std::collections::HashMap::is_empty"
72    )]
73    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
74}
75impl PutParams {
76    pub fn new(cidr: String) -> Self {
77        Self {
78            cidr,
79            comment: ::std::default::Default::default(),
80            digest: ::std::default::Default::default(),
81            rename: ::std::default::Default::default(),
82            additional_properties: ::std::default::Default::default(),
83        }
84    }
85}
86#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
87pub struct PutParams {
88    #[doc = "Network/IP specification in CIDR format."]
89    #[doc = ""]
90    pub cidr: String,
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    pub comment: Option<String>,
93    #[serde(skip_serializing_if = "Option::is_none", default)]
94    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
95    #[doc = ""]
96    pub digest: Option<DigestStr>,
97    #[serde(skip_serializing_if = "Option::is_none", default)]
98    #[doc = "Rename an existing alias."]
99    #[doc = ""]
100    pub rename: Option<RenameStr>,
101    #[serde(
102        flatten,
103        default,
104        skip_serializing_if = "::std::collections::HashMap::is_empty"
105    )]
106    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
107}
108#[derive(Debug, Clone, PartialEq, PartialOrd)]
109pub struct DigestStr {
110    value: String,
111}
112impl crate::types::bounded_string::BoundedString for DigestStr {
113    const MIN_LENGTH: Option<usize> = None::<usize>;
114    const MAX_LENGTH: Option<usize> = Some(64usize);
115    const DEFAULT: Option<&'static str> = None::<&'static str>;
116    const PATTERN: Option<&'static str> = None::<&'static str>;
117    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
118    fn get_value(&self) -> &str {
119        &self.value
120    }
121    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
122        Self::validate(&value)?;
123        Ok(Self { value })
124    }
125}
126impl std::convert::TryFrom<String> for DigestStr {
127    type Error = crate::types::bounded_string::BoundedStringError;
128    fn try_from(value: String) -> Result<Self, Self::Error> {
129        crate::types::bounded_string::BoundedString::new(value)
130    }
131}
132impl ::serde::Serialize for DigestStr {
133    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
134    where
135        S: ::serde::Serializer,
136    {
137        crate::types::bounded_string::serialize_bounded_string(self, serializer)
138    }
139}
140impl<'de> ::serde::Deserialize<'de> for DigestStr {
141    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
142    where
143        D: ::serde::Deserializer<'de>,
144    {
145        crate::types::bounded_string::deserialize_bounded_string(deserializer)
146    }
147}
148#[derive(Debug, Clone, PartialEq, PartialOrd)]
149pub struct RenameStr {
150    value: String,
151}
152impl crate::types::bounded_string::BoundedString for RenameStr {
153    const MIN_LENGTH: Option<usize> = Some(2usize);
154    const MAX_LENGTH: Option<usize> = Some(64usize);
155    const DEFAULT: Option<&'static str> = None::<&'static str>;
156    const PATTERN: Option<&'static str> = Some("[A-Za-z][A-Za-z0-9\\-\\_]+");
157    const TYPE_DESCRIPTION: &'static str =
158        "a string with pattern r\"[A-Za-z][A-Za-z0-9\\-\\_]+\" and length between 2 and 64";
159    fn get_value(&self) -> &str {
160        &self.value
161    }
162    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
163        Self::validate(&value)?;
164        Ok(Self { value })
165    }
166}
167impl std::convert::TryFrom<String> for RenameStr {
168    type Error = crate::types::bounded_string::BoundedStringError;
169    fn try_from(value: String) -> Result<Self, Self::Error> {
170        crate::types::bounded_string::BoundedString::new(value)
171    }
172}
173impl ::serde::Serialize for RenameStr {
174    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
175    where
176        S: ::serde::Serializer,
177    {
178        crate::types::bounded_string::serialize_bounded_string(self, serializer)
179    }
180}
181impl<'de> ::serde::Deserialize<'de> for RenameStr {
182    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
183    where
184        D: ::serde::Deserializer<'de>,
185    {
186        crate::types::bounded_string::deserialize_bounded_string(deserializer)
187    }
188}