hanzo_client/apis/
authz_api.rs1use 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 GetAuthzHealthError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetAuthzReadyzError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum PostAuthzCheckError {
36 UnknownValue(serde_json::Value),
37}
38
39
40pub async fn get_authz_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetAuthzHealthError>> {
42
43 let uri_str = format!("{}/v1/authz/health", configuration.base_path);
44 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
45
46 if let Some(ref user_agent) = configuration.user_agent {
47 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
48 }
49 if let Some(ref token) = configuration.bearer_access_token {
50 req_builder = req_builder.bearer_auth(token.to_owned());
51 };
52
53 let req = req_builder.build()?;
54 let resp = configuration.client.execute(req).await?;
55
56 let status = resp.status();
57
58 if !status.is_client_error() && !status.is_server_error() {
59 Ok(())
60 } else {
61 let content = resp.text().await?;
62 let entity: Option<GetAuthzHealthError> = serde_json::from_str(&content).ok();
63 Err(Error::ResponseError(ResponseContent { status, content, entity }))
64 }
65}
66
67pub async fn get_authz_readyz(configuration: &configuration::Configuration, ) -> Result<(), Error<GetAuthzReadyzError>> {
69
70 let uri_str = format!("{}/v1/authz/readyz", configuration.base_path);
71 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
72
73 if let Some(ref user_agent) = configuration.user_agent {
74 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75 }
76 if let Some(ref token) = configuration.bearer_access_token {
77 req_builder = req_builder.bearer_auth(token.to_owned());
78 };
79
80 let req = req_builder.build()?;
81 let resp = configuration.client.execute(req).await?;
82
83 let status = resp.status();
84
85 if !status.is_client_error() && !status.is_server_error() {
86 Ok(())
87 } else {
88 let content = resp.text().await?;
89 let entity: Option<GetAuthzReadyzError> = serde_json::from_str(&content).ok();
90 Err(Error::ResponseError(ResponseContent { status, content, entity }))
91 }
92}
93
94pub async fn post_authz_check(configuration: &configuration::Configuration, ) -> Result<(), Error<PostAuthzCheckError>> {
96
97 let uri_str = format!("{}/v1/authz/check", configuration.base_path);
98 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
99
100 if let Some(ref user_agent) = configuration.user_agent {
101 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
102 }
103 if let Some(ref token) = configuration.bearer_access_token {
104 req_builder = req_builder.bearer_auth(token.to_owned());
105 };
106
107 let req = req_builder.build()?;
108 let resp = configuration.client.execute(req).await?;
109
110 let status = resp.status();
111
112 if !status.is_client_error() && !status.is_server_error() {
113 Ok(())
114 } else {
115 let content = resp.text().await?;
116 let entity: Option<PostAuthzCheckError> = serde_json::from_str(&content).ok();
117 Err(Error::ResponseError(ResponseContent { status, content, entity }))
118 }
119}
120