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