bitwarden_api_api/apis/
info_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 [`alive_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AliveGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`now_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum NowGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`version_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum VersionGetError {
35    UnknownValue(serde_json::Value),
36}
37
38pub async fn alive_get(
39    configuration: &configuration::Configuration,
40) -> Result<String, Error<AliveGetError>> {
41    let local_var_configuration = configuration;
42
43    let local_var_client = &local_var_configuration.client;
44
45    let local_var_uri_str = format!("{}/alive", local_var_configuration.base_path);
46    let mut local_var_req_builder =
47        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
48
49    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
50        local_var_req_builder =
51            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
52    }
53    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
54        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
55    };
56
57    let local_var_req = local_var_req_builder.build()?;
58    let local_var_resp = local_var_client.execute(local_var_req).await?;
59
60    let local_var_status = local_var_resp.status();
61    let local_var_content = local_var_resp.text().await?;
62
63    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
64        serde_json::from_str(&local_var_content).map_err(Error::from)
65    } else {
66        let local_var_entity: Option<AliveGetError> = serde_json::from_str(&local_var_content).ok();
67        let local_var_error = ResponseContent {
68            status: local_var_status,
69            content: local_var_content,
70            entity: local_var_entity,
71        };
72        Err(Error::ResponseError(local_var_error))
73    }
74}
75
76pub async fn now_get(
77    configuration: &configuration::Configuration,
78) -> Result<String, Error<NowGetError>> {
79    let local_var_configuration = configuration;
80
81    let local_var_client = &local_var_configuration.client;
82
83    let local_var_uri_str = format!("{}/now", local_var_configuration.base_path);
84    let mut local_var_req_builder =
85        local_var_client.request(reqwest::Method::GET, 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
95    let local_var_req = local_var_req_builder.build()?;
96    let local_var_resp = local_var_client.execute(local_var_req).await?;
97
98    let local_var_status = local_var_resp.status();
99    let local_var_content = local_var_resp.text().await?;
100
101    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
102        serde_json::from_str(&local_var_content).map_err(Error::from)
103    } else {
104        let local_var_entity: Option<NowGetError> = serde_json::from_str(&local_var_content).ok();
105        let local_var_error = ResponseContent {
106            status: local_var_status,
107            content: local_var_content,
108            entity: local_var_entity,
109        };
110        Err(Error::ResponseError(local_var_error))
111    }
112}
113
114pub async fn version_get(
115    configuration: &configuration::Configuration,
116) -> Result<(), Error<VersionGetError>> {
117    let local_var_configuration = configuration;
118
119    let local_var_client = &local_var_configuration.client;
120
121    let local_var_uri_str = format!("{}/version", local_var_configuration.base_path);
122    let mut local_var_req_builder =
123        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
124
125    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
126        local_var_req_builder =
127            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
128    }
129    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
130        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
131    };
132
133    let local_var_req = local_var_req_builder.build()?;
134    let local_var_resp = local_var_client.execute(local_var_req).await?;
135
136    let local_var_status = local_var_resp.status();
137    let local_var_content = local_var_resp.text().await?;
138
139    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
140        Ok(())
141    } else {
142        let local_var_entity: Option<VersionGetError> =
143            serde_json::from_str(&local_var_content).ok();
144        let local_var_error = ResponseContent {
145            status: local_var_status,
146            content: local_var_content,
147            entity: local_var_entity,
148        };
149        Err(Error::ResponseError(local_var_error))
150    }
151}