bitwarden_api_api/apis/
devices_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`devices_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum DevicesGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`devices_id_delete`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum DevicesIdDeleteError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`devices_id_delete_post`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum DevicesIdDeletePostError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`devices_id_get`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum DevicesIdGetError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`devices_id_post`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum DevicesIdPostError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`devices_id_put`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum DevicesIdPutError {
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`devices_identifier_identifier_clear_token_post`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum DevicesIdentifierIdentifierClearTokenPostError {
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`devices_identifier_identifier_clear_token_put`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum DevicesIdentifierIdentifierClearTokenPutError {
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`devices_identifier_identifier_get`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum DevicesIdentifierIdentifierGetError {
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`devices_identifier_identifier_token_post`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum DevicesIdentifierIdentifierTokenPostError {
84    UnknownValue(serde_json::Value),
85}
86
87/// struct for typed errors of method [`devices_identifier_identifier_token_put`]
88#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum DevicesIdentifierIdentifierTokenPutError {
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`devices_identifier_keys_post`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum DevicesIdentifierKeysPostError {
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`devices_identifier_keys_put`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum DevicesIdentifierKeysPutError {
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`devices_identifier_retrieve_keys_post`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum DevicesIdentifierRetrieveKeysPostError {
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`devices_knowndevice_email_identifier_get`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum DevicesKnowndeviceEmailIdentifierGetError {
119    UnknownValue(serde_json::Value),
120}
121
122/// struct for typed errors of method [`devices_knowndevice_get`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum DevicesKnowndeviceGetError {
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`devices_lost_trust_post`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum DevicesLostTrustPostError {
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed errors of method [`devices_post`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum DevicesPostError {
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`devices_update_trust_post`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum DevicesUpdateTrustPostError {
147    UnknownValue(serde_json::Value),
148}
149
150pub async fn devices_get(
151    configuration: &configuration::Configuration,
152) -> Result<models::DeviceResponseModelListResponseModel, Error<DevicesGetError>> {
153    let local_var_configuration = configuration;
154
155    let local_var_client = &local_var_configuration.client;
156
157    let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path);
158    let mut local_var_req_builder =
159        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
160
161    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
162        local_var_req_builder =
163            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
164    }
165    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
166        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
167    };
168
169    let local_var_req = local_var_req_builder.build()?;
170    let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172    let local_var_status = local_var_resp.status();
173    let local_var_content = local_var_resp.text().await?;
174
175    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
176        serde_json::from_str(&local_var_content).map_err(Error::from)
177    } else {
178        let local_var_entity: Option<DevicesGetError> =
179            serde_json::from_str(&local_var_content).ok();
180        let local_var_error = ResponseContent {
181            status: local_var_status,
182            content: local_var_content,
183            entity: local_var_entity,
184        };
185        Err(Error::ResponseError(local_var_error))
186    }
187}
188
189pub async fn devices_id_delete(
190    configuration: &configuration::Configuration,
191    id: &str,
192) -> Result<(), Error<DevicesIdDeleteError>> {
193    let local_var_configuration = configuration;
194
195    let local_var_client = &local_var_configuration.client;
196
197    let local_var_uri_str = format!(
198        "{}/devices/{id}",
199        local_var_configuration.base_path,
200        id = crate::apis::urlencode(id)
201    );
202    let mut local_var_req_builder =
203        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
204
205    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
206        local_var_req_builder =
207            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208    }
209    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
210        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
211    };
212
213    let local_var_req = local_var_req_builder.build()?;
214    let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216    let local_var_status = local_var_resp.status();
217    let local_var_content = local_var_resp.text().await?;
218
219    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220        Ok(())
221    } else {
222        let local_var_entity: Option<DevicesIdDeleteError> =
223            serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent {
225            status: local_var_status,
226            content: local_var_content,
227            entity: local_var_entity,
228        };
229        Err(Error::ResponseError(local_var_error))
230    }
231}
232
233pub async fn devices_id_delete_post(
234    configuration: &configuration::Configuration,
235    id: &str,
236) -> Result<(), Error<DevicesIdDeletePostError>> {
237    let local_var_configuration = configuration;
238
239    let local_var_client = &local_var_configuration.client;
240
241    let local_var_uri_str = format!(
242        "{}/devices/{id}/delete",
243        local_var_configuration.base_path,
244        id = crate::apis::urlencode(id)
245    );
246    let mut local_var_req_builder =
247        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
248
249    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
250        local_var_req_builder =
251            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
252    }
253    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
254        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
255    };
256
257    let local_var_req = local_var_req_builder.build()?;
258    let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260    let local_var_status = local_var_resp.status();
261    let local_var_content = local_var_resp.text().await?;
262
263    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264        Ok(())
265    } else {
266        let local_var_entity: Option<DevicesIdDeletePostError> =
267            serde_json::from_str(&local_var_content).ok();
268        let local_var_error = ResponseContent {
269            status: local_var_status,
270            content: local_var_content,
271            entity: local_var_entity,
272        };
273        Err(Error::ResponseError(local_var_error))
274    }
275}
276
277pub async fn devices_id_get(
278    configuration: &configuration::Configuration,
279    id: &str,
280) -> Result<models::DeviceResponseModel, Error<DevicesIdGetError>> {
281    let local_var_configuration = configuration;
282
283    let local_var_client = &local_var_configuration.client;
284
285    let local_var_uri_str = format!(
286        "{}/devices/{id}",
287        local_var_configuration.base_path,
288        id = crate::apis::urlencode(id)
289    );
290    let mut local_var_req_builder =
291        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
292
293    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294        local_var_req_builder =
295            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296    }
297    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
298        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
299    };
300
301    let local_var_req = local_var_req_builder.build()?;
302    let local_var_resp = local_var_client.execute(local_var_req).await?;
303
304    let local_var_status = local_var_resp.status();
305    let local_var_content = local_var_resp.text().await?;
306
307    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
308        serde_json::from_str(&local_var_content).map_err(Error::from)
309    } else {
310        let local_var_entity: Option<DevicesIdGetError> =
311            serde_json::from_str(&local_var_content).ok();
312        let local_var_error = ResponseContent {
313            status: local_var_status,
314            content: local_var_content,
315            entity: local_var_entity,
316        };
317        Err(Error::ResponseError(local_var_error))
318    }
319}
320
321pub async fn devices_id_post(
322    configuration: &configuration::Configuration,
323    id: &str,
324    device_request_model: Option<models::DeviceRequestModel>,
325) -> Result<models::DeviceResponseModel, Error<DevicesIdPostError>> {
326    let local_var_configuration = configuration;
327
328    let local_var_client = &local_var_configuration.client;
329
330    let local_var_uri_str = format!(
331        "{}/devices/{id}",
332        local_var_configuration.base_path,
333        id = crate::apis::urlencode(id)
334    );
335    let mut local_var_req_builder =
336        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
337
338    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
339        local_var_req_builder =
340            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
341    }
342    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
343        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
344    };
345    local_var_req_builder = local_var_req_builder.json(&device_request_model);
346
347    let local_var_req = local_var_req_builder.build()?;
348    let local_var_resp = local_var_client.execute(local_var_req).await?;
349
350    let local_var_status = local_var_resp.status();
351    let local_var_content = local_var_resp.text().await?;
352
353    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
354        serde_json::from_str(&local_var_content).map_err(Error::from)
355    } else {
356        let local_var_entity: Option<DevicesIdPostError> =
357            serde_json::from_str(&local_var_content).ok();
358        let local_var_error = ResponseContent {
359            status: local_var_status,
360            content: local_var_content,
361            entity: local_var_entity,
362        };
363        Err(Error::ResponseError(local_var_error))
364    }
365}
366
367pub async fn devices_id_put(
368    configuration: &configuration::Configuration,
369    id: &str,
370    device_request_model: Option<models::DeviceRequestModel>,
371) -> Result<models::DeviceResponseModel, Error<DevicesIdPutError>> {
372    let local_var_configuration = configuration;
373
374    let local_var_client = &local_var_configuration.client;
375
376    let local_var_uri_str = format!(
377        "{}/devices/{id}",
378        local_var_configuration.base_path,
379        id = crate::apis::urlencode(id)
380    );
381    let mut local_var_req_builder =
382        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
383
384    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
385        local_var_req_builder =
386            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
387    }
388    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
389        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
390    };
391    local_var_req_builder = local_var_req_builder.json(&device_request_model);
392
393    let local_var_req = local_var_req_builder.build()?;
394    let local_var_resp = local_var_client.execute(local_var_req).await?;
395
396    let local_var_status = local_var_resp.status();
397    let local_var_content = local_var_resp.text().await?;
398
399    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
400        serde_json::from_str(&local_var_content).map_err(Error::from)
401    } else {
402        let local_var_entity: Option<DevicesIdPutError> =
403            serde_json::from_str(&local_var_content).ok();
404        let local_var_error = ResponseContent {
405            status: local_var_status,
406            content: local_var_content,
407            entity: local_var_entity,
408        };
409        Err(Error::ResponseError(local_var_error))
410    }
411}
412
413pub async fn devices_identifier_identifier_clear_token_post(
414    configuration: &configuration::Configuration,
415    identifier: &str,
416) -> Result<(), Error<DevicesIdentifierIdentifierClearTokenPostError>> {
417    let local_var_configuration = configuration;
418
419    let local_var_client = &local_var_configuration.client;
420
421    let local_var_uri_str = format!(
422        "{}/devices/identifier/{identifier}/clear-token",
423        local_var_configuration.base_path,
424        identifier = crate::apis::urlencode(identifier)
425    );
426    let mut local_var_req_builder =
427        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
428
429    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
430        local_var_req_builder =
431            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
432    }
433    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
434        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
435    };
436
437    let local_var_req = local_var_req_builder.build()?;
438    let local_var_resp = local_var_client.execute(local_var_req).await?;
439
440    let local_var_status = local_var_resp.status();
441    let local_var_content = local_var_resp.text().await?;
442
443    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
444        Ok(())
445    } else {
446        let local_var_entity: Option<DevicesIdentifierIdentifierClearTokenPostError> =
447            serde_json::from_str(&local_var_content).ok();
448        let local_var_error = ResponseContent {
449            status: local_var_status,
450            content: local_var_content,
451            entity: local_var_entity,
452        };
453        Err(Error::ResponseError(local_var_error))
454    }
455}
456
457pub async fn devices_identifier_identifier_clear_token_put(
458    configuration: &configuration::Configuration,
459    identifier: &str,
460) -> Result<(), Error<DevicesIdentifierIdentifierClearTokenPutError>> {
461    let local_var_configuration = configuration;
462
463    let local_var_client = &local_var_configuration.client;
464
465    let local_var_uri_str = format!(
466        "{}/devices/identifier/{identifier}/clear-token",
467        local_var_configuration.base_path,
468        identifier = crate::apis::urlencode(identifier)
469    );
470    let mut local_var_req_builder =
471        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
472
473    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
474        local_var_req_builder =
475            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
476    }
477    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
478        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
479    };
480
481    let local_var_req = local_var_req_builder.build()?;
482    let local_var_resp = local_var_client.execute(local_var_req).await?;
483
484    let local_var_status = local_var_resp.status();
485    let local_var_content = local_var_resp.text().await?;
486
487    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
488        Ok(())
489    } else {
490        let local_var_entity: Option<DevicesIdentifierIdentifierClearTokenPutError> =
491            serde_json::from_str(&local_var_content).ok();
492        let local_var_error = ResponseContent {
493            status: local_var_status,
494            content: local_var_content,
495            entity: local_var_entity,
496        };
497        Err(Error::ResponseError(local_var_error))
498    }
499}
500
501pub async fn devices_identifier_identifier_get(
502    configuration: &configuration::Configuration,
503    identifier: &str,
504) -> Result<models::DeviceResponseModel, Error<DevicesIdentifierIdentifierGetError>> {
505    let local_var_configuration = configuration;
506
507    let local_var_client = &local_var_configuration.client;
508
509    let local_var_uri_str = format!(
510        "{}/devices/identifier/{identifier}",
511        local_var_configuration.base_path,
512        identifier = crate::apis::urlencode(identifier)
513    );
514    let mut local_var_req_builder =
515        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
516
517    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
518        local_var_req_builder =
519            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
520    }
521    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
522        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
523    };
524
525    let local_var_req = local_var_req_builder.build()?;
526    let local_var_resp = local_var_client.execute(local_var_req).await?;
527
528    let local_var_status = local_var_resp.status();
529    let local_var_content = local_var_resp.text().await?;
530
531    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
532        serde_json::from_str(&local_var_content).map_err(Error::from)
533    } else {
534        let local_var_entity: Option<DevicesIdentifierIdentifierGetError> =
535            serde_json::from_str(&local_var_content).ok();
536        let local_var_error = ResponseContent {
537            status: local_var_status,
538            content: local_var_content,
539            entity: local_var_entity,
540        };
541        Err(Error::ResponseError(local_var_error))
542    }
543}
544
545pub async fn devices_identifier_identifier_token_post(
546    configuration: &configuration::Configuration,
547    identifier: &str,
548    device_token_request_model: Option<models::DeviceTokenRequestModel>,
549) -> Result<(), Error<DevicesIdentifierIdentifierTokenPostError>> {
550    let local_var_configuration = configuration;
551
552    let local_var_client = &local_var_configuration.client;
553
554    let local_var_uri_str = format!(
555        "{}/devices/identifier/{identifier}/token",
556        local_var_configuration.base_path,
557        identifier = crate::apis::urlencode(identifier)
558    );
559    let mut local_var_req_builder =
560        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
561
562    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
563        local_var_req_builder =
564            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
565    }
566    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
567        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
568    };
569    local_var_req_builder = local_var_req_builder.json(&device_token_request_model);
570
571    let local_var_req = local_var_req_builder.build()?;
572    let local_var_resp = local_var_client.execute(local_var_req).await?;
573
574    let local_var_status = local_var_resp.status();
575    let local_var_content = local_var_resp.text().await?;
576
577    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
578        Ok(())
579    } else {
580        let local_var_entity: Option<DevicesIdentifierIdentifierTokenPostError> =
581            serde_json::from_str(&local_var_content).ok();
582        let local_var_error = ResponseContent {
583            status: local_var_status,
584            content: local_var_content,
585            entity: local_var_entity,
586        };
587        Err(Error::ResponseError(local_var_error))
588    }
589}
590
591pub async fn devices_identifier_identifier_token_put(
592    configuration: &configuration::Configuration,
593    identifier: &str,
594    device_token_request_model: Option<models::DeviceTokenRequestModel>,
595) -> Result<(), Error<DevicesIdentifierIdentifierTokenPutError>> {
596    let local_var_configuration = configuration;
597
598    let local_var_client = &local_var_configuration.client;
599
600    let local_var_uri_str = format!(
601        "{}/devices/identifier/{identifier}/token",
602        local_var_configuration.base_path,
603        identifier = crate::apis::urlencode(identifier)
604    );
605    let mut local_var_req_builder =
606        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
607
608    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
609        local_var_req_builder =
610            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
611    }
612    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
613        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
614    };
615    local_var_req_builder = local_var_req_builder.json(&device_token_request_model);
616
617    let local_var_req = local_var_req_builder.build()?;
618    let local_var_resp = local_var_client.execute(local_var_req).await?;
619
620    let local_var_status = local_var_resp.status();
621    let local_var_content = local_var_resp.text().await?;
622
623    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
624        Ok(())
625    } else {
626        let local_var_entity: Option<DevicesIdentifierIdentifierTokenPutError> =
627            serde_json::from_str(&local_var_content).ok();
628        let local_var_error = ResponseContent {
629            status: local_var_status,
630            content: local_var_content,
631            entity: local_var_entity,
632        };
633        Err(Error::ResponseError(local_var_error))
634    }
635}
636
637pub async fn devices_identifier_keys_post(
638    configuration: &configuration::Configuration,
639    identifier: &str,
640    device_keys_request_model: Option<models::DeviceKeysRequestModel>,
641) -> Result<models::DeviceResponseModel, Error<DevicesIdentifierKeysPostError>> {
642    let local_var_configuration = configuration;
643
644    let local_var_client = &local_var_configuration.client;
645
646    let local_var_uri_str = format!(
647        "{}/devices/{identifier}/keys",
648        local_var_configuration.base_path,
649        identifier = crate::apis::urlencode(identifier)
650    );
651    let mut local_var_req_builder =
652        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
653
654    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
655        local_var_req_builder =
656            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
657    }
658    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
659        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
660    };
661    local_var_req_builder = local_var_req_builder.json(&device_keys_request_model);
662
663    let local_var_req = local_var_req_builder.build()?;
664    let local_var_resp = local_var_client.execute(local_var_req).await?;
665
666    let local_var_status = local_var_resp.status();
667    let local_var_content = local_var_resp.text().await?;
668
669    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
670        serde_json::from_str(&local_var_content).map_err(Error::from)
671    } else {
672        let local_var_entity: Option<DevicesIdentifierKeysPostError> =
673            serde_json::from_str(&local_var_content).ok();
674        let local_var_error = ResponseContent {
675            status: local_var_status,
676            content: local_var_content,
677            entity: local_var_entity,
678        };
679        Err(Error::ResponseError(local_var_error))
680    }
681}
682
683pub async fn devices_identifier_keys_put(
684    configuration: &configuration::Configuration,
685    identifier: &str,
686    device_keys_request_model: Option<models::DeviceKeysRequestModel>,
687) -> Result<models::DeviceResponseModel, Error<DevicesIdentifierKeysPutError>> {
688    let local_var_configuration = configuration;
689
690    let local_var_client = &local_var_configuration.client;
691
692    let local_var_uri_str = format!(
693        "{}/devices/{identifier}/keys",
694        local_var_configuration.base_path,
695        identifier = crate::apis::urlencode(identifier)
696    );
697    let mut local_var_req_builder =
698        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
699
700    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
701        local_var_req_builder =
702            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
703    }
704    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
705        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
706    };
707    local_var_req_builder = local_var_req_builder.json(&device_keys_request_model);
708
709    let local_var_req = local_var_req_builder.build()?;
710    let local_var_resp = local_var_client.execute(local_var_req).await?;
711
712    let local_var_status = local_var_resp.status();
713    let local_var_content = local_var_resp.text().await?;
714
715    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
716        serde_json::from_str(&local_var_content).map_err(Error::from)
717    } else {
718        let local_var_entity: Option<DevicesIdentifierKeysPutError> =
719            serde_json::from_str(&local_var_content).ok();
720        let local_var_error = ResponseContent {
721            status: local_var_status,
722            content: local_var_content,
723            entity: local_var_entity,
724        };
725        Err(Error::ResponseError(local_var_error))
726    }
727}
728
729pub async fn devices_identifier_retrieve_keys_post(
730    configuration: &configuration::Configuration,
731    identifier: &str,
732    secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
733) -> Result<models::ProtectedDeviceResponseModel, Error<DevicesIdentifierRetrieveKeysPostError>> {
734    let local_var_configuration = configuration;
735
736    let local_var_client = &local_var_configuration.client;
737
738    let local_var_uri_str = format!(
739        "{}/devices/{identifier}/retrieve-keys",
740        local_var_configuration.base_path,
741        identifier = crate::apis::urlencode(identifier)
742    );
743    let mut local_var_req_builder =
744        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
745
746    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
747        local_var_req_builder =
748            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
749    }
750    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
751        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
752    };
753    local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
754
755    let local_var_req = local_var_req_builder.build()?;
756    let local_var_resp = local_var_client.execute(local_var_req).await?;
757
758    let local_var_status = local_var_resp.status();
759    let local_var_content = local_var_resp.text().await?;
760
761    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
762        serde_json::from_str(&local_var_content).map_err(Error::from)
763    } else {
764        let local_var_entity: Option<DevicesIdentifierRetrieveKeysPostError> =
765            serde_json::from_str(&local_var_content).ok();
766        let local_var_error = ResponseContent {
767            status: local_var_status,
768            content: local_var_content,
769            entity: local_var_entity,
770        };
771        Err(Error::ResponseError(local_var_error))
772    }
773}
774
775pub async fn devices_knowndevice_email_identifier_get(
776    configuration: &configuration::Configuration,
777    email: &str,
778    identifier: &str,
779) -> Result<bool, Error<DevicesKnowndeviceEmailIdentifierGetError>> {
780    let local_var_configuration = configuration;
781
782    let local_var_client = &local_var_configuration.client;
783
784    let local_var_uri_str = format!(
785        "{}/devices/knowndevice/{email}/{identifier}",
786        local_var_configuration.base_path,
787        email = crate::apis::urlencode(email),
788        identifier = crate::apis::urlencode(identifier)
789    );
790    let mut local_var_req_builder =
791        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
792
793    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
794        local_var_req_builder =
795            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
796    }
797    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
798        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
799    };
800
801    let local_var_req = local_var_req_builder.build()?;
802    let local_var_resp = local_var_client.execute(local_var_req).await?;
803
804    let local_var_status = local_var_resp.status();
805    let local_var_content = local_var_resp.text().await?;
806
807    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
808        serde_json::from_str(&local_var_content).map_err(Error::from)
809    } else {
810        let local_var_entity: Option<DevicesKnowndeviceEmailIdentifierGetError> =
811            serde_json::from_str(&local_var_content).ok();
812        let local_var_error = ResponseContent {
813            status: local_var_status,
814            content: local_var_content,
815            entity: local_var_entity,
816        };
817        Err(Error::ResponseError(local_var_error))
818    }
819}
820
821pub async fn devices_knowndevice_get(
822    configuration: &configuration::Configuration,
823    x_request_email: &str,
824    x_device_identifier: &str,
825) -> Result<bool, Error<DevicesKnowndeviceGetError>> {
826    let local_var_configuration = configuration;
827
828    let local_var_client = &local_var_configuration.client;
829
830    let local_var_uri_str = format!("{}/devices/knowndevice", local_var_configuration.base_path);
831    let mut local_var_req_builder =
832        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
833
834    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
835        local_var_req_builder =
836            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
837    }
838    local_var_req_builder =
839        local_var_req_builder.header("x-Request-Email", x_request_email.to_string());
840    local_var_req_builder =
841        local_var_req_builder.header("x-Device-Identifier", x_device_identifier.to_string());
842    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
843        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
844    };
845
846    let local_var_req = local_var_req_builder.build()?;
847    let local_var_resp = local_var_client.execute(local_var_req).await?;
848
849    let local_var_status = local_var_resp.status();
850    let local_var_content = local_var_resp.text().await?;
851
852    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
853        serde_json::from_str(&local_var_content).map_err(Error::from)
854    } else {
855        let local_var_entity: Option<DevicesKnowndeviceGetError> =
856            serde_json::from_str(&local_var_content).ok();
857        let local_var_error = ResponseContent {
858            status: local_var_status,
859            content: local_var_content,
860            entity: local_var_entity,
861        };
862        Err(Error::ResponseError(local_var_error))
863    }
864}
865
866pub async fn devices_lost_trust_post(
867    configuration: &configuration::Configuration,
868) -> Result<(), Error<DevicesLostTrustPostError>> {
869    let local_var_configuration = configuration;
870
871    let local_var_client = &local_var_configuration.client;
872
873    let local_var_uri_str = format!("{}/devices/lost-trust", local_var_configuration.base_path);
874    let mut local_var_req_builder =
875        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
876
877    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
878        local_var_req_builder =
879            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
880    }
881    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
882        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
883    };
884
885    let local_var_req = local_var_req_builder.build()?;
886    let local_var_resp = local_var_client.execute(local_var_req).await?;
887
888    let local_var_status = local_var_resp.status();
889    let local_var_content = local_var_resp.text().await?;
890
891    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
892        Ok(())
893    } else {
894        let local_var_entity: Option<DevicesLostTrustPostError> =
895            serde_json::from_str(&local_var_content).ok();
896        let local_var_error = ResponseContent {
897            status: local_var_status,
898            content: local_var_content,
899            entity: local_var_entity,
900        };
901        Err(Error::ResponseError(local_var_error))
902    }
903}
904
905pub async fn devices_post(
906    configuration: &configuration::Configuration,
907    device_request_model: Option<models::DeviceRequestModel>,
908) -> Result<models::DeviceResponseModel, Error<DevicesPostError>> {
909    let local_var_configuration = configuration;
910
911    let local_var_client = &local_var_configuration.client;
912
913    let local_var_uri_str = format!("{}/devices", local_var_configuration.base_path);
914    let mut local_var_req_builder =
915        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
916
917    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
918        local_var_req_builder =
919            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
920    }
921    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
922        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
923    };
924    local_var_req_builder = local_var_req_builder.json(&device_request_model);
925
926    let local_var_req = local_var_req_builder.build()?;
927    let local_var_resp = local_var_client.execute(local_var_req).await?;
928
929    let local_var_status = local_var_resp.status();
930    let local_var_content = local_var_resp.text().await?;
931
932    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
933        serde_json::from_str(&local_var_content).map_err(Error::from)
934    } else {
935        let local_var_entity: Option<DevicesPostError> =
936            serde_json::from_str(&local_var_content).ok();
937        let local_var_error = ResponseContent {
938            status: local_var_status,
939            content: local_var_content,
940            entity: local_var_entity,
941        };
942        Err(Error::ResponseError(local_var_error))
943    }
944}
945
946pub async fn devices_update_trust_post(
947    configuration: &configuration::Configuration,
948    update_devices_trust_request_model: Option<models::UpdateDevicesTrustRequestModel>,
949) -> Result<(), Error<DevicesUpdateTrustPostError>> {
950    let local_var_configuration = configuration;
951
952    let local_var_client = &local_var_configuration.client;
953
954    let local_var_uri_str = format!("{}/devices/update-trust", local_var_configuration.base_path);
955    let mut local_var_req_builder =
956        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
957
958    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
959        local_var_req_builder =
960            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
961    }
962    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
963        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
964    };
965    local_var_req_builder = local_var_req_builder.json(&update_devices_trust_request_model);
966
967    let local_var_req = local_var_req_builder.build()?;
968    let local_var_resp = local_var_client.execute(local_var_req).await?;
969
970    let local_var_status = local_var_resp.status();
971    let local_var_content = local_var_resp.text().await?;
972
973    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
974        Ok(())
975    } else {
976        let local_var_entity: Option<DevicesUpdateTrustPostError> =
977            serde_json::from_str(&local_var_content).ok();
978        let local_var_error = ResponseContent {
979            status: local_var_status,
980            content: local_var_content,
981            entity: local_var_entity,
982        };
983        Err(Error::ResponseError(local_var_error))
984    }
985}