bitwarden_api_api/apis/
info_api.rs1use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AliveGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum IpGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum NowGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum VersionGetError {
42 UnknownValue(serde_json::Value),
43}
44
45pub async fn alive_get(
46 configuration: &configuration::Configuration,
47) -> Result<String, Error<AliveGetError>> {
48 let local_var_configuration = configuration;
49
50 let local_var_client = &local_var_configuration.client;
51
52 let local_var_uri_str = format!("{}/alive", local_var_configuration.base_path);
53 let mut local_var_req_builder =
54 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
55
56 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57 local_var_req_builder =
58 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
59 }
60 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
61 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
62 };
63
64 let local_var_req = local_var_req_builder.build()?;
65 let local_var_resp = local_var_client.execute(local_var_req).await?;
66
67 let local_var_status = local_var_resp.status();
68 let local_var_content = local_var_resp.text().await?;
69
70 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
71 serde_json::from_str(&local_var_content).map_err(Error::from)
72 } else {
73 let local_var_entity: Option<AliveGetError> = serde_json::from_str(&local_var_content).ok();
74 let local_var_error = ResponseContent {
75 status: local_var_status,
76 content: local_var_content,
77 entity: local_var_entity,
78 };
79 Err(Error::ResponseError(local_var_error))
80 }
81}
82
83pub async fn ip_get(configuration: &configuration::Configuration) -> Result<(), Error<IpGetError>> {
84 let local_var_configuration = configuration;
85
86 let local_var_client = &local_var_configuration.client;
87
88 let local_var_uri_str = format!("{}/ip", local_var_configuration.base_path);
89 let mut local_var_req_builder =
90 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
91
92 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
93 local_var_req_builder =
94 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
95 }
96 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
97 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
98 };
99
100 let local_var_req = local_var_req_builder.build()?;
101 let local_var_resp = local_var_client.execute(local_var_req).await?;
102
103 let local_var_status = local_var_resp.status();
104 let local_var_content = local_var_resp.text().await?;
105
106 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
107 Ok(())
108 } else {
109 let local_var_entity: Option<IpGetError> = serde_json::from_str(&local_var_content).ok();
110 let local_var_error = ResponseContent {
111 status: local_var_status,
112 content: local_var_content,
113 entity: local_var_entity,
114 };
115 Err(Error::ResponseError(local_var_error))
116 }
117}
118
119pub async fn now_get(
120 configuration: &configuration::Configuration,
121) -> Result<String, Error<NowGetError>> {
122 let local_var_configuration = configuration;
123
124 let local_var_client = &local_var_configuration.client;
125
126 let local_var_uri_str = format!("{}/now", local_var_configuration.base_path);
127 let mut local_var_req_builder =
128 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
129
130 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
131 local_var_req_builder =
132 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
133 }
134 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
135 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
136 };
137
138 let local_var_req = local_var_req_builder.build()?;
139 let local_var_resp = local_var_client.execute(local_var_req).await?;
140
141 let local_var_status = local_var_resp.status();
142 let local_var_content = local_var_resp.text().await?;
143
144 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
145 serde_json::from_str(&local_var_content).map_err(Error::from)
146 } else {
147 let local_var_entity: Option<NowGetError> = serde_json::from_str(&local_var_content).ok();
148 let local_var_error = ResponseContent {
149 status: local_var_status,
150 content: local_var_content,
151 entity: local_var_entity,
152 };
153 Err(Error::ResponseError(local_var_error))
154 }
155}
156
157pub async fn version_get(
158 configuration: &configuration::Configuration,
159) -> Result<(), Error<VersionGetError>> {
160 let local_var_configuration = configuration;
161
162 let local_var_client = &local_var_configuration.client;
163
164 let local_var_uri_str = format!("{}/version", local_var_configuration.base_path);
165 let mut local_var_req_builder =
166 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
167
168 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
169 local_var_req_builder =
170 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
171 }
172 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
173 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
174 };
175
176 let local_var_req = local_var_req_builder.build()?;
177 let local_var_resp = local_var_client.execute(local_var_req).await?;
178
179 let local_var_status = local_var_resp.status();
180 let local_var_content = local_var_resp.text().await?;
181
182 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
183 Ok(())
184 } else {
185 let local_var_entity: Option<VersionGetError> =
186 serde_json::from_str(&local_var_content).ok();
187 let local_var_error = ResponseContent {
188 status: local_var_status,
189 content: local_var_content,
190 entity: local_var_entity,
191 };
192 Err(Error::ResponseError(local_var_error))
193 }
194}