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