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 AddOrganisationToSharingGroupError {
22 Status403(models::UnauthorizedApiError),
23 Status404(models::NotFoundApiError),
24 DefaultResponse(models::ApiError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum AddServerToSharingGroupError {
32 Status403(models::UnauthorizedApiError),
33 Status404(models::NotFoundApiError),
34 DefaultResponse(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum AddSharingGroupError {
42 Status403(models::UnauthorizedApiError),
43 Status404(models::NotFoundApiError),
44 DefaultResponse(models::ApiError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum DeleteSharingGroupError {
52 Status403(models::UnauthorizedApiError),
53 Status404(models::NotFoundApiError),
54 DefaultResponse(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum EditSharingGroupError {
62 Status403(models::UnauthorizedApiError),
63 Status404(models::NotFoundApiError),
64 DefaultResponse(models::ApiError),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetSharingGroupError {
72 Status403(models::UnauthorizedApiError),
73 Status404(models::NotFoundApiError),
74 DefaultResponse(models::ApiError),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetSharingGroupByIdError {
82 Status403(models::UnauthorizedApiError),
83 Status404(models::NotFoundApiError),
84 DefaultResponse(models::ApiError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RemoveOrganisationFromSharingGroupError {
92 Status403(models::UnauthorizedApiError),
93 Status404(models::NotFoundApiError),
94 DefaultResponse(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum RemoveServerFromSharingGroupError {
102 Status403(models::UnauthorizedApiError),
103 Status404(models::NotFoundApiError),
104 DefaultResponse(models::ApiError),
105 UnknownValue(serde_json::Value),
106}
107
108
109pub async fn add_organisation_to_sharing_group(configuration: &configuration::Configuration, sharing_group_id: &str, organisation_id: &str) -> Result<models::AddOrganisationToSharingGroup200Response, Error<AddOrganisationToSharingGroupError>> {
110 let p_sharing_group_id = sharing_group_id;
112 let p_organisation_id = organisation_id;
113
114 let uri_str = format!("{}/sharing_groups/addOrg/{sharingGroupId}/{organisationId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string(), organisationId=p_organisation_id.to_string());
115 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
116
117 if let Some(ref user_agent) = configuration.user_agent {
118 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119 }
120 if let Some(ref apikey) = configuration.api_key {
121 let key = apikey.key.clone();
122 let value = match apikey.prefix {
123 Some(ref prefix) => format!("{} {}", prefix, key),
124 None => key,
125 };
126 req_builder = req_builder.header("Authorization", value);
127 };
128
129 let req = req_builder.build()?;
130 let resp = configuration.client.execute(req).await?;
131
132 let status = resp.status();
133 let content_type = resp
134 .headers()
135 .get("content-type")
136 .and_then(|v| v.to_str().ok())
137 .unwrap_or("application/octet-stream");
138 let content_type = super::ContentType::from(content_type);
139
140 if !status.is_client_error() && !status.is_server_error() {
141 let content = resp.text().await?;
142 match content_type {
143 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
144 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddOrganisationToSharingGroup200Response`"))),
145 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::AddOrganisationToSharingGroup200Response`")))),
146 }
147 } else {
148 let content = resp.text().await?;
149 let entity: Option<AddOrganisationToSharingGroupError> = serde_json::from_str(&content).ok();
150 Err(Error::ResponseError(ResponseContent { status, content, entity }))
151 }
152}
153
154pub async fn add_server_to_sharing_group(configuration: &configuration::Configuration, sharing_group_id: &str, server_id: &str) -> Result<models::AddServerToSharingGroup200Response, Error<AddServerToSharingGroupError>> {
155 let p_sharing_group_id = sharing_group_id;
157 let p_server_id = server_id;
158
159 let uri_str = format!("{}/sharing_groups/addServer/{sharingGroupId}/{serverId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string(), serverId=p_server_id.to_string());
160 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
161
162 if let Some(ref user_agent) = configuration.user_agent {
163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164 }
165 if let Some(ref apikey) = configuration.api_key {
166 let key = apikey.key.clone();
167 let value = match apikey.prefix {
168 Some(ref prefix) => format!("{} {}", prefix, key),
169 None => key,
170 };
171 req_builder = req_builder.header("Authorization", value);
172 };
173
174 let req = req_builder.build()?;
175 let resp = configuration.client.execute(req).await?;
176
177 let status = resp.status();
178 let content_type = resp
179 .headers()
180 .get("content-type")
181 .and_then(|v| v.to_str().ok())
182 .unwrap_or("application/octet-stream");
183 let content_type = super::ContentType::from(content_type);
184
185 if !status.is_client_error() && !status.is_server_error() {
186 let content = resp.text().await?;
187 match content_type {
188 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddServerToSharingGroup200Response`"))),
190 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::AddServerToSharingGroup200Response`")))),
191 }
192 } else {
193 let content = resp.text().await?;
194 let entity: Option<AddServerToSharingGroupError> = serde_json::from_str(&content).ok();
195 Err(Error::ResponseError(ResponseContent { status, content, entity }))
196 }
197}
198
199pub async fn add_sharing_group(configuration: &configuration::Configuration, sharing_group_no_id: Option<models::SharingGroupNoId>) -> Result<models::AddSharingGroup200Response, Error<AddSharingGroupError>> {
200 let p_sharing_group_no_id = sharing_group_no_id;
202
203 let uri_str = format!("{}/sharing_groups/add", configuration.base_path);
204 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
205
206 if let Some(ref user_agent) = configuration.user_agent {
207 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
208 }
209 if let Some(ref apikey) = configuration.api_key {
210 let key = apikey.key.clone();
211 let value = match apikey.prefix {
212 Some(ref prefix) => format!("{} {}", prefix, key),
213 None => key,
214 };
215 req_builder = req_builder.header("Authorization", value);
216 };
217 req_builder = req_builder.json(&p_sharing_group_no_id);
218
219 let req = req_builder.build()?;
220 let resp = configuration.client.execute(req).await?;
221
222 let status = resp.status();
223 let content_type = resp
224 .headers()
225 .get("content-type")
226 .and_then(|v| v.to_str().ok())
227 .unwrap_or("application/octet-stream");
228 let content_type = super::ContentType::from(content_type);
229
230 if !status.is_client_error() && !status.is_server_error() {
231 let content = resp.text().await?;
232 match content_type {
233 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
234 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddSharingGroup200Response`"))),
235 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::AddSharingGroup200Response`")))),
236 }
237 } else {
238 let content = resp.text().await?;
239 let entity: Option<AddSharingGroupError> = serde_json::from_str(&content).ok();
240 Err(Error::ResponseError(ResponseContent { status, content, entity }))
241 }
242}
243
244pub async fn delete_sharing_group(configuration: &configuration::Configuration, sharing_group_id: &str) -> Result<models::DeleteSharingGroup200Response, Error<DeleteSharingGroupError>> {
245 let p_sharing_group_id = sharing_group_id;
247
248 let uri_str = format!("{}/sharing_groups/delete/{sharingGroupId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string());
249 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
250
251 if let Some(ref user_agent) = configuration.user_agent {
252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253 }
254 if let Some(ref apikey) = configuration.api_key {
255 let key = apikey.key.clone();
256 let value = match apikey.prefix {
257 Some(ref prefix) => format!("{} {}", prefix, key),
258 None => key,
259 };
260 req_builder = req_builder.header("Authorization", value);
261 };
262
263 let req = req_builder.build()?;
264 let resp = configuration.client.execute(req).await?;
265
266 let status = resp.status();
267 let content_type = resp
268 .headers()
269 .get("content-type")
270 .and_then(|v| v.to_str().ok())
271 .unwrap_or("application/octet-stream");
272 let content_type = super::ContentType::from(content_type);
273
274 if !status.is_client_error() && !status.is_server_error() {
275 let content = resp.text().await?;
276 match content_type {
277 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
278 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteSharingGroup200Response`"))),
279 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::DeleteSharingGroup200Response`")))),
280 }
281 } else {
282 let content = resp.text().await?;
283 let entity: Option<DeleteSharingGroupError> = serde_json::from_str(&content).ok();
284 Err(Error::ResponseError(ResponseContent { status, content, entity }))
285 }
286}
287
288pub async fn edit_sharing_group(configuration: &configuration::Configuration, sharing_group_id: &str, sharing_group: Option<models::SharingGroup>) -> Result<models::AddSharingGroup200Response, Error<EditSharingGroupError>> {
289 let p_sharing_group_id = sharing_group_id;
291 let p_sharing_group = sharing_group;
292
293 let uri_str = format!("{}/sharing_groups/edit/{sharingGroupId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string());
294 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
295
296 if let Some(ref user_agent) = configuration.user_agent {
297 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
298 }
299 if let Some(ref apikey) = configuration.api_key {
300 let key = apikey.key.clone();
301 let value = match apikey.prefix {
302 Some(ref prefix) => format!("{} {}", prefix, key),
303 None => key,
304 };
305 req_builder = req_builder.header("Authorization", value);
306 };
307 req_builder = req_builder.json(&p_sharing_group);
308
309 let req = req_builder.build()?;
310 let resp = configuration.client.execute(req).await?;
311
312 let status = resp.status();
313 let content_type = resp
314 .headers()
315 .get("content-type")
316 .and_then(|v| v.to_str().ok())
317 .unwrap_or("application/octet-stream");
318 let content_type = super::ContentType::from(content_type);
319
320 if !status.is_client_error() && !status.is_server_error() {
321 let content = resp.text().await?;
322 match content_type {
323 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
324 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddSharingGroup200Response`"))),
325 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::AddSharingGroup200Response`")))),
326 }
327 } else {
328 let content = resp.text().await?;
329 let entity: Option<EditSharingGroupError> = serde_json::from_str(&content).ok();
330 Err(Error::ResponseError(ResponseContent { status, content, entity }))
331 }
332}
333
334pub async fn get_sharing_group(configuration: &configuration::Configuration, ) -> Result<models::GetSharingGroup200Response, Error<GetSharingGroupError>> {
335
336 let uri_str = format!("{}/sharing_groups", configuration.base_path);
337 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
338
339 if let Some(ref user_agent) = configuration.user_agent {
340 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
341 }
342 if let Some(ref apikey) = configuration.api_key {
343 let key = apikey.key.clone();
344 let value = match apikey.prefix {
345 Some(ref prefix) => format!("{} {}", prefix, key),
346 None => key,
347 };
348 req_builder = req_builder.header("Authorization", value);
349 };
350
351 let req = req_builder.build()?;
352 let resp = configuration.client.execute(req).await?;
353
354 let status = resp.status();
355 let content_type = resp
356 .headers()
357 .get("content-type")
358 .and_then(|v| v.to_str().ok())
359 .unwrap_or("application/octet-stream");
360 let content_type = super::ContentType::from(content_type);
361
362 if !status.is_client_error() && !status.is_server_error() {
363 let content = resp.text().await?;
364 match content_type {
365 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
366 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetSharingGroup200Response`"))),
367 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::GetSharingGroup200Response`")))),
368 }
369 } else {
370 let content = resp.text().await?;
371 let entity: Option<GetSharingGroupError> = serde_json::from_str(&content).ok();
372 Err(Error::ResponseError(ResponseContent { status, content, entity }))
373 }
374}
375
376pub async fn get_sharing_group_by_id(configuration: &configuration::Configuration, sharing_group_id: &str) -> Result<models::AddSharingGroup200Response, Error<GetSharingGroupByIdError>> {
377 let p_sharing_group_id = sharing_group_id;
379
380 let uri_str = format!("{}/sharing_groups/view/{sharingGroupId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string());
381 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
382
383 if let Some(ref user_agent) = configuration.user_agent {
384 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
385 }
386 if let Some(ref apikey) = configuration.api_key {
387 let key = apikey.key.clone();
388 let value = match apikey.prefix {
389 Some(ref prefix) => format!("{} {}", prefix, key),
390 None => key,
391 };
392 req_builder = req_builder.header("Authorization", value);
393 };
394
395 let req = req_builder.build()?;
396 let resp = configuration.client.execute(req).await?;
397
398 let status = resp.status();
399 let content_type = resp
400 .headers()
401 .get("content-type")
402 .and_then(|v| v.to_str().ok())
403 .unwrap_or("application/octet-stream");
404 let content_type = super::ContentType::from(content_type);
405
406 if !status.is_client_error() && !status.is_server_error() {
407 let content = resp.text().await?;
408 match content_type {
409 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
410 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddSharingGroup200Response`"))),
411 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::AddSharingGroup200Response`")))),
412 }
413 } else {
414 let content = resp.text().await?;
415 let entity: Option<GetSharingGroupByIdError> = serde_json::from_str(&content).ok();
416 Err(Error::ResponseError(ResponseContent { status, content, entity }))
417 }
418}
419
420pub async fn remove_organisation_from_sharing_group(configuration: &configuration::Configuration, sharing_group_id: &str, organisation_id: &str) -> Result<models::RemoveOrganisationFromSharingGroup200Response, Error<RemoveOrganisationFromSharingGroupError>> {
421 let p_sharing_group_id = sharing_group_id;
423 let p_organisation_id = organisation_id;
424
425 let uri_str = format!("{}/sharing_groups/removeOrg/{sharingGroupId}/{organisationId}", configuration.base_path, sharingGroupId=p_sharing_group_id.to_string(), organisationId=p_organisation_id.to_string());
426 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
427
428 if let Some(ref user_agent) = configuration.user_agent {
429 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
430 }
431 if let Some(ref apikey) = configuration.api_key {
432 let key = apikey.key.clone();
433 let value = match apikey.prefix {
434 Some(ref prefix) => format!("{} {}", prefix, key),
435 None => key,
436 };
437 req_builder = req_builder.header("Authorization", value);
438 };
439
440 let req = req_builder.build()?;
441 let resp = configuration.client.execute(req).await?;
442
443 let status = resp.status();
444 let content_type = resp
445 .headers()
446 .get("content-type")
447 .and_then(|v| v.to_str().ok())
448 .unwrap_or("application/octet-stream");
449 let content_type = super::ContentType::from(content_type);
450
451 if !status.is_client_error() && !status.is_server_error() {
452 let content = resp.text().await?;
453 match content_type {
454 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
455 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveOrganisationFromSharingGroup200Response`"))),
456 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::RemoveOrganisationFromSharingGroup200Response`")))),
457 }
458 } else {
459 let content = resp.text().await?;
460 let entity: Option<RemoveOrganisationFromSharingGroupError> = serde_json::from_str(&content).ok();
461 Err(Error::ResponseError(ResponseContent { status, content, entity }))
462 }
463}
464
465pub async fn remove_server_from_sharing_group(configuration: &configuration::Configuration, sharing_group_server_id: Option<&str>, server_id: &str) -> Result<models::RemoveServerFromSharingGroup200Response, Error<RemoveServerFromSharingGroupError>> {
466 let p_sharing_group_server_id = sharing_group_server_id;
468 let p_server_id = server_id;
469
470 let uri_str = format!("{}/sharing_groups/removeServer/{sharingGroupServerId}/{serverId}", configuration.base_path, sharingGroupServerId=crate::apis::urlencode(p_sharing_group_server_id.unwrap()), serverId=p_server_id.to_string());
471 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
472
473 if let Some(ref user_agent) = configuration.user_agent {
474 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
475 }
476 if let Some(ref apikey) = configuration.api_key {
477 let key = apikey.key.clone();
478 let value = match apikey.prefix {
479 Some(ref prefix) => format!("{} {}", prefix, key),
480 None => key,
481 };
482 req_builder = req_builder.header("Authorization", value);
483 };
484
485 let req = req_builder.build()?;
486 let resp = configuration.client.execute(req).await?;
487
488 let status = resp.status();
489 let content_type = resp
490 .headers()
491 .get("content-type")
492 .and_then(|v| v.to_str().ok())
493 .unwrap_or("application/octet-stream");
494 let content_type = super::ContentType::from(content_type);
495
496 if !status.is_client_error() && !status.is_server_error() {
497 let content = resp.text().await?;
498 match content_type {
499 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
500 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveServerFromSharingGroup200Response`"))),
501 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::RemoveServerFromSharingGroup200Response`")))),
502 }
503 } else {
504 let content = resp.text().await?;
505 let entity: Option<RemoveServerFromSharingGroupError> = serde_json::from_str(&content).ok();
506 Err(Error::ResponseError(ResponseContent { status, content, entity }))
507 }
508}
509