1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
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 GetIdentitySchemaError {
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 GetSessionError {
129 Status400(models::ErrorGeneric),
130 DefaultResponse(models::ErrorGeneric),
131 UnknownValue(serde_json::Value),
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum ListIdentitiesError {
138 DefaultResponse(models::ErrorGeneric),
139 UnknownValue(serde_json::Value),
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum ListIdentitySchemasError {
146 DefaultResponse(models::ErrorGeneric),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum ListIdentitySessionsError {
154 Status400(models::ErrorGeneric),
155 Status404(models::ErrorGeneric),
156 DefaultResponse(models::ErrorGeneric),
157 UnknownValue(serde_json::Value),
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum ListSessionsError {
164 Status400(models::ErrorGeneric),
165 DefaultResponse(models::ErrorGeneric),
166 UnknownValue(serde_json::Value),
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum PatchIdentityError {
173 Status400(models::ErrorGeneric),
174 Status404(models::ErrorGeneric),
175 Status409(models::ErrorGeneric),
176 DefaultResponse(models::ErrorGeneric),
177 UnknownValue(serde_json::Value),
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum UpdateIdentityError {
184 Status400(models::ErrorGeneric),
185 Status404(models::ErrorGeneric),
186 Status409(models::ErrorGeneric),
187 DefaultResponse(models::ErrorGeneric),
188 UnknownValue(serde_json::Value),
189}
190
191
192pub async fn batch_patch_identities(configuration: &configuration::Configuration, patch_identities_body: Option<models::PatchIdentitiesBody>) -> Result<models::BatchPatchIdentitiesResponse, Error<BatchPatchIdentitiesError>> {
194 let local_var_configuration = configuration;
195
196 let local_var_client = &local_var_configuration.client;
197
198 let local_var_uri_str = format!("{}/admin/identities", local_var_configuration.base_path);
199 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
200
201 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
203 }
204 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
205 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
206 };
207 local_var_req_builder = local_var_req_builder.json(&patch_identities_body);
208
209 let local_var_req = local_var_req_builder.build()?;
210 let local_var_resp = local_var_client.execute(local_var_req).await?;
211
212 let local_var_status = local_var_resp.status();
213 let local_var_content = local_var_resp.text().await?;
214
215 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
216 serde_json::from_str(&local_var_content).map_err(Error::from)
217 } else {
218 let local_var_entity: Option<BatchPatchIdentitiesError> = serde_json::from_str(&local_var_content).ok();
219 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
220 Err(Error::ResponseError(local_var_error))
221 }
222}
223
224pub async fn create_identity(configuration: &configuration::Configuration, create_identity_body: Option<models::CreateIdentityBody>) -> Result<models::Identity, Error<CreateIdentityError>> {
226 let local_var_configuration = configuration;
227
228 let local_var_client = &local_var_configuration.client;
229
230 let local_var_uri_str = format!("{}/admin/identities", local_var_configuration.base_path);
231 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
232
233 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
234 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
235 }
236 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
237 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
238 };
239 local_var_req_builder = local_var_req_builder.json(&create_identity_body);
240
241 let local_var_req = local_var_req_builder.build()?;
242 let local_var_resp = local_var_client.execute(local_var_req).await?;
243
244 let local_var_status = local_var_resp.status();
245 let local_var_content = local_var_resp.text().await?;
246
247 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
248 serde_json::from_str(&local_var_content).map_err(Error::from)
249 } else {
250 let local_var_entity: Option<CreateIdentityError> = serde_json::from_str(&local_var_content).ok();
251 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
252 Err(Error::ResponseError(local_var_error))
253 }
254}
255
256pub async fn create_recovery_code_for_identity(configuration: &configuration::Configuration, create_recovery_code_for_identity_body: Option<models::CreateRecoveryCodeForIdentityBody>) -> Result<models::RecoveryCodeForIdentity, Error<CreateRecoveryCodeForIdentityError>> {
258 let local_var_configuration = configuration;
259
260 let local_var_client = &local_var_configuration.client;
261
262 let local_var_uri_str = format!("{}/admin/recovery/code", local_var_configuration.base_path);
263 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
264
265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267 }
268 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
269 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
270 };
271 local_var_req_builder = local_var_req_builder.json(&create_recovery_code_for_identity_body);
272
273 let local_var_req = local_var_req_builder.build()?;
274 let local_var_resp = local_var_client.execute(local_var_req).await?;
275
276 let local_var_status = local_var_resp.status();
277 let local_var_content = local_var_resp.text().await?;
278
279 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280 serde_json::from_str(&local_var_content).map_err(Error::from)
281 } else {
282 let local_var_entity: Option<CreateRecoveryCodeForIdentityError> = serde_json::from_str(&local_var_content).ok();
283 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
284 Err(Error::ResponseError(local_var_error))
285 }
286}
287
288pub 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>> {
290 let local_var_configuration = configuration;
291
292 let local_var_client = &local_var_configuration.client;
293
294 let local_var_uri_str = format!("{}/admin/recovery/link", local_var_configuration.base_path);
295 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
296
297 if let Some(ref local_var_str) = return_to {
298 local_var_req_builder = local_var_req_builder.query(&[("return_to", &local_var_str.to_string())]);
299 }
300 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
301 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
302 }
303 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
304 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
305 };
306 local_var_req_builder = local_var_req_builder.json(&create_recovery_link_for_identity_body);
307
308 let local_var_req = local_var_req_builder.build()?;
309 let local_var_resp = local_var_client.execute(local_var_req).await?;
310
311 let local_var_status = local_var_resp.status();
312 let local_var_content = local_var_resp.text().await?;
313
314 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315 serde_json::from_str(&local_var_content).map_err(Error::from)
316 } else {
317 let local_var_entity: Option<CreateRecoveryLinkForIdentityError> = serde_json::from_str(&local_var_content).ok();
318 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
319 Err(Error::ResponseError(local_var_error))
320 }
321}
322
323pub async fn delete_identity(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentityError>> {
325 let local_var_configuration = configuration;
326
327 let local_var_client = &local_var_configuration.client;
328
329 let local_var_uri_str = format!("{}/admin/identities/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
330 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
331
332 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
333 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
334 }
335 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
336 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
337 };
338
339 let local_var_req = local_var_req_builder.build()?;
340 let local_var_resp = local_var_client.execute(local_var_req).await?;
341
342 let local_var_status = local_var_resp.status();
343 let local_var_content = local_var_resp.text().await?;
344
345 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
346 Ok(())
347 } else {
348 let local_var_entity: Option<DeleteIdentityError> = serde_json::from_str(&local_var_content).ok();
349 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
350 Err(Error::ResponseError(local_var_error))
351 }
352}
353
354pub async fn delete_identity_credentials(configuration: &configuration::Configuration, id: &str, r#type: &str, identifier: Option<&str>) -> Result<(), Error<DeleteIdentityCredentialsError>> {
356 let local_var_configuration = configuration;
357
358 let local_var_client = &local_var_configuration.client;
359
360 let local_var_uri_str = format!("{}/admin/identities/{id}/credentials/{type}", local_var_configuration.base_path, id=crate::apis::urlencode(id), type=crate::apis::urlencode(r#type));
361 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
362
363 if let Some(ref local_var_str) = identifier {
364 local_var_req_builder = local_var_req_builder.query(&[("identifier", &local_var_str.to_string())]);
365 }
366 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
367 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
368 }
369 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
370 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
371 };
372
373 let local_var_req = local_var_req_builder.build()?;
374 let local_var_resp = local_var_client.execute(local_var_req).await?;
375
376 let local_var_status = local_var_resp.status();
377 let local_var_content = local_var_resp.text().await?;
378
379 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
380 Ok(())
381 } else {
382 let local_var_entity: Option<DeleteIdentityCredentialsError> = serde_json::from_str(&local_var_content).ok();
383 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
384 Err(Error::ResponseError(local_var_error))
385 }
386}
387
388pub async fn delete_identity_sessions(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteIdentitySessionsError>> {
390 let local_var_configuration = configuration;
391
392 let local_var_client = &local_var_configuration.client;
393
394 let local_var_uri_str = format!("{}/admin/identities/{id}/sessions", local_var_configuration.base_path, id=crate::apis::urlencode(id));
395 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
396
397 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
398 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
399 }
400 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
401 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
402 };
403
404 let local_var_req = local_var_req_builder.build()?;
405 let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407 let local_var_status = local_var_resp.status();
408 let local_var_content = local_var_resp.text().await?;
409
410 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411 Ok(())
412 } else {
413 let local_var_entity: Option<DeleteIdentitySessionsError> = serde_json::from_str(&local_var_content).ok();
414 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415 Err(Error::ResponseError(local_var_error))
416 }
417}
418
419pub async fn disable_session(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DisableSessionError>> {
421 let local_var_configuration = configuration;
422
423 let local_var_client = &local_var_configuration.client;
424
425 let local_var_uri_str = format!("{}/admin/sessions/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
426 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
427
428 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
429 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
430 }
431 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
432 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
433 };
434
435 let local_var_req = local_var_req_builder.build()?;
436 let local_var_resp = local_var_client.execute(local_var_req).await?;
437
438 let local_var_status = local_var_resp.status();
439 let local_var_content = local_var_resp.text().await?;
440
441 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
442 Ok(())
443 } else {
444 let local_var_entity: Option<DisableSessionError> = serde_json::from_str(&local_var_content).ok();
445 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
446 Err(Error::ResponseError(local_var_error))
447 }
448}
449
450pub async fn extend_session(configuration: &configuration::Configuration, id: &str) -> Result<models::Session, Error<ExtendSessionError>> {
452 let local_var_configuration = configuration;
453
454 let local_var_client = &local_var_configuration.client;
455
456 let local_var_uri_str = format!("{}/admin/sessions/{id}/extend", local_var_configuration.base_path, id=crate::apis::urlencode(id));
457 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
458
459 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
460 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
461 }
462 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
463 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
464 };
465
466 let local_var_req = local_var_req_builder.build()?;
467 let local_var_resp = local_var_client.execute(local_var_req).await?;
468
469 let local_var_status = local_var_resp.status();
470 let local_var_content = local_var_resp.text().await?;
471
472 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
473 serde_json::from_str(&local_var_content).map_err(Error::from)
474 } else {
475 let local_var_entity: Option<ExtendSessionError> = serde_json::from_str(&local_var_content).ok();
476 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
477 Err(Error::ResponseError(local_var_error))
478 }
479}
480
481pub async fn get_identity(configuration: &configuration::Configuration, id: &str, include_credential: Option<Vec<String>>) -> Result<models::Identity, Error<GetIdentityError>> {
483 let local_var_configuration = configuration;
484
485 let local_var_client = &local_var_configuration.client;
486
487 let local_var_uri_str = format!("{}/admin/identities/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
488 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
489
490 if let Some(ref local_var_str) = include_credential {
491 local_var_req_builder = match "multi" {
492 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("include_credential".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
493 _ => local_var_req_builder.query(&[("include_credential", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
494 };
495 }
496 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
497 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
498 }
499 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
500 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
501 };
502
503 let local_var_req = local_var_req_builder.build()?;
504 let local_var_resp = local_var_client.execute(local_var_req).await?;
505
506 let local_var_status = local_var_resp.status();
507 let local_var_content = local_var_resp.text().await?;
508
509 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
510 serde_json::from_str(&local_var_content).map_err(Error::from)
511 } else {
512 let local_var_entity: Option<GetIdentityError> = serde_json::from_str(&local_var_content).ok();
513 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
514 Err(Error::ResponseError(local_var_error))
515 }
516}
517
518pub async fn get_identity_schema(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<GetIdentitySchemaError>> {
520 let local_var_configuration = configuration;
521
522 let local_var_client = &local_var_configuration.client;
523
524 let local_var_uri_str = format!("{}/schemas/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
525 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
526
527 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
528 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
529 }
530
531 let local_var_req = local_var_req_builder.build()?;
532 let local_var_resp = local_var_client.execute(local_var_req).await?;
533
534 let local_var_status = local_var_resp.status();
535 let local_var_content = local_var_resp.text().await?;
536
537 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
538 serde_json::from_str(&local_var_content).map_err(Error::from)
539 } else {
540 let local_var_entity: Option<GetIdentitySchemaError> = serde_json::from_str(&local_var_content).ok();
541 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
542 Err(Error::ResponseError(local_var_error))
543 }
544}
545
546pub async fn get_session(configuration: &configuration::Configuration, id: &str, expand: Option<Vec<String>>) -> Result<models::Session, Error<GetSessionError>> {
548 let local_var_configuration = configuration;
549
550 let local_var_client = &local_var_configuration.client;
551
552 let local_var_uri_str = format!("{}/admin/sessions/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
553 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
554
555 if let Some(ref local_var_str) = expand {
556 local_var_req_builder = match "multi" {
557 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
558 _ => local_var_req_builder.query(&[("expand", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
559 };
560 }
561 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
562 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
563 }
564 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
565 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
566 };
567
568 let local_var_req = local_var_req_builder.build()?;
569 let local_var_resp = local_var_client.execute(local_var_req).await?;
570
571 let local_var_status = local_var_resp.status();
572 let local_var_content = local_var_resp.text().await?;
573
574 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
575 serde_json::from_str(&local_var_content).map_err(Error::from)
576 } else {
577 let local_var_entity: Option<GetSessionError> = serde_json::from_str(&local_var_content).ok();
578 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
579 Err(Error::ResponseError(local_var_error))
580 }
581}
582
583pub 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>> {
585 let local_var_configuration = configuration;
586
587 let local_var_client = &local_var_configuration.client;
588
589 let local_var_uri_str = format!("{}/admin/identities", local_var_configuration.base_path);
590 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
591
592 if let Some(ref local_var_str) = per_page {
593 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
594 }
595 if let Some(ref local_var_str) = page {
596 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
597 }
598 if let Some(ref local_var_str) = page_size {
599 local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
600 }
601 if let Some(ref local_var_str) = page_token {
602 local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
603 }
604 if let Some(ref local_var_str) = consistency {
605 local_var_req_builder = local_var_req_builder.query(&[("consistency", &local_var_str.to_string())]);
606 }
607 if let Some(ref local_var_str) = ids {
608 local_var_req_builder = match "multi" {
609 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
610 _ => local_var_req_builder.query(&[("ids", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
611 };
612 }
613 if let Some(ref local_var_str) = credentials_identifier {
614 local_var_req_builder = local_var_req_builder.query(&[("credentials_identifier", &local_var_str.to_string())]);
615 }
616 if let Some(ref local_var_str) = preview_credentials_identifier_similar {
617 local_var_req_builder = local_var_req_builder.query(&[("preview_credentials_identifier_similar", &local_var_str.to_string())]);
618 }
619 if let Some(ref local_var_str) = include_credential {
620 local_var_req_builder = match "multi" {
621 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("include_credential".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
622 _ => local_var_req_builder.query(&[("include_credential", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
623 };
624 }
625 if let Some(ref local_var_str) = organization_id {
626 local_var_req_builder = local_var_req_builder.query(&[("organization_id", &local_var_str.to_string())]);
627 }
628 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
629 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
630 }
631 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
632 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
633 };
634
635 let local_var_req = local_var_req_builder.build()?;
636 let local_var_resp = local_var_client.execute(local_var_req).await?;
637
638 let local_var_status = local_var_resp.status();
639 let local_var_content = local_var_resp.text().await?;
640
641 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
642 serde_json::from_str(&local_var_content).map_err(Error::from)
643 } else {
644 let local_var_entity: Option<ListIdentitiesError> = serde_json::from_str(&local_var_content).ok();
645 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
646 Err(Error::ResponseError(local_var_error))
647 }
648}
649
650pub 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>> {
652 let local_var_configuration = configuration;
653
654 let local_var_client = &local_var_configuration.client;
655
656 let local_var_uri_str = format!("{}/schemas", local_var_configuration.base_path);
657 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
658
659 if let Some(ref local_var_str) = per_page {
660 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
661 }
662 if let Some(ref local_var_str) = page {
663 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
664 }
665 if let Some(ref local_var_str) = page_size {
666 local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
667 }
668 if let Some(ref local_var_str) = page_token {
669 local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
670 }
671 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
672 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
673 }
674
675 let local_var_req = local_var_req_builder.build()?;
676 let local_var_resp = local_var_client.execute(local_var_req).await?;
677
678 let local_var_status = local_var_resp.status();
679 let local_var_content = local_var_resp.text().await?;
680
681 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
682 serde_json::from_str(&local_var_content).map_err(Error::from)
683 } else {
684 let local_var_entity: Option<ListIdentitySchemasError> = serde_json::from_str(&local_var_content).ok();
685 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
686 Err(Error::ResponseError(local_var_error))
687 }
688}
689
690pub 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>> {
692 let local_var_configuration = configuration;
693
694 let local_var_client = &local_var_configuration.client;
695
696 let local_var_uri_str = format!("{}/admin/identities/{id}/sessions", local_var_configuration.base_path, id=crate::apis::urlencode(id));
697 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
698
699 if let Some(ref local_var_str) = per_page {
700 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
701 }
702 if let Some(ref local_var_str) = page {
703 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
704 }
705 if let Some(ref local_var_str) = page_size {
706 local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
707 }
708 if let Some(ref local_var_str) = page_token {
709 local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
710 }
711 if let Some(ref local_var_str) = active {
712 local_var_req_builder = local_var_req_builder.query(&[("active", &local_var_str.to_string())]);
713 }
714 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
715 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
716 }
717 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
718 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
719 };
720
721 let local_var_req = local_var_req_builder.build()?;
722 let local_var_resp = local_var_client.execute(local_var_req).await?;
723
724 let local_var_status = local_var_resp.status();
725 let local_var_content = local_var_resp.text().await?;
726
727 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
728 serde_json::from_str(&local_var_content).map_err(Error::from)
729 } else {
730 let local_var_entity: Option<ListIdentitySessionsError> = serde_json::from_str(&local_var_content).ok();
731 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
732 Err(Error::ResponseError(local_var_error))
733 }
734}
735
736pub 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>> {
738 let local_var_configuration = configuration;
739
740 let local_var_client = &local_var_configuration.client;
741
742 let local_var_uri_str = format!("{}/admin/sessions", local_var_configuration.base_path);
743 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
744
745 if let Some(ref local_var_str) = page_size {
746 local_var_req_builder = local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
747 }
748 if let Some(ref local_var_str) = page_token {
749 local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
750 }
751 if let Some(ref local_var_str) = active {
752 local_var_req_builder = local_var_req_builder.query(&[("active", &local_var_str.to_string())]);
753 }
754 if let Some(ref local_var_str) = expand {
755 local_var_req_builder = match "multi" {
756 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("expand".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
757 _ => local_var_req_builder.query(&[("expand", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
758 };
759 }
760 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
761 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
762 }
763 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
764 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
765 };
766
767 let local_var_req = local_var_req_builder.build()?;
768 let local_var_resp = local_var_client.execute(local_var_req).await?;
769
770 let local_var_status = local_var_resp.status();
771 let local_var_content = local_var_resp.text().await?;
772
773 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
774 serde_json::from_str(&local_var_content).map_err(Error::from)
775 } else {
776 let local_var_entity: Option<ListSessionsError> = serde_json::from_str(&local_var_content).ok();
777 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
778 Err(Error::ResponseError(local_var_error))
779 }
780}
781
782pub async fn patch_identity(configuration: &configuration::Configuration, id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::Identity, Error<PatchIdentityError>> {
784 let local_var_configuration = configuration;
785
786 let local_var_client = &local_var_configuration.client;
787
788 let local_var_uri_str = format!("{}/admin/identities/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
789 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
790
791 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
792 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
793 }
794 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
795 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
796 };
797 local_var_req_builder = local_var_req_builder.json(&json_patch);
798
799 let local_var_req = local_var_req_builder.build()?;
800 let local_var_resp = local_var_client.execute(local_var_req).await?;
801
802 let local_var_status = local_var_resp.status();
803 let local_var_content = local_var_resp.text().await?;
804
805 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
806 serde_json::from_str(&local_var_content).map_err(Error::from)
807 } else {
808 let local_var_entity: Option<PatchIdentityError> = serde_json::from_str(&local_var_content).ok();
809 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
810 Err(Error::ResponseError(local_var_error))
811 }
812}
813
814pub async fn update_identity(configuration: &configuration::Configuration, id: &str, update_identity_body: Option<models::UpdateIdentityBody>) -> Result<models::Identity, Error<UpdateIdentityError>> {
816 let local_var_configuration = configuration;
817
818 let local_var_client = &local_var_configuration.client;
819
820 let local_var_uri_str = format!("{}/admin/identities/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
821 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
822
823 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
824 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
825 }
826 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
827 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
828 };
829 local_var_req_builder = local_var_req_builder.json(&update_identity_body);
830
831 let local_var_req = local_var_req_builder.build()?;
832 let local_var_resp = local_var_client.execute(local_var_req).await?;
833
834 let local_var_status = local_var_resp.status();
835 let local_var_content = local_var_resp.text().await?;
836
837 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
838 serde_json::from_str(&local_var_content).map_err(Error::from)
839 } else {
840 let local_var_entity: Option<UpdateIdentityError> = serde_json::from_str(&local_var_content).ok();
841 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
842 Err(Error::ResponseError(local_var_error))
843 }
844}
845