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 ScimCreateUserError {
22 Status400(serde_json::Value),
23 Status401(serde_json::Value),
24 Status403(serde_json::Value),
25 Status404(serde_json::Value),
26 Status405(serde_json::Value),
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum ScimDeleteUserError {
34 Status400(serde_json::Value),
35 Status401(serde_json::Value),
36 Status403(serde_json::Value),
37 Status404(serde_json::Value),
38 Status405(serde_json::Value),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum ScimGetResourceTypesError {
46 Status400(serde_json::Value),
47 Status401(serde_json::Value),
48 Status403(serde_json::Value),
49 Status404(serde_json::Value),
50 Status405(serde_json::Value),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum ScimGetSchemasError {
58 Status400(serde_json::Value),
59 Status401(serde_json::Value),
60 Status403(serde_json::Value),
61 Status404(serde_json::Value),
62 Status405(serde_json::Value),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ScimGetServiceProviderConfigError {
70 Status400(serde_json::Value),
71 Status401(serde_json::Value),
72 Status403(serde_json::Value),
73 Status404(serde_json::Value),
74 Status405(serde_json::Value),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum ScimGetUserError {
82 Status400(serde_json::Value),
83 Status401(serde_json::Value),
84 Status403(serde_json::Value),
85 Status404(serde_json::Value),
86 Status405(serde_json::Value),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum ScimListUsersError {
94 Status400(serde_json::Value),
95 Status401(serde_json::Value),
96 Status403(serde_json::Value),
97 Status404(serde_json::Value),
98 Status405(serde_json::Value),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn scim_create_user(configuration: &configuration::Configuration, scim_create_user_request: models::ScimCreateUserRequest) -> Result<models::ScimUser, Error<ScimCreateUserError>> {
105 let p_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.client.request(reqwest::Method::POST, &uri_str);
110
111 if let Some(ref user_agent) = configuration.user_agent {
112 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113 }
114 if let Some(ref auth_conf) = configuration.basic_auth {
115 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
116 };
117 req_builder = req_builder.json(&p_scim_create_user_request);
118
119 let req = req_builder.build()?;
120 let resp = configuration.client.execute(req).await?;
121
122 let status = resp.status();
123 let content_type = resp
124 .headers()
125 .get("content-type")
126 .and_then(|v| v.to_str().ok())
127 .unwrap_or("application/octet-stream");
128 let content_type = super::ContentType::from(content_type);
129
130 if !status.is_client_error() && !status.is_server_error() {
131 let content = resp.text().await?;
132 match content_type {
133 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
134 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUser`"))),
135 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`")))),
136 }
137 } else {
138 let content = resp.text().await?;
139 let entity: Option<ScimCreateUserError> = serde_json::from_str(&content).ok();
140 Err(Error::ResponseError(ResponseContent { status, content, entity }))
141 }
142}
143
144pub async fn scim_delete_user(configuration: &configuration::Configuration, user_id: &str) -> Result<serde_json::Value, Error<ScimDeleteUserError>> {
146 let p_user_id = user_id;
148
149 let uri_str = format!("{}/api/public/scim/Users/{userId}", configuration.base_path, userId=crate::apis::urlencode(p_user_id));
150 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
151
152 if let Some(ref user_agent) = configuration.user_agent {
153 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154 }
155 if let Some(ref auth_conf) = configuration.basic_auth {
156 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
157 };
158
159 let req = req_builder.build()?;
160 let resp = configuration.client.execute(req).await?;
161
162 let status = resp.status();
163 let content_type = resp
164 .headers()
165 .get("content-type")
166 .and_then(|v| v.to_str().ok())
167 .unwrap_or("application/octet-stream");
168 let content_type = super::ContentType::from(content_type);
169
170 if !status.is_client_error() && !status.is_server_error() {
171 let content = resp.text().await?;
172 match content_type {
173 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
174 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
175 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`")))),
176 }
177 } else {
178 let content = resp.text().await?;
179 let entity: Option<ScimDeleteUserError> = serde_json::from_str(&content).ok();
180 Err(Error::ResponseError(ResponseContent { status, content, entity }))
181 }
182}
183
184pub async fn scim_get_resource_types(configuration: &configuration::Configuration, ) -> Result<models::ResourceTypesResponse, Error<ScimGetResourceTypesError>> {
186
187 let uri_str = format!("{}/api/public/scim/ResourceTypes", configuration.base_path);
188 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
189
190 if let Some(ref user_agent) = configuration.user_agent {
191 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
192 }
193 if let Some(ref auth_conf) = configuration.basic_auth {
194 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
195 };
196
197 let req = req_builder.build()?;
198 let resp = configuration.client.execute(req).await?;
199
200 let status = resp.status();
201 let content_type = resp
202 .headers()
203 .get("content-type")
204 .and_then(|v| v.to_str().ok())
205 .unwrap_or("application/octet-stream");
206 let content_type = super::ContentType::from(content_type);
207
208 if !status.is_client_error() && !status.is_server_error() {
209 let content = resp.text().await?;
210 match content_type {
211 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
212 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResourceTypesResponse`"))),
213 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`")))),
214 }
215 } else {
216 let content = resp.text().await?;
217 let entity: Option<ScimGetResourceTypesError> = serde_json::from_str(&content).ok();
218 Err(Error::ResponseError(ResponseContent { status, content, entity }))
219 }
220}
221
222pub async fn scim_get_schemas(configuration: &configuration::Configuration, ) -> Result<models::SchemasResponse, Error<ScimGetSchemasError>> {
224
225 let uri_str = format!("{}/api/public/scim/Schemas", configuration.base_path);
226 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
227
228 if let Some(ref user_agent) = configuration.user_agent {
229 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
230 }
231 if let Some(ref auth_conf) = configuration.basic_auth {
232 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
233 };
234
235 let req = req_builder.build()?;
236 let resp = configuration.client.execute(req).await?;
237
238 let status = resp.status();
239 let content_type = resp
240 .headers()
241 .get("content-type")
242 .and_then(|v| v.to_str().ok())
243 .unwrap_or("application/octet-stream");
244 let content_type = super::ContentType::from(content_type);
245
246 if !status.is_client_error() && !status.is_server_error() {
247 let content = resp.text().await?;
248 match content_type {
249 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
250 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SchemasResponse`"))),
251 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`")))),
252 }
253 } else {
254 let content = resp.text().await?;
255 let entity: Option<ScimGetSchemasError> = serde_json::from_str(&content).ok();
256 Err(Error::ResponseError(ResponseContent { status, content, entity }))
257 }
258}
259
260pub async fn scim_get_service_provider_config(configuration: &configuration::Configuration, ) -> Result<models::ServiceProviderConfig, Error<ScimGetServiceProviderConfigError>> {
262
263 let uri_str = format!("{}/api/public/scim/ServiceProviderConfig", configuration.base_path);
264 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
265
266 if let Some(ref user_agent) = configuration.user_agent {
267 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
268 }
269 if let Some(ref auth_conf) = configuration.basic_auth {
270 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
271 };
272
273 let req = req_builder.build()?;
274 let resp = configuration.client.execute(req).await?;
275
276 let status = resp.status();
277 let content_type = resp
278 .headers()
279 .get("content-type")
280 .and_then(|v| v.to_str().ok())
281 .unwrap_or("application/octet-stream");
282 let content_type = super::ContentType::from(content_type);
283
284 if !status.is_client_error() && !status.is_server_error() {
285 let content = resp.text().await?;
286 match content_type {
287 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
288 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceProviderConfig`"))),
289 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`")))),
290 }
291 } else {
292 let content = resp.text().await?;
293 let entity: Option<ScimGetServiceProviderConfigError> = serde_json::from_str(&content).ok();
294 Err(Error::ResponseError(ResponseContent { status, content, entity }))
295 }
296}
297
298pub async fn scim_get_user(configuration: &configuration::Configuration, user_id: &str) -> Result<models::ScimUser, Error<ScimGetUserError>> {
300 let p_user_id = user_id;
302
303 let uri_str = format!("{}/api/public/scim/Users/{userId}", configuration.base_path, userId=crate::apis::urlencode(p_user_id));
304 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
305
306 if let Some(ref user_agent) = configuration.user_agent {
307 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308 }
309 if let Some(ref auth_conf) = configuration.basic_auth {
310 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
311 };
312
313 let req = req_builder.build()?;
314 let resp = configuration.client.execute(req).await?;
315
316 let status = resp.status();
317 let content_type = resp
318 .headers()
319 .get("content-type")
320 .and_then(|v| v.to_str().ok())
321 .unwrap_or("application/octet-stream");
322 let content_type = super::ContentType::from(content_type);
323
324 if !status.is_client_error() && !status.is_server_error() {
325 let content = resp.text().await?;
326 match content_type {
327 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
328 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUser`"))),
329 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`")))),
330 }
331 } else {
332 let content = resp.text().await?;
333 let entity: Option<ScimGetUserError> = serde_json::from_str(&content).ok();
334 Err(Error::ResponseError(ResponseContent { status, content, entity }))
335 }
336}
337
338pub async fn scim_list_users(configuration: &configuration::Configuration, filter: Option<&str>, start_index: Option<i32>, count: Option<i32>) -> Result<models::ScimUsersListResponse, Error<ScimListUsersError>> {
340 let p_filter = filter;
342 let p_start_index = start_index;
343 let p_count = count;
344
345 let uri_str = format!("{}/api/public/scim/Users", configuration.base_path);
346 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
347
348 if let Some(ref param_value) = p_filter {
349 req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
350 }
351 if let Some(ref param_value) = p_start_index {
352 req_builder = req_builder.query(&[("startIndex", ¶m_value.to_string())]);
353 }
354 if let Some(ref param_value) = p_count {
355 req_builder = req_builder.query(&[("count", ¶m_value.to_string())]);
356 }
357 if let Some(ref user_agent) = configuration.user_agent {
358 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359 }
360 if let Some(ref auth_conf) = configuration.basic_auth {
361 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
362 };
363
364 let req = req_builder.build()?;
365 let resp = configuration.client.execute(req).await?;
366
367 let status = resp.status();
368 let content_type = resp
369 .headers()
370 .get("content-type")
371 .and_then(|v| v.to_str().ok())
372 .unwrap_or("application/octet-stream");
373 let content_type = super::ContentType::from(content_type);
374
375 if !status.is_client_error() && !status.is_server_error() {
376 let content = resp.text().await?;
377 match content_type {
378 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
379 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScimUsersListResponse`"))),
380 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`")))),
381 }
382 } else {
383 let content = resp.text().await?;
384 let entity: Option<ScimListUsersError> = serde_json::from_str(&content).ok();
385 Err(Error::ResponseError(ResponseContent { status, content, entity }))
386 }
387}
388