1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AccessGroupsCreateGroupError {
22 Status400(models::PveError),
23 Status401(models::PveError),
24 Status403(models::PveError),
25 Status404(models::PveError),
26 Status500(models::PveError),
27 Status501(models::PveError),
28 Status503(models::PveError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AccessGroupsDeleteGroupError {
36 Status400(models::PveError),
37 Status401(models::PveError),
38 Status403(models::PveError),
39 Status404(models::PveError),
40 Status500(models::PveError),
41 Status501(models::PveError),
42 Status503(models::PveError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AccessGroupsGetGroupsError {
50 Status400(models::PveError),
51 Status401(models::PveError),
52 Status403(models::PveError),
53 Status404(models::PveError),
54 Status500(models::PveError),
55 Status501(models::PveError),
56 Status503(models::PveError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum AccessGroupsReadGroupError {
64 Status400(models::PveError),
65 Status401(models::PveError),
66 Status403(models::PveError),
67 Status404(models::PveError),
68 Status500(models::PveError),
69 Status501(models::PveError),
70 Status503(models::PveError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AccessGroupsUpdateGroupError {
78 Status400(models::PveError),
79 Status401(models::PveError),
80 Status403(models::PveError),
81 Status404(models::PveError),
82 Status500(models::PveError),
83 Status501(models::PveError),
84 Status503(models::PveError),
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn access_groups_create_group(configuration: &configuration::Configuration, access_groups_create_group_request: models::AccessGroupsCreateGroupRequest) -> Result<models::AccessGroupsCreateGroupResponse, Error<AccessGroupsCreateGroupError>> {
91 let p_body_access_groups_create_group_request = access_groups_create_group_request;
93
94 let uri_str = format!("{}/access/groups", configuration.base_path);
95 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
96
97 if let Some(ref user_agent) = configuration.user_agent {
98 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99 }
100 if let Some(ref apikey) = configuration.api_key {
101 let key = apikey.key.clone();
102 let value = match apikey.prefix {
103 Some(ref prefix) => format!("{} {}", prefix, key),
104 None => key,
105 };
106 req_builder = req_builder.header("Authorization", value);
107 };
108 if let Some(ref apikey) = configuration.api_key {
109 let key = apikey.key.clone();
110 let value = match apikey.prefix {
111 Some(ref prefix) => format!("{} {}", prefix, key),
112 None => key,
113 };
114 req_builder = req_builder.header("CSRFPreventionToken", value);
115 };
116 req_builder = req_builder.json(&p_body_access_groups_create_group_request);
117
118 let req = req_builder.build()?;
119 let resp = configuration.client.execute(req).await?;
120
121 let status = resp.status();
122 let content_type = resp
123 .headers()
124 .get("content-type")
125 .and_then(|v| v.to_str().ok())
126 .unwrap_or("application/octet-stream");
127 let content_type = super::ContentType::from(content_type);
128
129 if !status.is_client_error() && !status.is_server_error() {
130 let content = resp.text().await?;
131 match content_type {
132 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
133 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGroupsCreateGroupResponse`"))),
134 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGroupsCreateGroupResponse`")))),
135 }
136 } else {
137 let content = resp.text().await?;
138 let entity: Option<AccessGroupsCreateGroupError> = serde_json::from_str(&content).ok();
139 Err(Error::ResponseError(ResponseContent { status, content, entity }))
140 }
141}
142
143pub async fn access_groups_delete_group(configuration: &configuration::Configuration, groupid: &str) -> Result<models::AccessGroupsDeleteGroupResponse, Error<AccessGroupsDeleteGroupError>> {
145 let p_path_groupid = groupid;
147
148 let uri_str = format!("{}/access/groups/{groupid}", configuration.base_path, groupid=crate::apis::urlencode(p_path_groupid));
149 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
150
151 if let Some(ref user_agent) = configuration.user_agent {
152 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
153 }
154 if let Some(ref apikey) = configuration.api_key {
155 let key = apikey.key.clone();
156 let value = match apikey.prefix {
157 Some(ref prefix) => format!("{} {}", prefix, key),
158 None => key,
159 };
160 req_builder = req_builder.header("Authorization", value);
161 };
162 if let Some(ref apikey) = configuration.api_key {
163 let key = apikey.key.clone();
164 let value = match apikey.prefix {
165 Some(ref prefix) => format!("{} {}", prefix, key),
166 None => key,
167 };
168 req_builder = req_builder.header("CSRFPreventionToken", value);
169 };
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGroupsDeleteGroupResponse`"))),
187 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGroupsDeleteGroupResponse`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<AccessGroupsDeleteGroupError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent { status, content, entity }))
193 }
194}
195
196pub async fn access_groups_get_groups(configuration: &configuration::Configuration, ) -> Result<models::AccessGroupsGetGroupsResponse, Error<AccessGroupsGetGroupsError>> {
198
199 let uri_str = format!("{}/access/groups", configuration.base_path);
200 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
201
202 if let Some(ref user_agent) = configuration.user_agent {
203 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
204 }
205 if let Some(ref apikey) = configuration.api_key {
206 let key = apikey.key.clone();
207 let value = match apikey.prefix {
208 Some(ref prefix) => format!("{} {}", prefix, key),
209 None => key,
210 };
211 req_builder = req_builder.header("Authorization", value);
212 };
213 if let Some(ref apikey) = configuration.api_key {
214 let key = apikey.key.clone();
215 let value = match apikey.prefix {
216 Some(ref prefix) => format!("{} {}", prefix, key),
217 None => key,
218 };
219 req_builder = req_builder.header("CSRFPreventionToken", value);
220 };
221
222 let req = req_builder.build()?;
223 let resp = configuration.client.execute(req).await?;
224
225 let status = resp.status();
226 let content_type = resp
227 .headers()
228 .get("content-type")
229 .and_then(|v| v.to_str().ok())
230 .unwrap_or("application/octet-stream");
231 let content_type = super::ContentType::from(content_type);
232
233 if !status.is_client_error() && !status.is_server_error() {
234 let content = resp.text().await?;
235 match content_type {
236 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
237 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGroupsGetGroupsResponse`"))),
238 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGroupsGetGroupsResponse`")))),
239 }
240 } else {
241 let content = resp.text().await?;
242 let entity: Option<AccessGroupsGetGroupsError> = serde_json::from_str(&content).ok();
243 Err(Error::ResponseError(ResponseContent { status, content, entity }))
244 }
245}
246
247pub async fn access_groups_read_group(configuration: &configuration::Configuration, groupid: &str) -> Result<models::AccessGroupsReadGroupResponse, Error<AccessGroupsReadGroupError>> {
249 let p_path_groupid = groupid;
251
252 let uri_str = format!("{}/access/groups/{groupid}", configuration.base_path, groupid=crate::apis::urlencode(p_path_groupid));
253 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
254
255 if let Some(ref user_agent) = configuration.user_agent {
256 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
257 }
258 if let Some(ref apikey) = configuration.api_key {
259 let key = apikey.key.clone();
260 let value = match apikey.prefix {
261 Some(ref prefix) => format!("{} {}", prefix, key),
262 None => key,
263 };
264 req_builder = req_builder.header("Authorization", value);
265 };
266 if let Some(ref apikey) = configuration.api_key {
267 let key = apikey.key.clone();
268 let value = match apikey.prefix {
269 Some(ref prefix) => format!("{} {}", prefix, key),
270 None => key,
271 };
272 req_builder = req_builder.header("CSRFPreventionToken", value);
273 };
274
275 let req = req_builder.build()?;
276 let resp = configuration.client.execute(req).await?;
277
278 let status = resp.status();
279 let content_type = resp
280 .headers()
281 .get("content-type")
282 .and_then(|v| v.to_str().ok())
283 .unwrap_or("application/octet-stream");
284 let content_type = super::ContentType::from(content_type);
285
286 if !status.is_client_error() && !status.is_server_error() {
287 let content = resp.text().await?;
288 match content_type {
289 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
290 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGroupsReadGroupResponse`"))),
291 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGroupsReadGroupResponse`")))),
292 }
293 } else {
294 let content = resp.text().await?;
295 let entity: Option<AccessGroupsReadGroupError> = serde_json::from_str(&content).ok();
296 Err(Error::ResponseError(ResponseContent { status, content, entity }))
297 }
298}
299
300pub async fn access_groups_update_group(configuration: &configuration::Configuration, groupid: &str, access_groups_update_group_request: Option<models::AccessGroupsUpdateGroupRequest>) -> Result<models::AccessGroupsUpdateGroupResponse, Error<AccessGroupsUpdateGroupError>> {
302 let p_path_groupid = groupid;
304 let p_body_access_groups_update_group_request = access_groups_update_group_request;
305
306 let uri_str = format!("{}/access/groups/{groupid}", configuration.base_path, groupid=crate::apis::urlencode(p_path_groupid));
307 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
308
309 if let Some(ref user_agent) = configuration.user_agent {
310 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
311 }
312 if let Some(ref apikey) = configuration.api_key {
313 let key = apikey.key.clone();
314 let value = match apikey.prefix {
315 Some(ref prefix) => format!("{} {}", prefix, key),
316 None => key,
317 };
318 req_builder = req_builder.header("Authorization", value);
319 };
320 if let Some(ref apikey) = configuration.api_key {
321 let key = apikey.key.clone();
322 let value = match apikey.prefix {
323 Some(ref prefix) => format!("{} {}", prefix, key),
324 None => key,
325 };
326 req_builder = req_builder.header("CSRFPreventionToken", value);
327 };
328 req_builder = req_builder.json(&p_body_access_groups_update_group_request);
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334 let content_type = resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let content_type = super::ContentType::from(content_type);
340
341 if !status.is_client_error() && !status.is_server_error() {
342 let content = resp.text().await?;
343 match content_type {
344 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGroupsUpdateGroupResponse`"))),
346 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGroupsUpdateGroupResponse`")))),
347 }
348 } else {
349 let content = resp.text().await?;
350 let entity: Option<AccessGroupsUpdateGroupError> = serde_json::from_str(&content).ok();
351 Err(Error::ResponseError(ResponseContent { status, content, entity }))
352 }
353}
354