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>>, 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_credentials_identifier = credentials_identifier;
780 let p_query_preview_credentials_identifier_similar = preview_credentials_identifier_similar;
781 let p_query_include_credential = include_credential;
782 let p_query_organization_id = organization_id;
783
784 let uri_str = format!("{}/admin/identities", configuration.base_path);
785 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
786
787 if let Some(ref param_value) = p_query_per_page {
788 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
789 }
790 if let Some(ref param_value) = p_query_page {
791 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
792 }
793 if let Some(ref param_value) = p_query_page_size {
794 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
795 }
796 if let Some(ref param_value) = p_query_page_token {
797 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
798 }
799 if let Some(ref param_value) = p_query_consistency {
800 req_builder = req_builder.query(&[("consistency", ¶m_value.to_string())]);
801 }
802 if let Some(ref param_value) = p_query_ids {
803 req_builder = match "multi" {
804 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
805 _ => req_builder.query(&[("ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
806 };
807 }
808 if let Some(ref param_value) = p_query_credentials_identifier {
809 req_builder = req_builder.query(&[("credentials_identifier", ¶m_value.to_string())]);
810 }
811 if let Some(ref param_value) = p_query_preview_credentials_identifier_similar {
812 req_builder = req_builder.query(&[("preview_credentials_identifier_similar", ¶m_value.to_string())]);
813 }
814 if let Some(ref param_value) = p_query_include_credential {
815 req_builder = match "multi" {
816 "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)>>()),
817 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
818 };
819 }
820 if let Some(ref param_value) = p_query_organization_id {
821 req_builder = req_builder.query(&[("organization_id", ¶m_value.to_string())]);
822 }
823 if let Some(ref user_agent) = configuration.user_agent {
824 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
825 }
826 if let Some(ref token) = configuration.bearer_access_token {
827 req_builder = req_builder.bearer_auth(token.to_owned());
828 };
829
830 let req = req_builder.build()?;
831 let resp = configuration.client.execute(req).await?;
832
833 let status = resp.status();
834 let content_type = resp
835 .headers()
836 .get("content-type")
837 .and_then(|v| v.to_str().ok())
838 .unwrap_or("application/octet-stream");
839 let content_type = super::ContentType::from(content_type);
840
841 if !status.is_client_error() && !status.is_server_error() {
842 let content = resp.text().await?;
843 match content_type {
844 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
845 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Identity>`"))),
846 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>`")))),
847 }
848 } else {
849 let content = resp.text().await?;
850 let entity: Option<ListIdentitiesError> = serde_json::from_str(&content).ok();
851 Err(Error::ResponseError(ResponseContent { status, content, entity }))
852 }
853}
854
855pub 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>> {
857 let p_query_per_page = per_page;
859 let p_query_page = page;
860 let p_query_page_size = page_size;
861 let p_query_page_token = page_token;
862
863 let uri_str = format!("{}/schemas", configuration.base_path);
864 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
865
866 if let Some(ref param_value) = p_query_per_page {
867 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
868 }
869 if let Some(ref param_value) = p_query_page {
870 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
871 }
872 if let Some(ref param_value) = p_query_page_size {
873 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
874 }
875 if let Some(ref param_value) = p_query_page_token {
876 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
877 }
878 if let Some(ref user_agent) = configuration.user_agent {
879 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
880 }
881
882 let req = req_builder.build()?;
883 let resp = configuration.client.execute(req).await?;
884
885 let status = resp.status();
886 let content_type = resp
887 .headers()
888 .get("content-type")
889 .and_then(|v| v.to_str().ok())
890 .unwrap_or("application/octet-stream");
891 let content_type = super::ContentType::from(content_type);
892
893 if !status.is_client_error() && !status.is_server_error() {
894 let content = resp.text().await?;
895 match content_type {
896 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
897 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::IdentitySchemaContainer>`"))),
898 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>`")))),
899 }
900 } else {
901 let content = resp.text().await?;
902 let entity: Option<ListIdentitySchemasError> = serde_json::from_str(&content).ok();
903 Err(Error::ResponseError(ResponseContent { status, content, entity }))
904 }
905}
906
907pub 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>> {
909 let p_path_id = id;
911 let p_query_per_page = per_page;
912 let p_query_page = page;
913 let p_query_page_size = page_size;
914 let p_query_page_token = page_token;
915 let p_query_active = active;
916
917 let uri_str = format!("{}/admin/identities/{id}/sessions", configuration.base_path, id=crate::apis::urlencode(p_path_id));
918 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
919
920 if let Some(ref param_value) = p_query_per_page {
921 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
922 }
923 if let Some(ref param_value) = p_query_page {
924 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
925 }
926 if let Some(ref param_value) = p_query_page_size {
927 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
928 }
929 if let Some(ref param_value) = p_query_page_token {
930 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
931 }
932 if let Some(ref param_value) = p_query_active {
933 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
934 }
935 if let Some(ref user_agent) = configuration.user_agent {
936 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
937 }
938 if let Some(ref token) = configuration.bearer_access_token {
939 req_builder = req_builder.bearer_auth(token.to_owned());
940 };
941
942 let req = req_builder.build()?;
943 let resp = configuration.client.execute(req).await?;
944
945 let status = resp.status();
946 let content_type = resp
947 .headers()
948 .get("content-type")
949 .and_then(|v| v.to_str().ok())
950 .unwrap_or("application/octet-stream");
951 let content_type = super::ContentType::from(content_type);
952
953 if !status.is_client_error() && !status.is_server_error() {
954 let content = resp.text().await?;
955 match content_type {
956 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
957 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
958 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>`")))),
959 }
960 } else {
961 let content = resp.text().await?;
962 let entity: Option<ListIdentitySessionsError> = serde_json::from_str(&content).ok();
963 Err(Error::ResponseError(ResponseContent { status, content, entity }))
964 }
965}
966
967pub 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>> {
969 let p_query_page_size = page_size;
971 let p_query_page_token = page_token;
972 let p_query_active = active;
973 let p_query_expand = expand;
974
975 let uri_str = format!("{}/admin/sessions", configuration.base_path);
976 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
977
978 if let Some(ref param_value) = p_query_page_size {
979 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
980 }
981 if let Some(ref param_value) = p_query_page_token {
982 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
983 }
984 if let Some(ref param_value) = p_query_active {
985 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
986 }
987 if let Some(ref param_value) = p_query_expand {
988 req_builder = match "multi" {
989 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
990 _ => req_builder.query(&[("expand", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
991 };
992 }
993 if let Some(ref user_agent) = configuration.user_agent {
994 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
995 }
996 if let Some(ref token) = configuration.bearer_access_token {
997 req_builder = req_builder.bearer_auth(token.to_owned());
998 };
999
1000 let req = req_builder.build()?;
1001 let resp = configuration.client.execute(req).await?;
1002
1003 let status = resp.status();
1004 let content_type = resp
1005 .headers()
1006 .get("content-type")
1007 .and_then(|v| v.to_str().ok())
1008 .unwrap_or("application/octet-stream");
1009 let content_type = super::ContentType::from(content_type);
1010
1011 if !status.is_client_error() && !status.is_server_error() {
1012 let content = resp.text().await?;
1013 match content_type {
1014 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1015 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
1016 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>`")))),
1017 }
1018 } else {
1019 let content = resp.text().await?;
1020 let entity: Option<ListSessionsError> = serde_json::from_str(&content).ok();
1021 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1022 }
1023}
1024
1025pub async fn manage_sessions(configuration: &configuration::Configuration, manage_sessions_body: models::ManageSessionsBody) -> Result<models::ManageSessionsResponse, Error<ManageSessionsError>> {
1027 let p_body_manage_sessions_body = manage_sessions_body;
1029
1030 let uri_str = format!("{}/admin/sessions", configuration.base_path);
1031 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1032
1033 if let Some(ref user_agent) = configuration.user_agent {
1034 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1035 }
1036 if let Some(ref token) = configuration.bearer_access_token {
1037 req_builder = req_builder.bearer_auth(token.to_owned());
1038 };
1039 req_builder = req_builder.json(&p_body_manage_sessions_body);
1040
1041 let req = req_builder.build()?;
1042 let resp = configuration.client.execute(req).await?;
1043
1044 let status = resp.status();
1045 let content_type = resp
1046 .headers()
1047 .get("content-type")
1048 .and_then(|v| v.to_str().ok())
1049 .unwrap_or("application/octet-stream");
1050 let content_type = super::ContentType::from(content_type);
1051
1052 if !status.is_client_error() && !status.is_server_error() {
1053 let content = resp.text().await?;
1054 match content_type {
1055 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1056 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ManageSessionsResponse`"))),
1057 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`")))),
1058 }
1059 } else {
1060 let content = resp.text().await?;
1061 let entity: Option<ManageSessionsError> = serde_json::from_str(&content).ok();
1062 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1063 }
1064}
1065
1066pub async fn patch_identity(configuration: &configuration::Configuration, id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::Identity, Error<PatchIdentityError>> {
1068 let p_path_id = id;
1070 let p_body_json_patch = json_patch;
1071
1072 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1073 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1074
1075 if let Some(ref user_agent) = configuration.user_agent {
1076 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1077 }
1078 if let Some(ref token) = configuration.bearer_access_token {
1079 req_builder = req_builder.bearer_auth(token.to_owned());
1080 };
1081 req_builder = req_builder.json(&p_body_json_patch);
1082
1083 let req = req_builder.build()?;
1084 let resp = configuration.client.execute(req).await?;
1085
1086 let status = resp.status();
1087 let content_type = resp
1088 .headers()
1089 .get("content-type")
1090 .and_then(|v| v.to_str().ok())
1091 .unwrap_or("application/octet-stream");
1092 let content_type = super::ContentType::from(content_type);
1093
1094 if !status.is_client_error() && !status.is_server_error() {
1095 let content = resp.text().await?;
1096 match content_type {
1097 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1098 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
1099 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`")))),
1100 }
1101 } else {
1102 let content = resp.text().await?;
1103 let entity: Option<PatchIdentityError> = serde_json::from_str(&content).ok();
1104 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1105 }
1106}
1107
1108pub async fn update_identity(configuration: &configuration::Configuration, id: &str, update_identity_body: Option<models::UpdateIdentityBody>) -> Result<models::Identity, Error<UpdateIdentityError>> {
1110 let p_path_id = id;
1112 let p_body_update_identity_body = update_identity_body;
1113
1114 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1115 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1116
1117 if let Some(ref user_agent) = configuration.user_agent {
1118 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1119 }
1120 if let Some(ref token) = configuration.bearer_access_token {
1121 req_builder = req_builder.bearer_auth(token.to_owned());
1122 };
1123 req_builder = req_builder.json(&p_body_update_identity_body);
1124
1125 let req = req_builder.build()?;
1126 let resp = configuration.client.execute(req).await?;
1127
1128 let status = resp.status();
1129 let content_type = resp
1130 .headers()
1131 .get("content-type")
1132 .and_then(|v| v.to_str().ok())
1133 .unwrap_or("application/octet-stream");
1134 let content_type = super::ContentType::from(content_type);
1135
1136 if !status.is_client_error() && !status.is_server_error() {
1137 let content = resp.text().await?;
1138 match content_type {
1139 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1140 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
1141 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`")))),
1142 }
1143 } else {
1144 let content = resp.text().await?;
1145 let entity: Option<UpdateIdentityError> = serde_json::from_str(&content).ok();
1146 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1147 }
1148}
1149