bitwarden_api_identity/apis/
info_api.rs

1/*
2 * Bitwarden Identity
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: v1
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
54    let local_var_req = local_var_req_builder.build()?;
55    let local_var_resp = local_var_client.execute(local_var_req).await?;
56
57    let local_var_status = local_var_resp.status();
58    let local_var_content = local_var_resp.text().await?;
59
60    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
61        serde_json::from_str(&local_var_content).map_err(Error::from)
62    } else {
63        let local_var_entity: Option<AliveGetError> = serde_json::from_str(&local_var_content).ok();
64        let local_var_error = ResponseContent {
65            status: local_var_status,
66            content: local_var_content,
67            entity: local_var_entity,
68        };
69        Err(Error::ResponseError(local_var_error))
70    }
71}
72
73pub async fn now_get(
74    configuration: &configuration::Configuration,
75) -> Result<String, Error<NowGetError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!("{}/now", local_var_configuration.base_path);
81    let mut local_var_req_builder =
82        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder =
86            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
87    }
88
89    let local_var_req = local_var_req_builder.build()?;
90    let local_var_resp = local_var_client.execute(local_var_req).await?;
91
92    let local_var_status = local_var_resp.status();
93    let local_var_content = local_var_resp.text().await?;
94
95    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
96        serde_json::from_str(&local_var_content).map_err(Error::from)
97    } else {
98        let local_var_entity: Option<NowGetError> = serde_json::from_str(&local_var_content).ok();
99        let local_var_error = ResponseContent {
100            status: local_var_status,
101            content: local_var_content,
102            entity: local_var_entity,
103        };
104        Err(Error::ResponseError(local_var_error))
105    }
106}
107
108pub async fn version_get(
109    configuration: &configuration::Configuration,
110) -> Result<(), Error<VersionGetError>> {
111    let local_var_configuration = configuration;
112
113    let local_var_client = &local_var_configuration.client;
114
115    let local_var_uri_str = format!("{}/version", local_var_configuration.base_path);
116    let mut local_var_req_builder =
117        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
118
119    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
120        local_var_req_builder =
121            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
122    }
123
124    let local_var_req = local_var_req_builder.build()?;
125    let local_var_resp = local_var_client.execute(local_var_req).await?;
126
127    let local_var_status = local_var_resp.status();
128    let local_var_content = local_var_resp.text().await?;
129
130    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
131        Ok(())
132    } else {
133        let local_var_entity: Option<VersionGetError> =
134            serde_json::from_str(&local_var_content).ok();
135        let local_var_error = ResponseContent {
136            status: local_var_status,
137            content: local_var_content,
138            entity: local_var_entity,
139        };
140        Err(Error::ResponseError(local_var_error))
141    }
142}