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 DeleteIdentityError {
62 Status404(models::ErrorGeneric),
63 DefaultResponse(models::ErrorGeneric),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum DeleteIdentityCredentialsError {
71 Status404(models::ErrorGeneric),
72 DefaultResponse(models::ErrorGeneric),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum DeleteIdentitySessionsError {
80 Status400(models::ErrorGeneric),
81 Status401(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 DisableSessionError {
91 Status400(models::ErrorGeneric),
92 Status401(models::ErrorGeneric),
93 DefaultResponse(models::ErrorGeneric),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum ExtendSessionError {
101 Status400(models::ErrorGeneric),
102 Status404(models::ErrorGeneric),
103 DefaultResponse(models::ErrorGeneric),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum GetIdentityError {
111 Status404(models::ErrorGeneric),
112 DefaultResponse(models::ErrorGeneric),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetIdentityByExternalIdError {
120 Status404(models::ErrorGeneric),
121 DefaultResponse(models::ErrorGeneric),
122 UnknownValue(serde_json::Value),
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum GetIdentitySchemaError {
129 Status404(models::ErrorGeneric),
130 DefaultResponse(models::ErrorGeneric),
131 UnknownValue(serde_json::Value),
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum GetSessionError {
138 Status400(models::ErrorGeneric),
139 DefaultResponse(models::ErrorGeneric),
140 UnknownValue(serde_json::Value),
141}
142
143#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum ListIdentitiesError {
147 DefaultResponse(models::ErrorGeneric),
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum ListIdentitySchemasError {
155 DefaultResponse(models::ErrorGeneric),
156 UnknownValue(serde_json::Value),
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(untagged)]
162pub enum ListIdentitySessionsError {
163 Status400(models::ErrorGeneric),
164 Status404(models::ErrorGeneric),
165 DefaultResponse(models::ErrorGeneric),
166 UnknownValue(serde_json::Value),
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum ListSessionsError {
173 Status400(models::ErrorGeneric),
174 DefaultResponse(models::ErrorGeneric),
175 UnknownValue(serde_json::Value),
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum PatchIdentityError {
182 Status400(models::ErrorGeneric),
183 Status404(models::ErrorGeneric),
184 Status409(models::ErrorGeneric),
185 DefaultResponse(models::ErrorGeneric),
186 UnknownValue(serde_json::Value),
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum UpdateIdentityError {
193 Status400(models::ErrorGeneric),
194 Status404(models::ErrorGeneric),
195 Status409(models::ErrorGeneric),
196 DefaultResponse(models::ErrorGeneric),
197 UnknownValue(serde_json::Value),
198}
199
200
201pub async fn batch_patch_identities(configuration: &configuration::Configuration, patch_identities_body: Option<models::PatchIdentitiesBody>) -> Result<models::BatchPatchIdentitiesResponse, Error<BatchPatchIdentitiesError>> {
203 let p_patch_identities_body = patch_identities_body;
205
206 let uri_str = format!("{}/admin/identities", configuration.base_path);
207 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
208
209 if let Some(ref user_agent) = configuration.user_agent {
210 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
211 }
212 if let Some(ref token) = configuration.bearer_access_token {
213 req_builder = req_builder.bearer_auth(token.to_owned());
214 };
215 req_builder = req_builder.json(&p_patch_identities_body);
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchPatchIdentitiesResponse`"))),
233 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BatchPatchIdentitiesResponse`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<BatchPatchIdentitiesError> = serde_json::from_str(&content).ok();
238 Err(Error::ResponseError(ResponseContent { status, content, entity }))
239 }
240}
241
242pub async fn create_identity(configuration: &configuration::Configuration, create_identity_body: Option<models::CreateIdentityBody>) -> Result<models::Identity, Error<CreateIdentityError>> {
244 let p_create_identity_body = create_identity_body;
246
247 let uri_str = format!("{}/admin/identities", configuration.base_path);
248 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
249
250 if let Some(ref user_agent) = configuration.user_agent {
251 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252 }
253 if let Some(ref token) = configuration.bearer_access_token {
254 req_builder = req_builder.bearer_auth(token.to_owned());
255 };
256 req_builder = req_builder.json(&p_create_identity_body);
257
258 let req = req_builder.build()?;
259 let resp = configuration.client.execute(req).await?;
260
261 let status = resp.status();
262 let content_type = resp
263 .headers()
264 .get("content-type")
265 .and_then(|v| v.to_str().ok())
266 .unwrap_or("application/octet-stream");
267 let content_type = super::ContentType::from(content_type);
268
269 if !status.is_client_error() && !status.is_server_error() {
270 let content = resp.text().await?;
271 match content_type {
272 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
273 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
274 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`")))),
275 }
276 } else {
277 let content = resp.text().await?;
278 let entity: Option<CreateIdentityError> = serde_json::from_str(&content).ok();
279 Err(Error::ResponseError(ResponseContent { status, content, entity }))
280 }
281}
282
283pub async fn create_recovery_code_for_identity(configuration: &configuration::Configuration, create_recovery_code_for_identity_body: Option<models::CreateRecoveryCodeForIdentityBody>) -> Result<models::RecoveryCodeForIdentity, Error<CreateRecoveryCodeForIdentityError>> {
285 let p_create_recovery_code_for_identity_body = create_recovery_code_for_identity_body;
287
288 let uri_str = format!("{}/admin/recovery/code", configuration.base_path);
289 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
290
291 if let Some(ref user_agent) = configuration.user_agent {
292 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
293 }
294 if let Some(ref token) = configuration.bearer_access_token {
295 req_builder = req_builder.bearer_auth(token.to_owned());
296 };
297 req_builder = req_builder.json(&p_create_recovery_code_for_identity_body);
298
299 let req = req_builder.build()?;
300 let resp = configuration.client.execute(req).await?;
301
302 let status = resp.status();
303 let content_type = resp
304 .headers()
305 .get("content-type")
306 .and_then(|v| v.to_str().ok())
307 .unwrap_or("application/octet-stream");
308 let content_type = super::ContentType::from(content_type);
309
310 if !status.is_client_error() && !status.is_server_error() {
311 let content = resp.text().await?;
312 match content_type {
313 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryCodeForIdentity`"))),
315 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`")))),
316 }
317 } else {
318 let content = resp.text().await?;
319 let entity: Option<CreateRecoveryCodeForIdentityError> = serde_json::from_str(&content).ok();
320 Err(Error::ResponseError(ResponseContent { status, content, entity }))
321 }
322}
323
324pub 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>> {
326 let p_return_to = return_to;
328 let p_create_recovery_link_for_identity_body = create_recovery_link_for_identity_body;
329
330 let uri_str = format!("{}/admin/recovery/link", configuration.base_path);
331 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
332
333 if let Some(ref param_value) = p_return_to {
334 req_builder = req_builder.query(&[("return_to", ¶m_value.to_string())]);
335 }
336 if let Some(ref user_agent) = configuration.user_agent {
337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338 }
339 if let Some(ref token) = configuration.bearer_access_token {
340 req_builder = req_builder.bearer_auth(token.to_owned());
341 };
342 req_builder = req_builder.json(&p_create_recovery_link_for_identity_body);
343
344 let req = req_builder.build()?;
345 let resp = configuration.client.execute(req).await?;
346
347 let status = resp.status();
348 let content_type = resp
349 .headers()
350 .get("content-type")
351 .and_then(|v| v.to_str().ok())
352 .unwrap_or("application/octet-stream");
353 let content_type = super::ContentType::from(content_type);
354
355 if !status.is_client_error() && !status.is_server_error() {
356 let content = resp.text().await?;
357 match content_type {
358 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
359 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryLinkForIdentity`"))),
360 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`")))),
361 }
362 } else {
363 let content = resp.text().await?;
364 let entity: Option<CreateRecoveryLinkForIdentityError> = serde_json::from_str(&content).ok();
365 Err(Error::ResponseError(ResponseContent { status, content, entity }))
366 }
367}
368
369pub async fn delete_identity(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentityError>> {
371 let p_id = id;
373
374 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
375 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
376
377 if let Some(ref user_agent) = configuration.user_agent {
378 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
379 }
380 if let Some(ref token) = configuration.bearer_access_token {
381 req_builder = req_builder.bearer_auth(token.to_owned());
382 };
383
384 let req = req_builder.build()?;
385 let resp = configuration.client.execute(req).await?;
386
387 let status = resp.status();
388
389 if !status.is_client_error() && !status.is_server_error() {
390 Ok(())
391 } else {
392 let content = resp.text().await?;
393 let entity: Option<DeleteIdentityError> = serde_json::from_str(&content).ok();
394 Err(Error::ResponseError(ResponseContent { status, content, entity }))
395 }
396}
397
398pub async fn delete_identity_credentials(configuration: &configuration::Configuration, id: &str, r#type: &str, identifier: Option<&str>) -> Result<(), Error<DeleteIdentityCredentialsError>> {
400 let p_id = id;
402 let p_type = r#type;
403 let p_identifier = identifier;
404
405 let uri_str = format!("{}/admin/identities/{id}/credentials/{type}", configuration.base_path, id=crate::apis::urlencode(p_id), type=crate::apis::urlencode(p_type));
406 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
407
408 if let Some(ref param_value) = p_identifier {
409 req_builder = req_builder.query(&[("identifier", ¶m_value.to_string())]);
410 }
411 if let Some(ref user_agent) = configuration.user_agent {
412 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413 }
414 if let Some(ref token) = configuration.bearer_access_token {
415 req_builder = req_builder.bearer_auth(token.to_owned());
416 };
417
418 let req = req_builder.build()?;
419 let resp = configuration.client.execute(req).await?;
420
421 let status = resp.status();
422
423 if !status.is_client_error() && !status.is_server_error() {
424 Ok(())
425 } else {
426 let content = resp.text().await?;
427 let entity: Option<DeleteIdentityCredentialsError> = serde_json::from_str(&content).ok();
428 Err(Error::ResponseError(ResponseContent { status, content, entity }))
429 }
430}
431
432pub async fn delete_identity_sessions(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentitySessionsError>> {
434 let p_id = id;
436
437 let uri_str = format!("{}/admin/identities/{id}/sessions", configuration.base_path, id=crate::apis::urlencode(p_id));
438 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
439
440 if let Some(ref user_agent) = configuration.user_agent {
441 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
442 }
443 if let Some(ref token) = configuration.bearer_access_token {
444 req_builder = req_builder.bearer_auth(token.to_owned());
445 };
446
447 let req = req_builder.build()?;
448 let resp = configuration.client.execute(req).await?;
449
450 let status = resp.status();
451
452 if !status.is_client_error() && !status.is_server_error() {
453 Ok(())
454 } else {
455 let content = resp.text().await?;
456 let entity: Option<DeleteIdentitySessionsError> = serde_json::from_str(&content).ok();
457 Err(Error::ResponseError(ResponseContent { status, content, entity }))
458 }
459}
460
461pub async fn disable_session(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DisableSessionError>> {
463 let p_id = id;
465
466 let uri_str = format!("{}/admin/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
467 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
468
469 if let Some(ref user_agent) = configuration.user_agent {
470 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
471 }
472 if let Some(ref token) = configuration.bearer_access_token {
473 req_builder = req_builder.bearer_auth(token.to_owned());
474 };
475
476 let req = req_builder.build()?;
477 let resp = configuration.client.execute(req).await?;
478
479 let status = resp.status();
480
481 if !status.is_client_error() && !status.is_server_error() {
482 Ok(())
483 } else {
484 let content = resp.text().await?;
485 let entity: Option<DisableSessionError> = serde_json::from_str(&content).ok();
486 Err(Error::ResponseError(ResponseContent { status, content, entity }))
487 }
488}
489
490pub async fn extend_session(configuration: &configuration::Configuration, id: &str) -> Result<models::Session, Error<ExtendSessionError>> {
492 let p_id = id;
494
495 let uri_str = format!("{}/admin/sessions/{id}/extend", configuration.base_path, id=crate::apis::urlencode(p_id));
496 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
497
498 if let Some(ref user_agent) = configuration.user_agent {
499 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
500 }
501 if let Some(ref token) = configuration.bearer_access_token {
502 req_builder = req_builder.bearer_auth(token.to_owned());
503 };
504
505 let req = req_builder.build()?;
506 let resp = configuration.client.execute(req).await?;
507
508 let status = resp.status();
509 let content_type = resp
510 .headers()
511 .get("content-type")
512 .and_then(|v| v.to_str().ok())
513 .unwrap_or("application/octet-stream");
514 let content_type = super::ContentType::from(content_type);
515
516 if !status.is_client_error() && !status.is_server_error() {
517 let content = resp.text().await?;
518 match content_type {
519 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
520 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
521 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`")))),
522 }
523 } else {
524 let content = resp.text().await?;
525 let entity: Option<ExtendSessionError> = serde_json::from_str(&content).ok();
526 Err(Error::ResponseError(ResponseContent { status, content, entity }))
527 }
528}
529
530pub async fn get_identity(configuration: &configuration::Configuration, id: &str, include_credential: Option<Vec<String>>) -> Result<models::Identity, Error<GetIdentityError>> {
532 let p_id = id;
534 let p_include_credential = include_credential;
535
536 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
537 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
538
539 if let Some(ref param_value) = p_include_credential {
540 req_builder = match "multi" {
541 "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)>>()),
542 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
543 };
544 }
545 if let Some(ref user_agent) = configuration.user_agent {
546 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
547 }
548 if let Some(ref token) = configuration.bearer_access_token {
549 req_builder = req_builder.bearer_auth(token.to_owned());
550 };
551
552 let req = req_builder.build()?;
553 let resp = configuration.client.execute(req).await?;
554
555 let status = resp.status();
556 let content_type = resp
557 .headers()
558 .get("content-type")
559 .and_then(|v| v.to_str().ok())
560 .unwrap_or("application/octet-stream");
561 let content_type = super::ContentType::from(content_type);
562
563 if !status.is_client_error() && !status.is_server_error() {
564 let content = resp.text().await?;
565 match content_type {
566 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
567 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
568 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`")))),
569 }
570 } else {
571 let content = resp.text().await?;
572 let entity: Option<GetIdentityError> = serde_json::from_str(&content).ok();
573 Err(Error::ResponseError(ResponseContent { status, content, entity }))
574 }
575}
576
577pub async fn get_identity_by_external_id(configuration: &configuration::Configuration, external_id: &str, include_credential: Option<Vec<String>>) -> Result<models::Identity, Error<GetIdentityByExternalIdError>> {
579 let p_external_id = external_id;
581 let p_include_credential = include_credential;
582
583 let uri_str = format!("{}/admin/identities/by/external/{externalID}", configuration.base_path, externalID=crate::apis::urlencode(p_external_id));
584 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
585
586 if let Some(ref param_value) = p_include_credential {
587 req_builder = match "multi" {
588 "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)>>()),
589 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
590 };
591 }
592 if let Some(ref user_agent) = configuration.user_agent {
593 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
594 }
595 if let Some(ref token) = configuration.bearer_access_token {
596 req_builder = req_builder.bearer_auth(token.to_owned());
597 };
598
599 let req = req_builder.build()?;
600 let resp = configuration.client.execute(req).await?;
601
602 let status = resp.status();
603 let content_type = resp
604 .headers()
605 .get("content-type")
606 .and_then(|v| v.to_str().ok())
607 .unwrap_or("application/octet-stream");
608 let content_type = super::ContentType::from(content_type);
609
610 if !status.is_client_error() && !status.is_server_error() {
611 let content = resp.text().await?;
612 match content_type {
613 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
614 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
615 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`")))),
616 }
617 } else {
618 let content = resp.text().await?;
619 let entity: Option<GetIdentityByExternalIdError> = serde_json::from_str(&content).ok();
620 Err(Error::ResponseError(ResponseContent { status, content, entity }))
621 }
622}
623
624pub async fn get_identity_schema(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<GetIdentitySchemaError>> {
626 let p_id = id;
628
629 let uri_str = format!("{}/schemas/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
630 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
631
632 if let Some(ref user_agent) = configuration.user_agent {
633 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
634 }
635
636 let req = req_builder.build()?;
637 let resp = configuration.client.execute(req).await?;
638
639 let status = resp.status();
640 let content_type = resp
641 .headers()
642 .get("content-type")
643 .and_then(|v| v.to_str().ok())
644 .unwrap_or("application/octet-stream");
645 let content_type = super::ContentType::from(content_type);
646
647 if !status.is_client_error() && !status.is_server_error() {
648 let content = resp.text().await?;
649 match content_type {
650 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
651 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
652 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`")))),
653 }
654 } else {
655 let content = resp.text().await?;
656 let entity: Option<GetIdentitySchemaError> = serde_json::from_str(&content).ok();
657 Err(Error::ResponseError(ResponseContent { status, content, entity }))
658 }
659}
660
661pub async fn get_session(configuration: &configuration::Configuration, id: &str, expand: Option<Vec<String>>) -> Result<models::Session, Error<GetSessionError>> {
663 let p_id = id;
665 let p_expand = expand;
666
667 let uri_str = format!("{}/admin/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
668 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
669
670 if let Some(ref param_value) = p_expand {
671 req_builder = match "multi" {
672 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
673 _ => req_builder.query(&[("expand", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
674 };
675 }
676 if let Some(ref user_agent) = configuration.user_agent {
677 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
678 }
679 if let Some(ref token) = configuration.bearer_access_token {
680 req_builder = req_builder.bearer_auth(token.to_owned());
681 };
682
683 let req = req_builder.build()?;
684 let resp = configuration.client.execute(req).await?;
685
686 let status = resp.status();
687 let content_type = resp
688 .headers()
689 .get("content-type")
690 .and_then(|v| v.to_str().ok())
691 .unwrap_or("application/octet-stream");
692 let content_type = super::ContentType::from(content_type);
693
694 if !status.is_client_error() && !status.is_server_error() {
695 let content = resp.text().await?;
696 match content_type {
697 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
698 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
699 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`")))),
700 }
701 } else {
702 let content = resp.text().await?;
703 let entity: Option<GetSessionError> = serde_json::from_str(&content).ok();
704 Err(Error::ResponseError(ResponseContent { status, content, entity }))
705 }
706}
707
708pub 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>> {
710 let p_per_page = per_page;
712 let p_page = page;
713 let p_page_size = page_size;
714 let p_page_token = page_token;
715 let p_consistency = consistency;
716 let p_ids = ids;
717 let p_credentials_identifier = credentials_identifier;
718 let p_preview_credentials_identifier_similar = preview_credentials_identifier_similar;
719 let p_include_credential = include_credential;
720 let p_organization_id = organization_id;
721
722 let uri_str = format!("{}/admin/identities", configuration.base_path);
723 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
724
725 if let Some(ref param_value) = p_per_page {
726 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
727 }
728 if let Some(ref param_value) = p_page {
729 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
730 }
731 if let Some(ref param_value) = p_page_size {
732 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
733 }
734 if let Some(ref param_value) = p_page_token {
735 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
736 }
737 if let Some(ref param_value) = p_consistency {
738 req_builder = req_builder.query(&[("consistency", ¶m_value.to_string())]);
739 }
740 if let Some(ref param_value) = p_ids {
741 req_builder = match "multi" {
742 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
743 _ => req_builder.query(&[("ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
744 };
745 }
746 if let Some(ref param_value) = p_credentials_identifier {
747 req_builder = req_builder.query(&[("credentials_identifier", ¶m_value.to_string())]);
748 }
749 if let Some(ref param_value) = p_preview_credentials_identifier_similar {
750 req_builder = req_builder.query(&[("preview_credentials_identifier_similar", ¶m_value.to_string())]);
751 }
752 if let Some(ref param_value) = p_include_credential {
753 req_builder = match "multi" {
754 "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)>>()),
755 _ => req_builder.query(&[("include_credential", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
756 };
757 }
758 if let Some(ref param_value) = p_organization_id {
759 req_builder = req_builder.query(&[("organization_id", ¶m_value.to_string())]);
760 }
761 if let Some(ref user_agent) = configuration.user_agent {
762 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
763 }
764 if let Some(ref token) = configuration.bearer_access_token {
765 req_builder = req_builder.bearer_auth(token.to_owned());
766 };
767
768 let req = req_builder.build()?;
769 let resp = configuration.client.execute(req).await?;
770
771 let status = resp.status();
772 let content_type = resp
773 .headers()
774 .get("content-type")
775 .and_then(|v| v.to_str().ok())
776 .unwrap_or("application/octet-stream");
777 let content_type = super::ContentType::from(content_type);
778
779 if !status.is_client_error() && !status.is_server_error() {
780 let content = resp.text().await?;
781 match content_type {
782 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
783 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Identity>`"))),
784 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>`")))),
785 }
786 } else {
787 let content = resp.text().await?;
788 let entity: Option<ListIdentitiesError> = serde_json::from_str(&content).ok();
789 Err(Error::ResponseError(ResponseContent { status, content, entity }))
790 }
791}
792
793pub 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>> {
795 let p_per_page = per_page;
797 let p_page = page;
798 let p_page_size = page_size;
799 let p_page_token = page_token;
800
801 let uri_str = format!("{}/schemas", configuration.base_path);
802 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
803
804 if let Some(ref param_value) = p_per_page {
805 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
806 }
807 if let Some(ref param_value) = p_page {
808 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
809 }
810 if let Some(ref param_value) = p_page_size {
811 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
812 }
813 if let Some(ref param_value) = p_page_token {
814 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
815 }
816 if let Some(ref user_agent) = configuration.user_agent {
817 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
818 }
819
820 let req = req_builder.build()?;
821 let resp = configuration.client.execute(req).await?;
822
823 let status = resp.status();
824 let content_type = resp
825 .headers()
826 .get("content-type")
827 .and_then(|v| v.to_str().ok())
828 .unwrap_or("application/octet-stream");
829 let content_type = super::ContentType::from(content_type);
830
831 if !status.is_client_error() && !status.is_server_error() {
832 let content = resp.text().await?;
833 match content_type {
834 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
835 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::IdentitySchemaContainer>`"))),
836 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>`")))),
837 }
838 } else {
839 let content = resp.text().await?;
840 let entity: Option<ListIdentitySchemasError> = serde_json::from_str(&content).ok();
841 Err(Error::ResponseError(ResponseContent { status, content, entity }))
842 }
843}
844
845pub 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>> {
847 let p_id = id;
849 let p_per_page = per_page;
850 let p_page = page;
851 let p_page_size = page_size;
852 let p_page_token = page_token;
853 let p_active = active;
854
855 let uri_str = format!("{}/admin/identities/{id}/sessions", configuration.base_path, id=crate::apis::urlencode(p_id));
856 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
857
858 if let Some(ref param_value) = p_per_page {
859 req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
860 }
861 if let Some(ref param_value) = p_page {
862 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
863 }
864 if let Some(ref param_value) = p_page_size {
865 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
866 }
867 if let Some(ref param_value) = p_page_token {
868 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
869 }
870 if let Some(ref param_value) = p_active {
871 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
872 }
873 if let Some(ref user_agent) = configuration.user_agent {
874 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
875 }
876 if let Some(ref token) = configuration.bearer_access_token {
877 req_builder = req_builder.bearer_auth(token.to_owned());
878 };
879
880 let req = req_builder.build()?;
881 let resp = configuration.client.execute(req).await?;
882
883 let status = resp.status();
884 let content_type = resp
885 .headers()
886 .get("content-type")
887 .and_then(|v| v.to_str().ok())
888 .unwrap_or("application/octet-stream");
889 let content_type = super::ContentType::from(content_type);
890
891 if !status.is_client_error() && !status.is_server_error() {
892 let content = resp.text().await?;
893 match content_type {
894 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
895 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
896 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>`")))),
897 }
898 } else {
899 let content = resp.text().await?;
900 let entity: Option<ListIdentitySessionsError> = serde_json::from_str(&content).ok();
901 Err(Error::ResponseError(ResponseContent { status, content, entity }))
902 }
903}
904
905pub 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>> {
907 let p_page_size = page_size;
909 let p_page_token = page_token;
910 let p_active = active;
911 let p_expand = expand;
912
913 let uri_str = format!("{}/admin/sessions", configuration.base_path);
914 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
915
916 if let Some(ref param_value) = p_page_size {
917 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
918 }
919 if let Some(ref param_value) = p_page_token {
920 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
921 }
922 if let Some(ref param_value) = p_active {
923 req_builder = req_builder.query(&[("active", ¶m_value.to_string())]);
924 }
925 if let Some(ref param_value) = p_expand {
926 req_builder = match "multi" {
927 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
928 _ => req_builder.query(&[("expand", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
929 };
930 }
931 if let Some(ref user_agent) = configuration.user_agent {
932 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
933 }
934 if let Some(ref token) = configuration.bearer_access_token {
935 req_builder = req_builder.bearer_auth(token.to_owned());
936 };
937
938 let req = req_builder.build()?;
939 let resp = configuration.client.execute(req).await?;
940
941 let status = resp.status();
942 let content_type = resp
943 .headers()
944 .get("content-type")
945 .and_then(|v| v.to_str().ok())
946 .unwrap_or("application/octet-stream");
947 let content_type = super::ContentType::from(content_type);
948
949 if !status.is_client_error() && !status.is_server_error() {
950 let content = resp.text().await?;
951 match content_type {
952 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
953 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Session>`"))),
954 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>`")))),
955 }
956 } else {
957 let content = resp.text().await?;
958 let entity: Option<ListSessionsError> = serde_json::from_str(&content).ok();
959 Err(Error::ResponseError(ResponseContent { status, content, entity }))
960 }
961}
962
963pub async fn patch_identity(configuration: &configuration::Configuration, id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::Identity, Error<PatchIdentityError>> {
965 let p_id = id;
967 let p_json_patch = json_patch;
968
969 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
970 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
971
972 if let Some(ref user_agent) = configuration.user_agent {
973 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
974 }
975 if let Some(ref token) = configuration.bearer_access_token {
976 req_builder = req_builder.bearer_auth(token.to_owned());
977 };
978 req_builder = req_builder.json(&p_json_patch);
979
980 let req = req_builder.build()?;
981 let resp = configuration.client.execute(req).await?;
982
983 let status = resp.status();
984 let content_type = resp
985 .headers()
986 .get("content-type")
987 .and_then(|v| v.to_str().ok())
988 .unwrap_or("application/octet-stream");
989 let content_type = super::ContentType::from(content_type);
990
991 if !status.is_client_error() && !status.is_server_error() {
992 let content = resp.text().await?;
993 match content_type {
994 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
995 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
996 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`")))),
997 }
998 } else {
999 let content = resp.text().await?;
1000 let entity: Option<PatchIdentityError> = serde_json::from_str(&content).ok();
1001 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1002 }
1003}
1004
1005pub async fn update_identity(configuration: &configuration::Configuration, id: &str, update_identity_body: Option<models::UpdateIdentityBody>) -> Result<models::Identity, Error<UpdateIdentityError>> {
1007 let p_id = id;
1009 let p_update_identity_body = update_identity_body;
1010
1011 let uri_str = format!("{}/admin/identities/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1012 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1013
1014 if let Some(ref user_agent) = configuration.user_agent {
1015 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1016 }
1017 if let Some(ref token) = configuration.bearer_access_token {
1018 req_builder = req_builder.bearer_auth(token.to_owned());
1019 };
1020 req_builder = req_builder.json(&p_update_identity_body);
1021
1022 let req = req_builder.build()?;
1023 let resp = configuration.client.execute(req).await?;
1024
1025 let status = resp.status();
1026 let content_type = resp
1027 .headers()
1028 .get("content-type")
1029 .and_then(|v| v.to_str().ok())
1030 .unwrap_or("application/octet-stream");
1031 let content_type = super::ContentType::from(content_type);
1032
1033 if !status.is_client_error() && !status.is_server_error() {
1034 let content = resp.text().await?;
1035 match content_type {
1036 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1037 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Identity`"))),
1038 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`")))),
1039 }
1040 } else {
1041 let content = resp.text().await?;
1042 let entity: Option<UpdateIdentityError> = serde_json::from_str(&content).ok();
1043 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1044 }
1045}
1046