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 BatchPatchIdentitiesError {
22 Status400(models::ErrorGeneric),
23 Status409(models::ErrorGeneric),
24 DefaultResponse(models::ErrorGeneric),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateIdentityError {
32 Status400(models::ErrorGeneric),
33 Status409(models::ErrorGeneric),
34 DefaultResponse(models::ErrorGeneric),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum CreateRecoveryCodeForIdentityError {
42 Status400(models::ErrorGeneric),
43 Status404(models::ErrorGeneric),
44 DefaultResponse(models::ErrorGeneric),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum CreateRecoveryLinkForIdentityError {
52 Status400(models::ErrorGeneric),
53 Status404(models::ErrorGeneric),
54 DefaultResponse(models::ErrorGeneric),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum CreateTestLoginFlowError {
62 Status400(models::ErrorGeneric),
63 Status404(models::ErrorGeneric),
64 DefaultResponse(models::ErrorGeneric),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum DeleteIdentityError {
72 Status404(models::ErrorGeneric),
73 DefaultResponse(models::ErrorGeneric),
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum DeleteIdentityCredentialsError {
81 Status400(models::ErrorGeneric),
82 Status404(models::ErrorGeneric),
83 DefaultResponse(models::ErrorGeneric),
84 UnknownValue(serde_json::Value),
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum DeleteIdentitySessionsError {
91 Status400(models::ErrorGeneric),
92 Status401(models::ErrorGeneric),
93 Status404(models::ErrorGeneric),
94 DefaultResponse(models::ErrorGeneric),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum DisableSessionError {
102 Status400(models::ErrorGeneric),
103 Status401(models::ErrorGeneric),
104 DefaultResponse(models::ErrorGeneric),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum ExtendSessionError {
112 Status400(models::ErrorGeneric),
113 Status404(models::ErrorGeneric),
114 DefaultResponse(models::ErrorGeneric),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetIdentityError {
122 Status404(models::ErrorGeneric),
123 DefaultResponse(models::ErrorGeneric),
124 UnknownValue(serde_json::Value),
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum GetIdentityByExternalIdError {
131 Status404(models::ErrorGeneric),
132 DefaultResponse(models::ErrorGeneric),
133 UnknownValue(serde_json::Value),
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum GetIdentitySchemaError {
140 Status404(models::ErrorGeneric),
141 DefaultResponse(models::ErrorGeneric),
142 UnknownValue(serde_json::Value),
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum GetSessionError {
149 Status400(models::ErrorGeneric),
150 DefaultResponse(models::ErrorGeneric),
151 UnknownValue(serde_json::Value),
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum ListIdentitiesError {
158 DefaultResponse(models::ErrorGeneric),
159 UnknownValue(serde_json::Value),
160}
161
162#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum ListIdentitySchemasError {
166 DefaultResponse(models::ErrorGeneric),
167 UnknownValue(serde_json::Value),
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum ListIdentitySessionsError {
174 Status400(models::ErrorGeneric),
175 Status404(models::ErrorGeneric),
176 DefaultResponse(models::ErrorGeneric),
177 UnknownValue(serde_json::Value),
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum ListSessionsError {
184 Status400(models::ErrorGeneric),
185 DefaultResponse(models::ErrorGeneric),
186 UnknownValue(serde_json::Value),
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum ManageSessionsError {
193 Status400(models::ErrorGeneric),
194 Status401(models::ErrorGeneric),
195 DefaultResponse(models::ErrorGeneric),
196 UnknownValue(serde_json::Value),
197}
198
199#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum PatchIdentityError {
203 Status400(models::ErrorGeneric),
204 Status404(models::ErrorGeneric),
205 Status409(models::ErrorGeneric),
206 DefaultResponse(models::ErrorGeneric),
207 UnknownValue(serde_json::Value),
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212#[serde(untagged)]
213pub enum UpdateIdentityError {
214 Status400(models::ErrorGeneric),
215 Status404(models::ErrorGeneric),
216 Status409(models::ErrorGeneric),
217 DefaultResponse(models::ErrorGeneric),
218 UnknownValue(serde_json::Value),
219}
220
221
222pub async fn batch_patch_identities(configuration: &configuration::Configuration, patch_identities_body: Option<models::PatchIdentitiesBody>) -> Result<models::BatchPatchIdentitiesResponse, Error<BatchPatchIdentitiesError>> {
224 let p_body_patch_identities_body = patch_identities_body;
226
227 let uri_str = format!("{}/admin/identities", configuration.base_path);
228 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
229
230 if let Some(ref user_agent) = configuration.user_agent {
231 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
232 }
233 if let Some(ref token) = configuration.bearer_access_token {
234 req_builder = req_builder.bearer_auth(token.to_owned());
235 };
236 req_builder = req_builder.json(&p_body_patch_identities_body);
237
238 let req = req_builder.build()?;
239 let resp = configuration.client.execute(req).await?;
240
241 let status = resp.status();
242 let content_type = resp
243 .headers()
244 .get("content-type")
245 .and_then(|v| v.to_str().ok())
246 .unwrap_or("application/octet-stream");
247 let content_type = super::ContentType::from(content_type);
248
249 if !status.is_client_error() && !status.is_server_error() {
250 let content = resp.text().await?;
251 match content_type {
252 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
253 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchPatchIdentitiesResponse`"))),
254 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::BatchPatchIdentitiesResponse`")))),
255 }
256 } else {
257 let content = resp.text().await?;
258 let entity: Option<BatchPatchIdentitiesError> = serde_json::from_str(&content).ok();
259 Err(Error::ResponseError(ResponseContent { status, content, entity }))
260 }
261}
262
263pub async fn create_identity(configuration: &configuration::Configuration, create_identity_body: Option<models::CreateIdentityBody>) -> Result<models::Identity, Error<CreateIdentityError>> {
265 let p_body_create_identity_body = create_identity_body;
267
268 let uri_str = format!("{}/admin/identities", configuration.base_path);
269 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
270
271 if let Some(ref user_agent) = configuration.user_agent {
272 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
273 }
274 if let Some(ref token) = configuration.bearer_access_token {
275 req_builder = req_builder.bearer_auth(token.to_owned());
276 };
277 req_builder = req_builder.json(&p_body_create_identity_body);
278
279 let req = req_builder.build()?;
280 let resp = configuration.client.execute(req).await?;
281
282 let status = resp.status();
283 let content_type = resp
284 .headers()
285 .get("content-type")
286 .and_then(|v| v.to_str().ok())
287 .unwrap_or("application/octet-stream");
288 let content_type = super::ContentType::from(content_type);
289
290 if !status.is_client_error() && !status.is_server_error() {
291 let content = resp.text().await?;
292 match content_type {
293 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
294 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
295 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::Identity`")))),
296 }
297 } else {
298 let content = resp.text().await?;
299 let entity: Option<CreateIdentityError> = serde_json::from_str(&content).ok();
300 Err(Error::ResponseError(ResponseContent { status, content, entity }))
301 }
302}
303
304pub async fn create_recovery_code_for_identity(configuration: &configuration::Configuration, create_recovery_code_for_identity_body: Option<models::CreateRecoveryCodeForIdentityBody>) -> Result<models::RecoveryCodeForIdentity, Error<CreateRecoveryCodeForIdentityError>> {
306 let p_body_create_recovery_code_for_identity_body = create_recovery_code_for_identity_body;
308
309 let uri_str = format!("{}/admin/recovery/code", configuration.base_path);
310 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
311
312 if let Some(ref user_agent) = configuration.user_agent {
313 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
314 }
315 if let Some(ref token) = configuration.bearer_access_token {
316 req_builder = req_builder.bearer_auth(token.to_owned());
317 };
318 req_builder = req_builder.json(&p_body_create_recovery_code_for_identity_body);
319
320 let req = req_builder.build()?;
321 let resp = configuration.client.execute(req).await?;
322
323 let status = resp.status();
324 let content_type = resp
325 .headers()
326 .get("content-type")
327 .and_then(|v| v.to_str().ok())
328 .unwrap_or("application/octet-stream");
329 let content_type = super::ContentType::from(content_type);
330
331 if !status.is_client_error() && !status.is_server_error() {
332 let content = resp.text().await?;
333 match content_type {
334 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
335 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryCodeForIdentity`"))),
336 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::RecoveryCodeForIdentity`")))),
337 }
338 } else {
339 let content = resp.text().await?;
340 let entity: Option<CreateRecoveryCodeForIdentityError> = serde_json::from_str(&content).ok();
341 Err(Error::ResponseError(ResponseContent { status, content, entity }))
342 }
343}
344
345pub async fn create_recovery_link_for_identity(configuration: &configuration::Configuration, return_to: Option<&str>, create_recovery_link_for_identity_body: Option<models::CreateRecoveryLinkForIdentityBody>) -> Result<models::RecoveryLinkForIdentity, Error<CreateRecoveryLinkForIdentityError>> {
347 let p_query_return_to = return_to;
349 let p_body_create_recovery_link_for_identity_body = create_recovery_link_for_identity_body;
350
351 let uri_str = format!("{}/admin/recovery/link", configuration.base_path);
352 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
353
354 if let Some(ref param_value) = p_query_return_to {
355 req_builder = req_builder.query(&[("return_to", ¶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 token) = configuration.bearer_access_token {
361 req_builder = req_builder.bearer_auth(token.to_owned());
362 };
363 req_builder = req_builder.json(&p_body_create_recovery_link_for_identity_body);
364
365 let req = req_builder.build()?;
366 let resp = configuration.client.execute(req).await?;
367
368 let status = resp.status();
369 let content_type = resp
370 .headers()
371 .get("content-type")
372 .and_then(|v| v.to_str().ok())
373 .unwrap_or("application/octet-stream");
374 let content_type = super::ContentType::from(content_type);
375
376 if !status.is_client_error() && !status.is_server_error() {
377 let content = resp.text().await?;
378 match content_type {
379 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
380 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryLinkForIdentity`"))),
381 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::RecoveryLinkForIdentity`")))),
382 }
383 } else {
384 let content = resp.text().await?;
385 let entity: Option<CreateRecoveryLinkForIdentityError> = serde_json::from_str(&content).ok();
386 Err(Error::ResponseError(ResponseContent { status, content, entity }))
387 }
388}
389
390pub async fn create_test_login_flow(configuration: &configuration::Configuration, create_test_login_flow_body: models::CreateTestLoginFlowBody) -> Result<models::LoginFlow, Error<CreateTestLoginFlowError>> {
392 let p_body_create_test_login_flow_body = create_test_login_flow_body;
394
395 let uri_str = format!("{}/admin/test-login-flows", configuration.base_path);
396 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
397
398 if let Some(ref user_agent) = configuration.user_agent {
399 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
400 }
401 if let Some(ref token) = configuration.bearer_access_token {
402 req_builder = req_builder.bearer_auth(token.to_owned());
403 };
404 req_builder = req_builder.json(&p_body_create_test_login_flow_body);
405
406 let req = req_builder.build()?;
407 let resp = configuration.client.execute(req).await?;
408
409 let status = resp.status();
410 let content_type = resp
411 .headers()
412 .get("content-type")
413 .and_then(|v| v.to_str().ok())
414 .unwrap_or("application/octet-stream");
415 let content_type = super::ContentType::from(content_type);
416
417 if !status.is_client_error() && !status.is_server_error() {
418 let content = resp.text().await?;
419 match content_type {
420 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
421 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
422 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::LoginFlow`")))),
423 }
424 } else {
425 let content = resp.text().await?;
426 let entity: Option<CreateTestLoginFlowError> = serde_json::from_str(&content).ok();
427 Err(Error::ResponseError(ResponseContent { status, content, entity }))
428 }
429}
430
431pub async fn delete_identity(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentityError>> {
433 let p_path_id = id;
435
436 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
437 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
438
439 if let Some(ref user_agent) = configuration.user_agent {
440 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
441 }
442 if let Some(ref token) = configuration.bearer_access_token {
443 req_builder = req_builder.bearer_auth(token.to_owned());
444 };
445
446 let req = req_builder.build()?;
447 let resp = configuration.client.execute(req).await?;
448
449 let status = resp.status();
450
451 if !status.is_client_error() && !status.is_server_error() {
452 Ok(())
453 } else {
454 let content = resp.text().await?;
455 let entity: Option<DeleteIdentityError> = serde_json::from_str(&content).ok();
456 Err(Error::ResponseError(ResponseContent { status, content, entity }))
457 }
458}
459
460pub async fn delete_identity_credentials(configuration: &configuration::Configuration, id: &str, r#type: &str, identifier: Option<&str>) -> Result<(), Error<DeleteIdentityCredentialsError>> {
462 let p_path_id = id;
464 let p_path_type = r#type;
465 let p_query_identifier = identifier;
466
467 let uri_str = format!("{}/admin/identities/{id}/credentials/{type}", configuration.base_path, id=crate::apis::urlencode(p_path_id), type=crate::apis::urlencode(p_path_type));
468 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
469
470 if let Some(ref param_value) = p_query_identifier {
471 req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]);
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 token) = configuration.bearer_access_token {
477 req_builder = req_builder.bearer_auth(token.to_owned());
478 };
479
480 let req = req_builder.build()?;
481 let resp = configuration.client.execute(req).await?;
482
483 let status = resp.status();
484
485 if !status.is_client_error() && !status.is_server_error() {
486 Ok(())
487 } else {
488 let content = resp.text().await?;
489 let entity: Option<DeleteIdentityCredentialsError> = serde_json::from_str(&content).ok();
490 Err(Error::ResponseError(ResponseContent { status, content, entity }))
491 }
492}
493
494pub async fn delete_identity_sessions(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentitySessionsError>> {
496 let p_path_id = id;
498
499 let uri_str = format!("{}/admin/identities/{id}/sessions", configuration.base_path, id=crate::apis::urlencode(p_path_id));
500 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
501
502 if let Some(ref user_agent) = configuration.user_agent {
503 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
504 }
505 if let Some(ref token) = configuration.bearer_access_token {
506 req_builder = req_builder.bearer_auth(token.to_owned());
507 };
508
509 let req = req_builder.build()?;
510 let resp = configuration.client.execute(req).await?;
511
512 let status = resp.status();
513
514 if !status.is_client_error() && !status.is_server_error() {
515 Ok(())
516 } else {
517 let content = resp.text().await?;
518 let entity: Option<DeleteIdentitySessionsError> = serde_json::from_str(&content).ok();
519 Err(Error::ResponseError(ResponseContent { status, content, entity }))
520 }
521}
522
523pub async fn disable_session(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DisableSessionError>> {
525 let p_path_id = id;
527
528 let uri_str = format!("{}/admin/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
529 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
530
531 if let Some(ref user_agent) = configuration.user_agent {
532 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
533 }
534 if let Some(ref token) = configuration.bearer_access_token {
535 req_builder = req_builder.bearer_auth(token.to_owned());
536 };
537
538 let req = req_builder.build()?;
539 let resp = configuration.client.execute(req).await?;
540
541 let status = resp.status();
542
543 if !status.is_client_error() && !status.is_server_error() {
544 Ok(())
545 } else {
546 let content = resp.text().await?;
547 let entity: Option<DisableSessionError> = serde_json::from_str(&content).ok();
548 Err(Error::ResponseError(ResponseContent { status, content, entity }))
549 }
550}
551
552pub async fn extend_session(configuration: &configuration::Configuration, id: &str) -> Result<models::Session, Error<ExtendSessionError>> {
554 let p_path_id = id;
556
557 let uri_str = format!("{}/admin/sessions/{id}/extend", configuration.base_path, id=crate::apis::urlencode(p_path_id));
558 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
559
560 if let Some(ref user_agent) = configuration.user_agent {
561 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
562 }
563 if let Some(ref token) = configuration.bearer_access_token {
564 req_builder = req_builder.bearer_auth(token.to_owned());
565 };
566
567 let req = req_builder.build()?;
568 let resp = configuration.client.execute(req).await?;
569
570 let status = resp.status();
571 let content_type = resp
572 .headers()
573 .get("content-type")
574 .and_then(|v| v.to_str().ok())
575 .unwrap_or("application/octet-stream");
576 let content_type = super::ContentType::from(content_type);
577
578 if !status.is_client_error() && !status.is_server_error() {
579 let content = resp.text().await?;
580 match content_type {
581 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
582 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
583 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::Session`")))),
584 }
585 } else {
586 let content = resp.text().await?;
587 let entity: Option<ExtendSessionError> = serde_json::from_str(&content).ok();
588 Err(Error::ResponseError(ResponseContent { status, content, entity }))
589 }
590}
591
592pub async fn get_identity(configuration: &configuration::Configuration, id: &str, include_credential: Option<Vec<String>>) -> Result<models::Identity, Error<GetIdentityError>> {
594 let p_path_id = id;
596 let p_query_include_credential = include_credential;
597
598 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
599 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
600
601 if let Some(ref param_value) = p_query_include_credential {
602 req_builder = match "multi" {
603 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("include_credential".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
604 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
605 };
606 }
607 if let Some(ref user_agent) = configuration.user_agent {
608 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
609 }
610 if let Some(ref token) = configuration.bearer_access_token {
611 req_builder = req_builder.bearer_auth(token.to_owned());
612 };
613
614 let req = req_builder.build()?;
615 let resp = configuration.client.execute(req).await?;
616
617 let status = resp.status();
618 let content_type = resp
619 .headers()
620 .get("content-type")
621 .and_then(|v| v.to_str().ok())
622 .unwrap_or("application/octet-stream");
623 let content_type = super::ContentType::from(content_type);
624
625 if !status.is_client_error() && !status.is_server_error() {
626 let content = resp.text().await?;
627 match content_type {
628 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
629 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
630 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::Identity`")))),
631 }
632 } else {
633 let content = resp.text().await?;
634 let entity: Option<GetIdentityError> = serde_json::from_str(&content).ok();
635 Err(Error::ResponseError(ResponseContent { status, content, entity }))
636 }
637}
638
639pub async fn get_identity_by_external_id(configuration: &configuration::Configuration, external_id: &str, include_credential: Option<Vec<String>>) -> Result<models::Identity, Error<GetIdentityByExternalIdError>> {
641 let p_path_external_id = external_id;
643 let p_query_include_credential = include_credential;
644
645 let uri_str = format!("{}/admin/identities/by/external/{externalID}", configuration.base_path, externalID=crate::apis::urlencode(p_path_external_id));
646 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
647
648 if let Some(ref param_value) = p_query_include_credential {
649 req_builder = match "multi" {
650 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("include_credential".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
651 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
652 };
653 }
654 if let Some(ref user_agent) = configuration.user_agent {
655 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
656 }
657 if let Some(ref token) = configuration.bearer_access_token {
658 req_builder = req_builder.bearer_auth(token.to_owned());
659 };
660
661 let req = req_builder.build()?;
662 let resp = configuration.client.execute(req).await?;
663
664 let status = resp.status();
665 let content_type = resp
666 .headers()
667 .get("content-type")
668 .and_then(|v| v.to_str().ok())
669 .unwrap_or("application/octet-stream");
670 let content_type = super::ContentType::from(content_type);
671
672 if !status.is_client_error() && !status.is_server_error() {
673 let content = resp.text().await?;
674 match content_type {
675 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
676 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
677 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::Identity`")))),
678 }
679 } else {
680 let content = resp.text().await?;
681 let entity: Option<GetIdentityByExternalIdError> = serde_json::from_str(&content).ok();
682 Err(Error::ResponseError(ResponseContent { status, content, entity }))
683 }
684}
685
686pub async fn get_identity_schema(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<GetIdentitySchemaError>> {
688 let p_path_id = id;
690
691 let uri_str = format!("{}/schemas/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
692 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
693
694 if let Some(ref user_agent) = configuration.user_agent {
695 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
696 }
697
698 let req = req_builder.build()?;
699 let resp = configuration.client.execute(req).await?;
700
701 let status = resp.status();
702 let content_type = resp
703 .headers()
704 .get("content-type")
705 .and_then(|v| v.to_str().ok())
706 .unwrap_or("application/octet-stream");
707 let content_type = super::ContentType::from(content_type);
708
709 if !status.is_client_error() && !status.is_server_error() {
710 let content = resp.text().await?;
711 match content_type {
712 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
713 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
714 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`")))),
715 }
716 } else {
717 let content = resp.text().await?;
718 let entity: Option<GetIdentitySchemaError> = serde_json::from_str(&content).ok();
719 Err(Error::ResponseError(ResponseContent { status, content, entity }))
720 }
721}
722
723pub async fn get_session(configuration: &configuration::Configuration, id: &str, expand: Option<Vec<String>>) -> Result<models::Session, Error<GetSessionError>> {
725 let p_path_id = id;
727 let p_query_expand = expand;
728
729 let uri_str = format!("{}/admin/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
730 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
731
732 if let Some(ref param_value) = p_query_expand {
733 req_builder = match "multi" {
734 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
735 _ => req_builder.query(&[("expand", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
736 };
737 }
738 if let Some(ref user_agent) = configuration.user_agent {
739 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
740 }
741 if let Some(ref token) = configuration.bearer_access_token {
742 req_builder = req_builder.bearer_auth(token.to_owned());
743 };
744
745 let req = req_builder.build()?;
746 let resp = configuration.client.execute(req).await?;
747
748 let status = resp.status();
749 let content_type = resp
750 .headers()
751 .get("content-type")
752 .and_then(|v| v.to_str().ok())
753 .unwrap_or("application/octet-stream");
754 let content_type = super::ContentType::from(content_type);
755
756 if !status.is_client_error() && !status.is_server_error() {
757 let content = resp.text().await?;
758 match content_type {
759 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
760 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
761 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::Session`")))),
762 }
763 } else {
764 let content = resp.text().await?;
765 let entity: Option<GetSessionError> = serde_json::from_str(&content).ok();
766 Err(Error::ResponseError(ResponseContent { status, content, entity }))
767 }
768}
769
770pub async fn list_identities(configuration: &configuration::Configuration, per_page: Option<i64>, page: Option<i64>, page_size: Option<i64>, page_token: Option<&str>, consistency: Option<&str>, ids: Option<Vec<String>>, external_ids: Option<Vec<String>>, credentials_identifier: Option<&str>, preview_credentials_identifier_similar: Option<&str>, include_credential: Option<Vec<String>>, organization_id: Option<&str>) -> Result<Vec<models::Identity>, Error<ListIdentitiesError>> {
772 let p_query_per_page = per_page;
774 let p_query_page = page;
775 let p_query_page_size = page_size;
776 let p_query_page_token = page_token;
777 let p_query_consistency = consistency;
778 let p_query_ids = ids;
779 let p_query_external_ids = external_ids;
780 let p_query_credentials_identifier = credentials_identifier;
781 let p_query_preview_credentials_identifier_similar = preview_credentials_identifier_similar;
782 let p_query_include_credential = include_credential;
783 let p_query_organization_id = organization_id;
784
785 let uri_str = format!("{}/admin/identities", configuration.base_path);
786 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
787
788 if let Some(ref param_value) = p_query_per_page {
789 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
790 }
791 if let Some(ref param_value) = p_query_page {
792 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
793 }
794 if let Some(ref param_value) = p_query_page_size {
795 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
796 }
797 if let Some(ref param_value) = p_query_page_token {
798 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
799 }
800 if let Some(ref param_value) = p_query_consistency {
801 req_builder = req_builder.query(&[("consistency", ¶m_value.to_string())]);
802 }
803 if let Some(ref param_value) = p_query_ids {
804 req_builder = match "multi" {
805 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
806 _ => req_builder.query(&[("ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
807 };
808 }
809 if let Some(ref param_value) = p_query_external_ids {
810 req_builder = match "multi" {
811 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("external_ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
812 _ => req_builder.query(&[("external_ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
813 };
814 }
815 if let Some(ref param_value) = p_query_credentials_identifier {
816 req_builder = req_builder.query(&[("credentials_identifier", ¶m_value.to_string())]);
817 }
818 if let Some(ref param_value) = p_query_preview_credentials_identifier_similar {
819 req_builder = req_builder.query(&[("preview_credentials_identifier_similar", ¶m_value.to_string())]);
820 }
821 if let Some(ref param_value) = p_query_include_credential {
822 req_builder = match "multi" {
823 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("include_credential".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
824 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
825 };
826 }
827 if let Some(ref param_value) = p_query_organization_id {
828 req_builder = req_builder.query(&[("organization_id", ¶m_value.to_string())]);
829 }
830 if let Some(ref user_agent) = configuration.user_agent {
831 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
832 }
833 if let Some(ref token) = configuration.bearer_access_token {
834 req_builder = req_builder.bearer_auth(token.to_owned());
835 };
836
837 let req = req_builder.build()?;
838 let resp = configuration.client.execute(req).await?;
839
840 let status = resp.status();
841 let content_type = resp
842 .headers()
843 .get("content-type")
844 .and_then(|v| v.to_str().ok())
845 .unwrap_or("application/octet-stream");
846 let content_type = super::ContentType::from(content_type);
847
848 if !status.is_client_error() && !status.is_server_error() {
849 let content = resp.text().await?;
850 match content_type {
851 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
852 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Identity>`"))),
853 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Identity>`")))),
854 }
855 } else {
856 let content = resp.text().await?;
857 let entity: Option<ListIdentitiesError> = serde_json::from_str(&content).ok();
858 Err(Error::ResponseError(ResponseContent { status, content, entity }))
859 }
860}
861
862pub async fn list_identity_schemas(configuration: &configuration::Configuration, per_page: Option<i64>, page: Option<i64>, page_size: Option<i64>, page_token: Option<&str>) -> Result<Vec<models::IdentitySchemaContainer>, Error<ListIdentitySchemasError>> {
864 let p_query_per_page = per_page;
866 let p_query_page = page;
867 let p_query_page_size = page_size;
868 let p_query_page_token = page_token;
869
870 let uri_str = format!("{}/schemas", configuration.base_path);
871 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
872
873 if let Some(ref param_value) = p_query_per_page {
874 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
875 }
876 if let Some(ref param_value) = p_query_page {
877 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
878 }
879 if let Some(ref param_value) = p_query_page_size {
880 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
881 }
882 if let Some(ref param_value) = p_query_page_token {
883 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
884 }
885 if let Some(ref user_agent) = configuration.user_agent {
886 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
887 }
888
889 let req = req_builder.build()?;
890 let resp = configuration.client.execute(req).await?;
891
892 let status = resp.status();
893 let content_type = resp
894 .headers()
895 .get("content-type")
896 .and_then(|v| v.to_str().ok())
897 .unwrap_or("application/octet-stream");
898 let content_type = super::ContentType::from(content_type);
899
900 if !status.is_client_error() && !status.is_server_error() {
901 let content = resp.text().await?;
902 match content_type {
903 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
904 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::IdentitySchemaContainer>`"))),
905 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::IdentitySchemaContainer>`")))),
906 }
907 } else {
908 let content = resp.text().await?;
909 let entity: Option<ListIdentitySchemasError> = serde_json::from_str(&content).ok();
910 Err(Error::ResponseError(ResponseContent { status, content, entity }))
911 }
912}
913
914pub async fn list_identity_sessions(configuration: &configuration::Configuration, id: &str, per_page: Option<i64>, page: Option<i64>, page_size: Option<i64>, page_token: Option<&str>, active: Option<bool>) -> Result<Vec<models::Session>, Error<ListIdentitySessionsError>> {
916 let p_path_id = id;
918 let p_query_per_page = per_page;
919 let p_query_page = page;
920 let p_query_page_size = page_size;
921 let p_query_page_token = page_token;
922 let p_query_active = active;
923
924 let uri_str = format!("{}/admin/identities/{id}/sessions", configuration.base_path, id=crate::apis::urlencode(p_path_id));
925 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
926
927 if let Some(ref param_value) = p_query_per_page {
928 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
929 }
930 if let Some(ref param_value) = p_query_page {
931 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
932 }
933 if let Some(ref param_value) = p_query_page_size {
934 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
935 }
936 if let Some(ref param_value) = p_query_page_token {
937 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
938 }
939 if let Some(ref param_value) = p_query_active {
940 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
941 }
942 if let Some(ref user_agent) = configuration.user_agent {
943 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
944 }
945 if let Some(ref token) = configuration.bearer_access_token {
946 req_builder = req_builder.bearer_auth(token.to_owned());
947 };
948
949 let req = req_builder.build()?;
950 let resp = configuration.client.execute(req).await?;
951
952 let status = resp.status();
953 let content_type = resp
954 .headers()
955 .get("content-type")
956 .and_then(|v| v.to_str().ok())
957 .unwrap_or("application/octet-stream");
958 let content_type = super::ContentType::from(content_type);
959
960 if !status.is_client_error() && !status.is_server_error() {
961 let content = resp.text().await?;
962 match content_type {
963 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
964 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
965 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Session>`")))),
966 }
967 } else {
968 let content = resp.text().await?;
969 let entity: Option<ListIdentitySessionsError> = serde_json::from_str(&content).ok();
970 Err(Error::ResponseError(ResponseContent { status, content, entity }))
971 }
972}
973
974pub async fn list_sessions(configuration: &configuration::Configuration, page_size: Option<i64>, page_token: Option<&str>, active: Option<bool>, expand: Option<Vec<String>>) -> Result<Vec<models::Session>, Error<ListSessionsError>> {
976 let p_query_page_size = page_size;
978 let p_query_page_token = page_token;
979 let p_query_active = active;
980 let p_query_expand = expand;
981
982 let uri_str = format!("{}/admin/sessions", configuration.base_path);
983 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
984
985 if let Some(ref param_value) = p_query_page_size {
986 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
987 }
988 if let Some(ref param_value) = p_query_page_token {
989 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
990 }
991 if let Some(ref param_value) = p_query_active {
992 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
993 }
994 if let Some(ref param_value) = p_query_expand {
995 req_builder = match "multi" {
996 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
997 _ => req_builder.query(&[("expand", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
998 };
999 }
1000 if let Some(ref user_agent) = configuration.user_agent {
1001 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1002 }
1003 if let Some(ref token) = configuration.bearer_access_token {
1004 req_builder = req_builder.bearer_auth(token.to_owned());
1005 };
1006
1007 let req = req_builder.build()?;
1008 let resp = configuration.client.execute(req).await?;
1009
1010 let status = resp.status();
1011 let content_type = resp
1012 .headers()
1013 .get("content-type")
1014 .and_then(|v| v.to_str().ok())
1015 .unwrap_or("application/octet-stream");
1016 let content_type = super::ContentType::from(content_type);
1017
1018 if !status.is_client_error() && !status.is_server_error() {
1019 let content = resp.text().await?;
1020 match content_type {
1021 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1022 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
1023 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Session>`")))),
1024 }
1025 } else {
1026 let content = resp.text().await?;
1027 let entity: Option<ListSessionsError> = serde_json::from_str(&content).ok();
1028 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1029 }
1030}
1031
1032pub async fn manage_sessions(configuration: &configuration::Configuration, manage_sessions_body: models::ManageSessionsBody) -> Result<models::ManageSessionsResponse, Error<ManageSessionsError>> {
1034 let p_body_manage_sessions_body = manage_sessions_body;
1036
1037 let uri_str = format!("{}/admin/sessions", configuration.base_path);
1038 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1039
1040 if let Some(ref user_agent) = configuration.user_agent {
1041 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1042 }
1043 if let Some(ref token) = configuration.bearer_access_token {
1044 req_builder = req_builder.bearer_auth(token.to_owned());
1045 };
1046 req_builder = req_builder.json(&p_body_manage_sessions_body);
1047
1048 let req = req_builder.build()?;
1049 let resp = configuration.client.execute(req).await?;
1050
1051 let status = resp.status();
1052 let content_type = resp
1053 .headers()
1054 .get("content-type")
1055 .and_then(|v| v.to_str().ok())
1056 .unwrap_or("application/octet-stream");
1057 let content_type = super::ContentType::from(content_type);
1058
1059 if !status.is_client_error() && !status.is_server_error() {
1060 let content = resp.text().await?;
1061 match content_type {
1062 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1063 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ManageSessionsResponse`"))),
1064 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::ManageSessionsResponse`")))),
1065 }
1066 } else {
1067 let content = resp.text().await?;
1068 let entity: Option<ManageSessionsError> = serde_json::from_str(&content).ok();
1069 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1070 }
1071}
1072
1073pub async fn patch_identity(configuration: &configuration::Configuration, id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::Identity, Error<PatchIdentityError>> {
1075 let p_path_id = id;
1077 let p_body_json_patch = json_patch;
1078
1079 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1080 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1081
1082 if let Some(ref user_agent) = configuration.user_agent {
1083 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1084 }
1085 if let Some(ref token) = configuration.bearer_access_token {
1086 req_builder = req_builder.bearer_auth(token.to_owned());
1087 };
1088 req_builder = req_builder.json(&p_body_json_patch);
1089
1090 let req = req_builder.build()?;
1091 let resp = configuration.client.execute(req).await?;
1092
1093 let status = resp.status();
1094 let content_type = resp
1095 .headers()
1096 .get("content-type")
1097 .and_then(|v| v.to_str().ok())
1098 .unwrap_or("application/octet-stream");
1099 let content_type = super::ContentType::from(content_type);
1100
1101 if !status.is_client_error() && !status.is_server_error() {
1102 let content = resp.text().await?;
1103 match content_type {
1104 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1105 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
1106 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::Identity`")))),
1107 }
1108 } else {
1109 let content = resp.text().await?;
1110 let entity: Option<PatchIdentityError> = serde_json::from_str(&content).ok();
1111 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1112 }
1113}
1114
1115pub async fn update_identity(configuration: &configuration::Configuration, id: &str, update_identity_body: Option<models::UpdateIdentityBody>) -> Result<models::Identity, Error<UpdateIdentityError>> {
1117 let p_path_id = id;
1119 let p_body_update_identity_body = update_identity_body;
1120
1121 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1122 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1123
1124 if let Some(ref user_agent) = configuration.user_agent {
1125 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1126 }
1127 if let Some(ref token) = configuration.bearer_access_token {
1128 req_builder = req_builder.bearer_auth(token.to_owned());
1129 };
1130 req_builder = req_builder.json(&p_body_update_identity_body);
1131
1132 let req = req_builder.build()?;
1133 let resp = configuration.client.execute(req).await?;
1134
1135 let status = resp.status();
1136 let content_type = resp
1137 .headers()
1138 .get("content-type")
1139 .and_then(|v| v.to_str().ok())
1140 .unwrap_or("application/octet-stream");
1141 let content_type = super::ContentType::from(content_type);
1142
1143 if !status.is_client_error() && !status.is_server_error() {
1144 let content = resp.text().await?;
1145 match content_type {
1146 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1147 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
1148 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::Identity`")))),
1149 }
1150 } else {
1151 let content = resp.text().await?;
1152 let entity: Option<UpdateIdentityError> = serde_json::from_str(&content).ok();
1153 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1154 }
1155}
1156