Skip to main content

bitwarden_api_api/apis/
installations_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 std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait InstallationsApi: Send + Sync {
29    /// GET /installations/{id}
30    async fn get<'a>(&self, id: uuid::Uuid) -> Result<models::InstallationResponseModel, Error>;
31
32    /// POST /installations
33    async fn post<'a>(
34        &self,
35        installation_request_model: Option<models::InstallationRequestModel>,
36    ) -> Result<models::InstallationResponseModel, Error>;
37}
38
39pub struct InstallationsApiClient {
40    configuration: Arc<configuration::Configuration>,
41}
42
43impl InstallationsApiClient {
44    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
45        Self { configuration }
46    }
47}
48
49#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
50#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
51impl InstallationsApi for InstallationsApiClient {
52    async fn get<'a>(&self, id: uuid::Uuid) -> Result<models::InstallationResponseModel, Error> {
53        let local_var_configuration = &self.configuration;
54
55        let local_var_client = &local_var_configuration.client;
56
57        let local_var_uri_str = format!(
58            "{}/installations/{id}",
59            local_var_configuration.base_path,
60            id = id
61        );
62        let mut local_var_req_builder =
63            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
64
65        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
66
67        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
68    }
69
70    async fn post<'a>(
71        &self,
72        installation_request_model: Option<models::InstallationRequestModel>,
73    ) -> Result<models::InstallationResponseModel, Error> {
74        let local_var_configuration = &self.configuration;
75
76        let local_var_client = &local_var_configuration.client;
77
78        let local_var_uri_str = format!("{}/installations", local_var_configuration.base_path);
79        let mut local_var_req_builder =
80            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
81
82        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
83        local_var_req_builder = local_var_req_builder.json(&installation_request_model);
84
85        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
86    }
87}