windmill_api/apis/
agent_workers_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BlacklistAgentTokenError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateAgentTokenError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetMinVersionError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListBlacklistedAgentTokensError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum RemoveBlacklistAgentTokenError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn blacklist_agent_token(configuration: &configuration::Configuration, blacklist_agent_token_request: models::BlacklistAgentTokenRequest) -> Result<(), Error<BlacklistAgentTokenError>> {
55 let local_var_configuration = configuration;
56
57 let local_var_client = &local_var_configuration.client;
58
59 let local_var_uri_str = format!("{}/agent_workers/blacklist_token", local_var_configuration.base_path);
60 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
61
62 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
63 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
64 }
65 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
66 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
67 };
68 local_var_req_builder = local_var_req_builder.json(&blacklist_agent_token_request);
69
70 let local_var_req = local_var_req_builder.build()?;
71 let local_var_resp = local_var_client.execute(local_var_req).await?;
72
73 let local_var_status = local_var_resp.status();
74 let local_var_content = local_var_resp.text().await?;
75
76 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
77 Ok(())
78 } else {
79 let local_var_entity: Option<BlacklistAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
80 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
81 Err(Error::ResponseError(local_var_error))
82 }
83}
84
85pub async fn create_agent_token(configuration: &configuration::Configuration, create_agent_token_request: models::CreateAgentTokenRequest) -> Result<String, Error<CreateAgentTokenError>> {
86 let local_var_configuration = configuration;
87
88 let local_var_client = &local_var_configuration.client;
89
90 let local_var_uri_str = format!("{}/agent_workers/create_agent_token", local_var_configuration.base_path);
91 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
92
93 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
94 local_var_req_builder = 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.bearer_access_token {
97 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
98 };
99 local_var_req_builder = local_var_req_builder.json(&create_agent_token_request);
100
101 let local_var_req = local_var_req_builder.build()?;
102 let local_var_resp = local_var_client.execute(local_var_req).await?;
103
104 let local_var_status = local_var_resp.status();
105 let local_var_content = local_var_resp.text().await?;
106
107 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
108 crate::from_str_patched(&local_var_content).map_err(Error::from)
109 } else {
110 let local_var_entity: Option<CreateAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
111 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
112 Err(Error::ResponseError(local_var_error))
113 }
114}
115
116pub async fn get_min_version(configuration: &configuration::Configuration, ) -> Result<String, Error<GetMinVersionError>> {
117 let local_var_configuration = configuration;
118
119 let local_var_client = &local_var_configuration.client;
120
121 let local_var_uri_str = format!("{}/agent_workers/get_min_version", local_var_configuration.base_path);
122 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
125 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
126 }
127 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
128 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
129 };
130
131 let local_var_req = local_var_req_builder.build()?;
132 let local_var_resp = local_var_client.execute(local_var_req).await?;
133
134 let local_var_status = local_var_resp.status();
135 let local_var_content = local_var_resp.text().await?;
136
137 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
138 crate::from_str_patched(&local_var_content).map_err(Error::from)
139 } else {
140 let local_var_entity: Option<GetMinVersionError> = crate::from_str_patched(&local_var_content).ok();
141 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
142 Err(Error::ResponseError(local_var_error))
143 }
144}
145
146pub async fn list_blacklisted_agent_tokens(configuration: &configuration::Configuration, include_expired: Option<bool>) -> Result<Vec<models::ListBlacklistedAgentTokens200ResponseInner>, Error<ListBlacklistedAgentTokensError>> {
147 let local_var_configuration = configuration;
148
149 let local_var_client = &local_var_configuration.client;
150
151 let local_var_uri_str = format!("{}/agent_workers/list_blacklisted_tokens", local_var_configuration.base_path);
152 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
153
154 if let Some(ref local_var_str) = include_expired {
155 local_var_req_builder = local_var_req_builder.query(&[("include_expired", &local_var_str.to_string())]);
156 }
157 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
159 }
160 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
161 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
162 };
163
164 let local_var_req = local_var_req_builder.build()?;
165 let local_var_resp = local_var_client.execute(local_var_req).await?;
166
167 let local_var_status = local_var_resp.status();
168 let local_var_content = local_var_resp.text().await?;
169
170 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
171 crate::from_str_patched(&local_var_content).map_err(Error::from)
172 } else {
173 let local_var_entity: Option<ListBlacklistedAgentTokensError> = crate::from_str_patched(&local_var_content).ok();
174 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
175 Err(Error::ResponseError(local_var_error))
176 }
177}
178
179pub async fn remove_blacklist_agent_token(configuration: &configuration::Configuration, remove_blacklist_agent_token_request: models::RemoveBlacklistAgentTokenRequest) -> Result<(), Error<RemoveBlacklistAgentTokenError>> {
180 let local_var_configuration = configuration;
181
182 let local_var_client = &local_var_configuration.client;
183
184 let local_var_uri_str = format!("{}/agent_workers/remove_blacklist_token", local_var_configuration.base_path);
185 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
186
187 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
188 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
189 }
190 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
191 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
192 };
193 local_var_req_builder = local_var_req_builder.json(&remove_blacklist_agent_token_request);
194
195 let local_var_req = local_var_req_builder.build()?;
196 let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198 let local_var_status = local_var_resp.status();
199 let local_var_content = local_var_resp.text().await?;
200
201 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202 Ok(())
203 } else {
204 let local_var_entity: Option<RemoveBlacklistAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
205 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206 Err(Error::ResponseError(local_var_error))
207 }
208}
209