Skip to main content

proxmox_api/generated/cluster/firewall/
refs.rs

1#[derive(Debug, Clone)]
2pub struct RefsClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> RefsClient<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, "/refs"),
14        }
15    }
16}
17impl<T> RefsClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Lists possible IPSet/Alias reference which are allowed in source/dest properties."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
24    pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
25        let path = self.path.to_string();
26        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &params).await?;
27        Ok(optional_vec.unwrap_or_default())
28    }
29}
30impl GetOutputItems {
31    pub fn new(name: String, reference: String, scope: String, ty: Type) -> Self {
32        Self {
33            name,
34            reference,
35            scope,
36            ty,
37            comment: ::std::default::Default::default(),
38            additional_properties: ::std::default::Default::default(),
39        }
40    }
41}
42#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
43pub struct GetOutputItems {
44    #[serde(skip_serializing_if = "Option::is_none", default)]
45    pub comment: Option<String>,
46    pub name: String,
47    #[serde(rename = "ref")]
48    pub reference: String,
49    pub scope: String,
50    #[serde(rename = "type")]
51    pub ty: Type,
52    #[serde(
53        flatten,
54        default,
55        skip_serializing_if = "::std::collections::HashMap::is_empty"
56    )]
57    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
58}
59#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
60pub struct GetParams {
61    #[serde(rename = "type")]
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    #[doc = "Only list references of specified type."]
64    #[doc = ""]
65    pub ty: Option<Type>,
66    #[serde(
67        flatten,
68        default,
69        skip_serializing_if = "::std::collections::HashMap::is_empty"
70    )]
71    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
72}
73#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
74#[doc = "Only list references of specified type."]
75#[doc = ""]
76pub enum Type {
77    #[serde(rename = "alias")]
78    Alias,
79    #[serde(rename = "ipset")]
80    Ipset,
81}
82impl TryFrom<&str> for Type {
83    type Error = String;
84    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
85        match value {
86            "alias" => Ok(Self::Alias),
87            "ipset" => Ok(Self::Ipset),
88            v => Err(format!("Unknown variant {v}")),
89        }
90    }
91}