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/{}/_attr/{}", id, 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/{}/_attr/class", id),
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/{}/_attr/name", 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/{}/_attr/authsession_expiry", id),
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/{}/_attr/authsession_expiry", id))
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/{}/_attr/credential_type_minimum", id),
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/{}/_attr/auth_password_minimum_length", id),
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/{}/_attr/auth_password_minimum_length",
78 id
79 ))
80 .await
81 }
82
83 pub async fn group_account_policy_privilege_expiry_set(
84 &self,
85 id: &str,
86 expiry: u32,
87 ) -> Result<(), ClientError> {
88 self.perform_put_request(
89 &format!("/v1/group/{}/_attr/privilege_expiry", id),
90 vec![expiry.to_string()],
91 )
92 .await
93 }
94
95 pub async fn group_account_policy_privilege_expiry_reset(
96 &self,
97 id: &str,
98 ) -> Result<(), ClientError> {
99 self.perform_delete_request(&format!("/v1/group/{}/_attr/privilege_expiry", id))
100 .await
101 }
102
103 pub async fn group_account_policy_webauthn_attestation_set(
104 &self,
105 id: &str,
106 att_ca_list: &str,
107 ) -> Result<(), ClientError> {
108 self.perform_put_request(
109 &format!("/v1/group/{}/_attr/webauthn_attestation_ca_list", id),
110 vec![att_ca_list.to_string()],
111 )
112 .await
113 }
114
115 pub async fn group_account_policy_webauthn_attestation_reset(
116 &self,
117 id: &str,
118 ) -> Result<(), ClientError> {
119 self.perform_delete_request(&format!(
120 "/v1/group/{}/_attr/webauthn_attestation_ca_list",
121 id
122 ))
123 .await
124 }
125
126 pub async fn group_account_policy_limit_search_max_results(
127 &self,
128 id: &str,
129 maximum: u32,
130 ) -> Result<(), ClientError> {
131 self.perform_put_request(
132 &format!("/v1/group/{}/_attr/limit_search_max_results", id),
133 vec![maximum.to_string()],
134 )
135 .await
136 }
137
138 pub async fn group_account_policy_limit_search_max_results_reset(
139 &self,
140 id: &str,
141 ) -> Result<(), ClientError> {
142 self.perform_delete_request(&format!("/v1/group/{}/_attr/limit_search_max_results", id))
143 .await
144 }
145
146 pub async fn group_account_policy_limit_search_max_filter_test(
147 &self,
148 id: &str,
149 maximum: u32,
150 ) -> Result<(), ClientError> {
151 self.perform_put_request(
152 &format!("/v1/group/{}/_attr/limit_search_max_filter_test", id),
153 vec![maximum.to_string()],
154 )
155 .await
156 }
157
158 pub async fn group_account_policy_limit_search_max_filter_test_reset(
159 &self,
160 id: &str,
161 ) -> Result<(), ClientError> {
162 self.perform_delete_request(&format!(
163 "/v1/group/{}/_attr/limit_search_max_filter_test",
164 id
165 ))
166 .await
167 }
168
169 pub async fn group_account_policy_allow_primary_cred_fallback(
170 &self,
171 id: &str,
172 allow: bool,
173 ) -> Result<(), ClientError> {
174 self.perform_put_request(
175 &format!("/v1/group/{}/_attr/allow_primary_cred_fallback", id),
176 vec![allow.to_string()],
177 )
178 .await
179 }
180
181 pub async fn idm_group_purge_mail(&self, id: &str) -> Result<(), ClientError> {
182 self.idm_group_purge_attr(id, "mail").await
183 }
184
185 pub async fn idm_group_set_mail<T: serde::Serialize>(
186 &self,
187 id: &str,
188 values: &[T],
189 ) -> Result<(), ClientError> {
190 self.perform_put_request(&format!("/v1/group/{}/_attr/mail", id), values)
191 .await
192 }
193
194 pub async fn idm_group_get_mail(&self, id: &str) -> Result<Option<Vec<String>>, ClientError> {
195 self.perform_get_request(&format!("/v1/group/{}/_attr/mail", id))
196 .await
197 }
198
199 pub async fn idm_group_purge_description(&self, id: &str) -> Result<(), ClientError> {
200 self.idm_group_purge_attr(id, "description").await
201 }
202
203 pub async fn idm_group_set_description(
204 &self,
205 id: &str,
206 description: &str,
207 ) -> Result<(), ClientError> {
208 self.perform_put_request(
209 &format!("/v1/group/{}/_attr/description", id),
210 &[description],
211 )
212 .await
213 }
214}