1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AccessCreateVncticketError {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AccessGetAccessError {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AccessGetPermissionsError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum AccessGetRolesError {
64 Status400(models::PbsError),
65 Status401(models::PbsError),
66 Status403(models::PbsError),
67 Status404(models::PbsError),
68 Status500(models::PbsError),
69 Status501(models::PbsError),
70 Status503(models::PbsError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AccessUpdatePasswordError {
78 Status400(models::PbsError),
79 Status401(models::PbsError),
80 Status403(models::PbsError),
81 Status404(models::PbsError),
82 Status500(models::PbsError),
83 Status501(models::PbsError),
84 Status503(models::PbsError),
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn access_create_vncticket(configuration: &configuration::Configuration, access_create_vncticket_request: models::AccessCreateVncticketRequest) -> Result<models::AccessCreateVncticketResponse, Error<AccessCreateVncticketError>> {
91 let p_body_access_create_vncticket_request = access_create_vncticket_request;
93
94 let uri_str = format!("{}/access/vncticket", configuration.base_path);
95 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
96
97 if let Some(ref user_agent) = configuration.user_agent {
98 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99 }
100 req_builder = req_builder.json(&p_body_access_create_vncticket_request);
101
102 let req = req_builder.build()?;
103 let resp = configuration.client.execute(req).await?;
104
105 let status = resp.status();
106 let content_type = resp
107 .headers()
108 .get("content-type")
109 .and_then(|v| v.to_str().ok())
110 .unwrap_or("application/octet-stream");
111 let content_type = super::ContentType::from(content_type);
112
113 if !status.is_client_error() && !status.is_server_error() {
114 let content = resp.text().await?;
115 match content_type {
116 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
117 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessCreateVncticketResponse`"))),
118 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessCreateVncticketResponse`")))),
119 }
120 } else {
121 let content = resp.text().await?;
122 let entity: Option<AccessCreateVncticketError> = serde_json::from_str(&content).ok();
123 Err(Error::ResponseError(ResponseContent { status, content, entity }))
124 }
125}
126
127pub async fn access_get_access(configuration: &configuration::Configuration, ) -> Result<models::AccessGetAccessResponse, Error<AccessGetAccessError>> {
129
130 let uri_str = format!("{}/access", configuration.base_path);
131 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
132
133 if let Some(ref user_agent) = configuration.user_agent {
134 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
135 }
136 if let Some(ref apikey) = configuration.api_key {
137 let key = apikey.key.clone();
138 let value = match apikey.prefix {
139 Some(ref prefix) => format!("{} {}", prefix, key),
140 None => key,
141 };
142 req_builder = req_builder.header("Authorization", value);
143 };
144 if let Some(ref apikey) = configuration.api_key {
145 let key = apikey.key.clone();
146 let value = match apikey.prefix {
147 Some(ref prefix) => format!("{} {}", prefix, key),
148 None => key,
149 };
150 req_builder = req_builder.header("CSRFPreventionToken", value);
151 };
152
153 let req = req_builder.build()?;
154 let resp = configuration.client.execute(req).await?;
155
156 let status = resp.status();
157 let content_type = resp
158 .headers()
159 .get("content-type")
160 .and_then(|v| v.to_str().ok())
161 .unwrap_or("application/octet-stream");
162 let content_type = super::ContentType::from(content_type);
163
164 if !status.is_client_error() && !status.is_server_error() {
165 let content = resp.text().await?;
166 match content_type {
167 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
168 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGetAccessResponse`"))),
169 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGetAccessResponse`")))),
170 }
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<AccessGetAccessError> = serde_json::from_str(&content).ok();
174 Err(Error::ResponseError(ResponseContent { status, content, entity }))
175 }
176}
177
178pub async fn access_get_permissions(configuration: &configuration::Configuration, auth_id: Option<&str>, path: Option<&str>) -> Result<models::AccessGetPermissionsResponse, Error<AccessGetPermissionsError>> {
180 let p_query_auth_id = auth_id;
182 let p_query_path = path;
183
184 let uri_str = format!("{}/access/permissions", configuration.base_path);
185 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
186
187 if let Some(ref param_value) = p_query_auth_id {
188 req_builder = req_builder.query(&[("auth-id", ¶m_value.to_string())]);
189 }
190 if let Some(ref param_value) = p_query_path {
191 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
192 }
193 if let Some(ref user_agent) = configuration.user_agent {
194 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
195 }
196 if let Some(ref apikey) = configuration.api_key {
197 let key = apikey.key.clone();
198 let value = match apikey.prefix {
199 Some(ref prefix) => format!("{} {}", prefix, key),
200 None => key,
201 };
202 req_builder = req_builder.header("Authorization", value);
203 };
204 if let Some(ref apikey) = configuration.api_key {
205 let key = apikey.key.clone();
206 let value = match apikey.prefix {
207 Some(ref prefix) => format!("{} {}", prefix, key),
208 None => key,
209 };
210 req_builder = req_builder.header("CSRFPreventionToken", value);
211 };
212
213 let req = req_builder.build()?;
214 let resp = configuration.client.execute(req).await?;
215
216 let status = resp.status();
217 let content_type = resp
218 .headers()
219 .get("content-type")
220 .and_then(|v| v.to_str().ok())
221 .unwrap_or("application/octet-stream");
222 let content_type = super::ContentType::from(content_type);
223
224 if !status.is_client_error() && !status.is_server_error() {
225 let content = resp.text().await?;
226 match content_type {
227 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
228 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGetPermissionsResponse`"))),
229 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGetPermissionsResponse`")))),
230 }
231 } else {
232 let content = resp.text().await?;
233 let entity: Option<AccessGetPermissionsError> = serde_json::from_str(&content).ok();
234 Err(Error::ResponseError(ResponseContent { status, content, entity }))
235 }
236}
237
238pub async fn access_get_roles(configuration: &configuration::Configuration, ) -> Result<models::AccessGetRolesResponse, Error<AccessGetRolesError>> {
240
241 let uri_str = format!("{}/access/roles", configuration.base_path);
242 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
243
244 if let Some(ref user_agent) = configuration.user_agent {
245 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
246 }
247 if let Some(ref apikey) = configuration.api_key {
248 let key = apikey.key.clone();
249 let value = match apikey.prefix {
250 Some(ref prefix) => format!("{} {}", prefix, key),
251 None => key,
252 };
253 req_builder = req_builder.header("Authorization", value);
254 };
255 if let Some(ref apikey) = configuration.api_key {
256 let key = apikey.key.clone();
257 let value = match apikey.prefix {
258 Some(ref prefix) => format!("{} {}", prefix, key),
259 None => key,
260 };
261 req_builder = req_builder.header("CSRFPreventionToken", value);
262 };
263
264 let req = req_builder.build()?;
265 let resp = configuration.client.execute(req).await?;
266
267 let status = resp.status();
268 let content_type = resp
269 .headers()
270 .get("content-type")
271 .and_then(|v| v.to_str().ok())
272 .unwrap_or("application/octet-stream");
273 let content_type = super::ContentType::from(content_type);
274
275 if !status.is_client_error() && !status.is_server_error() {
276 let content = resp.text().await?;
277 match content_type {
278 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
279 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessGetRolesResponse`"))),
280 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessGetRolesResponse`")))),
281 }
282 } else {
283 let content = resp.text().await?;
284 let entity: Option<AccessGetRolesError> = serde_json::from_str(&content).ok();
285 Err(Error::ResponseError(ResponseContent { status, content, entity }))
286 }
287}
288
289pub async fn access_update_password(configuration: &configuration::Configuration, access_update_password_request: models::AccessUpdatePasswordRequest) -> Result<models::AccessUpdatePasswordResponse, Error<AccessUpdatePasswordError>> {
291 let p_body_access_update_password_request = access_update_password_request;
293
294 let uri_str = format!("{}/access/password", configuration.base_path);
295 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
296
297 if let Some(ref user_agent) = configuration.user_agent {
298 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
299 }
300 if let Some(ref apikey) = configuration.api_key {
301 let key = apikey.key.clone();
302 let value = match apikey.prefix {
303 Some(ref prefix) => format!("{} {}", prefix, key),
304 None => key,
305 };
306 req_builder = req_builder.header("Authorization", value);
307 };
308 if let Some(ref apikey) = configuration.api_key {
309 let key = apikey.key.clone();
310 let value = match apikey.prefix {
311 Some(ref prefix) => format!("{} {}", prefix, key),
312 None => key,
313 };
314 req_builder = req_builder.header("CSRFPreventionToken", value);
315 };
316 req_builder = req_builder.json(&p_body_access_update_password_request);
317
318 let req = req_builder.build()?;
319 let resp = configuration.client.execute(req).await?;
320
321 let status = resp.status();
322 let content_type = resp
323 .headers()
324 .get("content-type")
325 .and_then(|v| v.to_str().ok())
326 .unwrap_or("application/octet-stream");
327 let content_type = super::ContentType::from(content_type);
328
329 if !status.is_client_error() && !status.is_server_error() {
330 let content = resp.text().await?;
331 match content_type {
332 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
333 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUpdatePasswordResponse`"))),
334 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUpdatePasswordResponse`")))),
335 }
336 } else {
337 let content = resp.text().await?;
338 let entity: Option<AccessUpdatePasswordError> = serde_json::from_str(&content).ok();
339 Err(Error::ResponseError(ResponseContent { status, content, entity }))
340 }
341}
342