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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`installations_id_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum InstallationsIdGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`installations_post`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum InstallationsPostError {
28    UnknownValue(serde_json::Value),
29}
30
31pub async fn installations_id_get(
32    configuration: &configuration::Configuration,
33    id: uuid::Uuid,
34) -> Result<models::InstallationResponseModel, Error<InstallationsIdGetError>> {
35    let local_var_configuration = configuration;
36
37    let local_var_client = &local_var_configuration.client;
38
39    let local_var_uri_str = format!(
40        "{}/installations/{id}",
41        local_var_configuration.base_path,
42        id = crate::apis::urlencode(id.to_string())
43    );
44    let mut local_var_req_builder =
45        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
46
47    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
48        local_var_req_builder =
49            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
50    }
51    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
52        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
53    };
54
55    let local_var_req = local_var_req_builder.build()?;
56    let local_var_resp = local_var_client.execute(local_var_req).await?;
57
58    let local_var_status = local_var_resp.status();
59    let local_var_content = local_var_resp.text().await?;
60
61    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
62        serde_json::from_str(&local_var_content).map_err(Error::from)
63    } else {
64        let local_var_entity: Option<InstallationsIdGetError> =
65            serde_json::from_str(&local_var_content).ok();
66        let local_var_error = ResponseContent {
67            status: local_var_status,
68            content: local_var_content,
69            entity: local_var_entity,
70        };
71        Err(Error::ResponseError(local_var_error))
72    }
73}
74
75pub async fn installations_post(
76    configuration: &configuration::Configuration,
77    installation_request_model: Option<models::InstallationRequestModel>,
78) -> Result<models::InstallationResponseModel, Error<InstallationsPostError>> {
79    let local_var_configuration = configuration;
80
81    let local_var_client = &local_var_configuration.client;
82
83    let local_var_uri_str = format!("{}/installations", local_var_configuration.base_path);
84    let mut local_var_req_builder =
85        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
86
87    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
88        local_var_req_builder =
89            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
90    }
91    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
92        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
93    };
94    local_var_req_builder = local_var_req_builder.json(&installation_request_model);
95
96    let local_var_req = local_var_req_builder.build()?;
97    let local_var_resp = local_var_client.execute(local_var_req).await?;
98
99    let local_var_status = local_var_resp.status();
100    let local_var_content = local_var_resp.text().await?;
101
102    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
103        serde_json::from_str(&local_var_content).map_err(Error::from)
104    } else {
105        let local_var_entity: Option<InstallationsPostError> =
106            serde_json::from_str(&local_var_content).ok();
107        let local_var_error = ResponseContent {
108            status: local_var_status,
109            content: local_var_content,
110            entity: local_var_entity,
111        };
112        Err(Error::ResponseError(local_var_error))
113    }
114}