1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ScimCreateUserError {
20 Status400(serde_json::Value),
21 Status401(serde_json::Value),
22 Status403(serde_json::Value),
23 Status404(serde_json::Value),
24 Status405(serde_json::Value),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum ScimDeleteUserError {
32 Status400(serde_json::Value),
33 Status401(serde_json::Value),
34 Status403(serde_json::Value),
35 Status404(serde_json::Value),
36 Status405(serde_json::Value),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum ScimGetResourceTypesError {
44 Status400(serde_json::Value),
45 Status401(serde_json::Value),
46 Status403(serde_json::Value),
47 Status404(serde_json::Value),
48 Status405(serde_json::Value),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ScimGetSchemasError {
56 Status400(serde_json::Value),
57 Status401(serde_json::Value),
58 Status403(serde_json::Value),
59 Status404(serde_json::Value),
60 Status405(serde_json::Value),
61 UnknownValue(serde_json::Value),
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum ScimGetServiceProviderConfigError {
68 Status400(serde_json::Value),
69 Status401(serde_json::Value),
70 Status403(serde_json::Value),
71 Status404(serde_json::Value),
72 Status405(serde_json::Value),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ScimGetUserError {
80 Status400(serde_json::Value),
81 Status401(serde_json::Value),
82 Status403(serde_json::Value),
83 Status404(serde_json::Value),
84 Status405(serde_json::Value),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ScimListUsersError {
92 Status400(serde_json::Value),
93 Status401(serde_json::Value),
94 Status403(serde_json::Value),
95 Status404(serde_json::Value),
96 Status405(serde_json::Value),
97 UnknownValue(serde_json::Value),
98}
99
100pub async fn scim_create_user(
102 configuration: &configuration::Configuration,
103 scim_create_user_request: models::ScimCreateUserRequest,
104) -> Result<models::ScimUser, Error<ScimCreateUserError>> {
105 let p_body_scim_create_user_request = scim_create_user_request;
107
108 let uri_str = format!("{}/api/public/scim/Users", configuration.base_path);
109 let mut req_builder = configuration
110 .client
111 .request(reqwest::Method::POST, &uri_str);
112
113 if let Some(ref user_agent) = configuration.user_agent {
114 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
115 }
116 if let Some(ref auth_conf) = configuration.basic_auth {
117 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
118 };
119 req_builder = req_builder.json(&p_body_scim_create_user_request);
120
121 let req = req_builder.build()?;
122 let resp = configuration.client.execute(req).await?;
123
124 let status = resp.status();
125 let content_type = resp
126 .headers()
127 .get("content-type")
128 .and_then(|v| v.to_str().ok())
129 .unwrap_or("application/octet-stream");
130 let content_type = super::ContentType::from(content_type);
131
132 if !status.is_client_error() && !status.is_server_error() {
133 let content = resp.text().await?;
134 match content_type {
135 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
136 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUser`"))),
137 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::ScimUser`")))),
138 }
139 } else {
140 let content = resp.text().await?;
141 let entity: Option<ScimCreateUserError> = serde_json::from_str(&content).ok();
142 Err(Error::ResponseError(ResponseContent {
143 status,
144 content,
145 entity,
146 }))
147 }
148}
149
150pub async fn scim_delete_user(
152 configuration: &configuration::Configuration,
153 user_id: &str,
154) -> Result<serde_json::Value, Error<ScimDeleteUserError>> {
155 let p_path_user_id = user_id;
157
158 let uri_str = format!(
159 "{}/api/public/scim/Users/{userId}",
160 configuration.base_path,
161 userId = crate::apis::urlencode(p_path_user_id)
162 );
163 let mut req_builder = configuration
164 .client
165 .request(reqwest::Method::DELETE, &uri_str);
166
167 if let Some(ref user_agent) = configuration.user_agent {
168 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169 }
170 if let Some(ref auth_conf) = configuration.basic_auth {
171 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
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 `serde_json::Value`"))),
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 `serde_json::Value`")))),
191 }
192 } else {
193 let content = resp.text().await?;
194 let entity: Option<ScimDeleteUserError> = serde_json::from_str(&content).ok();
195 Err(Error::ResponseError(ResponseContent {
196 status,
197 content,
198 entity,
199 }))
200 }
201}
202
203pub async fn scim_get_resource_types(
205 configuration: &configuration::Configuration,
206) -> Result<models::ResourceTypesResponse, Error<ScimGetResourceTypesError>> {
207 let uri_str = format!("{}/api/public/scim/ResourceTypes", configuration.base_path);
208 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
209
210 if let Some(ref user_agent) = configuration.user_agent {
211 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212 }
213 if let Some(ref auth_conf) = configuration.basic_auth {
214 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
215 };
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResourceTypesResponse`"))),
233 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::ResourceTypesResponse`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<ScimGetResourceTypesError> = serde_json::from_str(&content).ok();
238 Err(Error::ResponseError(ResponseContent {
239 status,
240 content,
241 entity,
242 }))
243 }
244}
245
246pub async fn scim_get_schemas(
248 configuration: &configuration::Configuration,
249) -> Result<models::SchemasResponse, Error<ScimGetSchemasError>> {
250 let uri_str = format!("{}/api/public/scim/Schemas", configuration.base_path);
251 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
252
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(ref auth_conf) = configuration.basic_auth {
257 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264 let content_type = resp
265 .headers()
266 .get("content-type")
267 .and_then(|v| v.to_str().ok())
268 .unwrap_or("application/octet-stream");
269 let content_type = super::ContentType::from(content_type);
270
271 if !status.is_client_error() && !status.is_server_error() {
272 let content = resp.text().await?;
273 match content_type {
274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SchemasResponse`"))),
276 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::SchemasResponse`")))),
277 }
278 } else {
279 let content = resp.text().await?;
280 let entity: Option<ScimGetSchemasError> = serde_json::from_str(&content).ok();
281 Err(Error::ResponseError(ResponseContent {
282 status,
283 content,
284 entity,
285 }))
286 }
287}
288
289pub async fn scim_get_service_provider_config(
291 configuration: &configuration::Configuration,
292) -> Result<models::ServiceProviderConfig, Error<ScimGetServiceProviderConfigError>> {
293 let uri_str = format!(
294 "{}/api/public/scim/ServiceProviderConfig",
295 configuration.base_path
296 );
297 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
298
299 if let Some(ref user_agent) = configuration.user_agent {
300 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
301 }
302 if let Some(ref auth_conf) = configuration.basic_auth {
303 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
304 };
305
306 let req = req_builder.build()?;
307 let resp = configuration.client.execute(req).await?;
308
309 let status = resp.status();
310 let content_type = resp
311 .headers()
312 .get("content-type")
313 .and_then(|v| v.to_str().ok())
314 .unwrap_or("application/octet-stream");
315 let content_type = super::ContentType::from(content_type);
316
317 if !status.is_client_error() && !status.is_server_error() {
318 let content = resp.text().await?;
319 match content_type {
320 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
321 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceProviderConfig`"))),
322 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::ServiceProviderConfig`")))),
323 }
324 } else {
325 let content = resp.text().await?;
326 let entity: Option<ScimGetServiceProviderConfigError> = serde_json::from_str(&content).ok();
327 Err(Error::ResponseError(ResponseContent {
328 status,
329 content,
330 entity,
331 }))
332 }
333}
334
335pub async fn scim_get_user(
337 configuration: &configuration::Configuration,
338 user_id: &str,
339) -> Result<models::ScimUser, Error<ScimGetUserError>> {
340 let p_path_user_id = user_id;
342
343 let uri_str = format!(
344 "{}/api/public/scim/Users/{userId}",
345 configuration.base_path,
346 userId = crate::apis::urlencode(p_path_user_id)
347 );
348 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
349
350 if let Some(ref user_agent) = configuration.user_agent {
351 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
352 }
353 if let Some(ref auth_conf) = configuration.basic_auth {
354 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
355 };
356
357 let req = req_builder.build()?;
358 let resp = configuration.client.execute(req).await?;
359
360 let status = resp.status();
361 let content_type = resp
362 .headers()
363 .get("content-type")
364 .and_then(|v| v.to_str().ok())
365 .unwrap_or("application/octet-stream");
366 let content_type = super::ContentType::from(content_type);
367
368 if !status.is_client_error() && !status.is_server_error() {
369 let content = resp.text().await?;
370 match content_type {
371 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
372 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUser`"))),
373 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::ScimUser`")))),
374 }
375 } else {
376 let content = resp.text().await?;
377 let entity: Option<ScimGetUserError> = serde_json::from_str(&content).ok();
378 Err(Error::ResponseError(ResponseContent {
379 status,
380 content,
381 entity,
382 }))
383 }
384}
385
386pub async fn scim_list_users(
388 configuration: &configuration::Configuration,
389 filter: Option<&str>,
390 start_index: Option<i32>,
391 count: Option<i32>,
392) -> Result<models::ScimUsersListResponse, Error<ScimListUsersError>> {
393 let p_query_filter = filter;
395 let p_query_start_index = start_index;
396 let p_query_count = count;
397
398 let uri_str = format!("{}/api/public/scim/Users", configuration.base_path);
399 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
400
401 if let Some(ref param_value) = p_query_filter {
402 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
403 }
404 if let Some(ref param_value) = p_query_start_index {
405 req_builder = req_builder.query(&[("startIndex", ¶m_value.to_string())]);
406 }
407 if let Some(ref param_value) = p_query_count {
408 req_builder = req_builder.query(&[("count", ¶m_value.to_string())]);
409 }
410 if let Some(ref user_agent) = configuration.user_agent {
411 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
412 }
413 if let Some(ref auth_conf) = configuration.basic_auth {
414 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
415 };
416
417 let req = req_builder.build()?;
418 let resp = configuration.client.execute(req).await?;
419
420 let status = resp.status();
421 let content_type = resp
422 .headers()
423 .get("content-type")
424 .and_then(|v| v.to_str().ok())
425 .unwrap_or("application/octet-stream");
426 let content_type = super::ContentType::from(content_type);
427
428 if !status.is_client_error() && !status.is_server_error() {
429 let content = resp.text().await?;
430 match content_type {
431 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
432 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUsersListResponse`"))),
433 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::ScimUsersListResponse`")))),
434 }
435 } else {
436 let content = resp.text().await?;
437 let entity: Option<ScimListUsersError> = serde_json::from_str(&content).ok();
438 Err(Error::ResponseError(ResponseContent {
439 status,
440 content,
441 entity,
442 }))
443 }
444}