Skip to main content

proxmox_api/generated/access/groups/
groupid.rs

1#[derive(Debug, Clone)]
2pub struct GroupidClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> GroupidClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str, groupid: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}/{}", parent_path, groupid),
14        }
15    }
16}
17impl<T> GroupidClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Delete group."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/access/groups\", [\"Group.Allocate\"])"]
24    pub async fn delete(&self) -> Result<(), T::Error> {
25        let path = self.path.to_string();
26        self.client.delete(&path, &()).await
27    }
28}
29impl<T> GroupidClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Get group configuration."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/access/groups\", [\"Sys.Audit\", \"Group.Allocate\"], any)"]
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> GroupidClient<T>
42where
43    T: crate::client::Client,
44{
45    #[doc = "Update group data."]
46    #[doc = ""]
47    #[doc = "Permission check: perm(\"/access/groups\", [\"Group.Allocate\"])"]
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}
53impl GetOutput {
54    pub fn new(members: Vec<MembersStr>) -> Self {
55        Self {
56            members,
57            comment: ::std::default::Default::default(),
58        }
59    }
60}
61#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
62pub struct GetOutput {
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    pub comment: Option<String>,
65    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
66    pub members: Vec<MembersStr>,
67}
68#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
69pub struct PutParams {
70    #[serde(skip_serializing_if = "Option::is_none", default)]
71    pub comment: Option<String>,
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}
79#[derive(Debug, Clone, PartialEq, PartialOrd)]
80pub struct MembersStr {
81    value: String,
82}
83impl crate::types::bounded_string::BoundedString for MembersStr {
84    const MIN_LENGTH: Option<usize> = None::<usize>;
85    const MAX_LENGTH: Option<usize> = Some(64usize);
86    const DEFAULT: Option<&'static str> = None::<&'static str>;
87    const PATTERN: Option<&'static str> = None::<&'static str>;
88    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
89    fn get_value(&self) -> &str {
90        &self.value
91    }
92    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
93        Self::validate(&value)?;
94        Ok(Self { value })
95    }
96}
97impl std::convert::TryFrom<String> for MembersStr {
98    type Error = crate::types::bounded_string::BoundedStringError;
99    fn try_from(value: String) -> Result<Self, Self::Error> {
100        crate::types::bounded_string::BoundedString::new(value)
101    }
102}
103impl ::serde::Serialize for MembersStr {
104    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
105    where
106        S: ::serde::Serializer,
107    {
108        crate::types::bounded_string::serialize_bounded_string(self, serializer)
109    }
110}
111impl<'de> ::serde::Deserialize<'de> for MembersStr {
112    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
113    where
114        D: ::serde::Deserializer<'de>,
115    {
116        crate::types::bounded_string::deserialize_bounded_string(deserializer)
117    }
118}