kanidm_client/
group.rs

1use crate::{ClientError, KanidmClient};
2use kanidm_proto::v1::Entry;
3
4impl KanidmClient {
5    pub async fn idm_group_search(&self, id: &str) -> Result<Vec<Entry>, ClientError> {
6        self.perform_get_request(&format!("/v1/group/_search/{id}"))
7            .await
8    }
9
10    pub async fn idm_group_purge_attr(&self, id: &str, attr: &str) -> Result<(), ClientError> {
11        self.perform_delete_request(format!("/v1/group/{id}/_attr/{attr}").as_str())
12            .await
13    }
14
15    pub async fn group_account_policy_enable(&self, id: &str) -> Result<(), ClientError> {
16        self.perform_post_request(
17            &format!("/v1/group/{id}/_attr/class"),
18            vec!["account_policy".to_string()],
19        )
20        .await
21    }
22
23    pub async fn group_rename(&self, name: &str, new_name: &str) -> Result<(), ClientError> {
24        self.perform_put_request(&format!("/v1/group/{name}/_attr/name"), vec![new_name])
25            .await
26    }
27
28    pub async fn group_account_policy_authsession_expiry_set(
29        &self,
30        id: &str,
31        expiry: u32,
32    ) -> Result<(), ClientError> {
33        self.perform_put_request(
34            &format!("/v1/group/{id}/_attr/authsession_expiry"),
35            vec![expiry.to_string()],
36        )
37        .await
38    }
39
40    pub async fn group_account_policy_authsession_expiry_reset(
41        &self,
42        id: &str,
43    ) -> Result<(), ClientError> {
44        self.perform_delete_request(&format!("/v1/group/{id}/_attr/authsession_expiry"))
45            .await
46    }
47
48    pub async fn group_account_policy_credential_type_minimum_set(
49        &self,
50        id: &str,
51        value: &str,
52    ) -> Result<(), ClientError> {
53        self.perform_put_request(
54            &format!("/v1/group/{id}/_attr/credential_type_minimum"),
55            vec![value.to_string()],
56        )
57        .await
58    }
59
60    pub async fn group_account_policy_password_minimum_length_set(
61        &self,
62        id: &str,
63        length: u32,
64    ) -> Result<(), ClientError> {
65        self.perform_put_request(
66            &format!("/v1/group/{id}/_attr/auth_password_minimum_length"),
67            vec![length.to_string()],
68        )
69        .await
70    }
71
72    pub async fn group_account_policy_password_minimum_length_reset(
73        &self,
74        id: &str,
75    ) -> Result<(), ClientError> {
76        self.perform_delete_request(&format!(
77            "/v1/group/{id}/_attr/auth_password_minimum_length"
78        ))
79        .await
80    }
81
82    pub async fn group_account_policy_privilege_expiry_set(
83        &self,
84        id: &str,
85        expiry: u32,
86    ) -> Result<(), ClientError> {
87        self.perform_put_request(
88            &format!("/v1/group/{id}/_attr/privilege_expiry"),
89            vec![expiry.to_string()],
90        )
91        .await
92    }
93
94    pub async fn group_account_policy_privilege_expiry_reset(
95        &self,
96        id: &str,
97    ) -> Result<(), ClientError> {
98        self.perform_delete_request(&format!("/v1/group/{id}/_attr/privilege_expiry"))
99            .await
100    }
101
102    pub async fn group_account_policy_webauthn_attestation_set(
103        &self,
104        id: &str,
105        att_ca_list: &str,
106    ) -> Result<(), ClientError> {
107        self.perform_put_request(
108            &format!("/v1/group/{id}/_attr/webauthn_attestation_ca_list"),
109            vec![att_ca_list.to_string()],
110        )
111        .await
112    }
113
114    pub async fn group_account_policy_webauthn_attestation_reset(
115        &self,
116        id: &str,
117    ) -> Result<(), ClientError> {
118        self.perform_delete_request(&format!(
119            "/v1/group/{id}/_attr/webauthn_attestation_ca_list"
120        ))
121        .await
122    }
123
124    pub async fn group_account_policy_limit_search_max_results(
125        &self,
126        id: &str,
127        maximum: u32,
128    ) -> Result<(), ClientError> {
129        self.perform_put_request(
130            &format!("/v1/group/{id}/_attr/limit_search_max_results"),
131            vec![maximum.to_string()],
132        )
133        .await
134    }
135
136    pub async fn group_account_policy_limit_search_max_results_reset(
137        &self,
138        id: &str,
139    ) -> Result<(), ClientError> {
140        self.perform_delete_request(&format!("/v1/group/{id}/_attr/limit_search_max_results"))
141            .await
142    }
143
144    pub async fn group_account_policy_limit_search_max_filter_test(
145        &self,
146        id: &str,
147        maximum: u32,
148    ) -> Result<(), ClientError> {
149        self.perform_put_request(
150            &format!("/v1/group/{id}/_attr/limit_search_max_filter_test"),
151            vec![maximum.to_string()],
152        )
153        .await
154    }
155
156    pub async fn group_account_policy_limit_search_max_filter_test_reset(
157        &self,
158        id: &str,
159    ) -> Result<(), ClientError> {
160        self.perform_delete_request(&format!(
161            "/v1/group/{id}/_attr/limit_search_max_filter_test"
162        ))
163        .await
164    }
165
166    pub async fn group_account_policy_allow_primary_cred_fallback(
167        &self,
168        id: &str,
169        allow: bool,
170    ) -> Result<(), ClientError> {
171        self.perform_put_request(
172            &format!("/v1/group/{id}/_attr/allow_primary_cred_fallback"),
173            vec![allow.to_string()],
174        )
175        .await
176    }
177
178    pub async fn idm_group_purge_mail(&self, id: &str) -> Result<(), ClientError> {
179        self.idm_group_purge_attr(id, "mail").await
180    }
181
182    pub async fn idm_group_set_mail<T: serde::Serialize>(
183        &self,
184        id: &str,
185        values: &[T],
186    ) -> Result<(), ClientError> {
187        self.perform_put_request(&format!("/v1/group/{id}/_attr/mail"), values)
188            .await
189    }
190
191    pub async fn idm_group_get_mail(&self, id: &str) -> Result<Option<Vec<String>>, ClientError> {
192        self.perform_get_request(&format!("/v1/group/{id}/_attr/mail"))
193            .await
194    }
195
196    pub async fn idm_group_purge_description(&self, id: &str) -> Result<(), ClientError> {
197        self.idm_group_purge_attr(id, "description").await
198    }
199
200    pub async fn idm_group_set_description(
201        &self,
202        id: &str,
203        description: &str,
204    ) -> Result<(), ClientError> {
205        self.perform_put_request(&format!("/v1/group/{id}/_attr/description"), &[description])
206            .await
207    }
208}