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 ListBlacklistedAgentTokensError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RemoveBlacklistAgentTokenError {
43 UnknownValue(serde_json::Value),
44}
45
46
47pub async fn blacklist_agent_token(configuration: &configuration::Configuration, blacklist_agent_token_request: models::BlacklistAgentTokenRequest) -> Result<(), Error<BlacklistAgentTokenError>> {
48 let local_var_configuration = configuration;
49
50 let local_var_client = &local_var_configuration.client;
51
52 let local_var_uri_str = format!("{}/agent_workers/blacklist_token", local_var_configuration.base_path);
53 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
54
55 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57 }
58 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60 };
61 local_var_req_builder = local_var_req_builder.json(&blacklist_agent_token_request);
62
63 let local_var_req = local_var_req_builder.build()?;
64 let local_var_resp = local_var_client.execute(local_var_req).await?;
65
66 let local_var_status = local_var_resp.status();
67 let local_var_content = local_var_resp.text().await?;
68
69 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
70 Ok(())
71 } else {
72 let local_var_entity: Option<BlacklistAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
73 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
74 Err(Error::ResponseError(local_var_error))
75 }
76}
77
78pub async fn create_agent_token(configuration: &configuration::Configuration, create_agent_token_request: models::CreateAgentTokenRequest) -> Result<String, Error<CreateAgentTokenError>> {
79 let local_var_configuration = configuration;
80
81 let local_var_client = &local_var_configuration.client;
82
83 let local_var_uri_str = format!("{}/agent_workers/create_agent_token", local_var_configuration.base_path);
84 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
85
86 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88 }
89 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
90 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
91 };
92 local_var_req_builder = local_var_req_builder.json(&create_agent_token_request);
93
94 let local_var_req = local_var_req_builder.build()?;
95 let local_var_resp = local_var_client.execute(local_var_req).await?;
96
97 let local_var_status = local_var_resp.status();
98 let local_var_content = local_var_resp.text().await?;
99
100 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
101 crate::from_str_patched(&local_var_content).map_err(Error::from)
102 } else {
103 let local_var_entity: Option<CreateAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
104 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
105 Err(Error::ResponseError(local_var_error))
106 }
107}
108
109pub async fn list_blacklisted_agent_tokens(configuration: &configuration::Configuration, include_expired: Option<bool>) -> Result<Vec<models::ListBlacklistedAgentTokens200ResponseInner>, Error<ListBlacklistedAgentTokensError>> {
110 let local_var_configuration = configuration;
111
112 let local_var_client = &local_var_configuration.client;
113
114 let local_var_uri_str = format!("{}/agent_workers/list_blacklisted_tokens", local_var_configuration.base_path);
115 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
116
117 if let Some(ref local_var_str) = include_expired {
118 local_var_req_builder = local_var_req_builder.query(&[("include_expired", &local_var_str.to_string())]);
119 }
120 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
121 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
122 }
123 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
124 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
125 };
126
127 let local_var_req = local_var_req_builder.build()?;
128 let local_var_resp = local_var_client.execute(local_var_req).await?;
129
130 let local_var_status = local_var_resp.status();
131 let local_var_content = local_var_resp.text().await?;
132
133 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
134 crate::from_str_patched(&local_var_content).map_err(Error::from)
135 } else {
136 let local_var_entity: Option<ListBlacklistedAgentTokensError> = crate::from_str_patched(&local_var_content).ok();
137 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
138 Err(Error::ResponseError(local_var_error))
139 }
140}
141
142pub async fn remove_blacklist_agent_token(configuration: &configuration::Configuration, remove_blacklist_agent_token_request: models::RemoveBlacklistAgentTokenRequest) -> Result<(), Error<RemoveBlacklistAgentTokenError>> {
143 let local_var_configuration = configuration;
144
145 let local_var_client = &local_var_configuration.client;
146
147 let local_var_uri_str = format!("{}/agent_workers/remove_blacklist_token", local_var_configuration.base_path);
148 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
149
150 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
151 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
152 }
153 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
154 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
155 };
156 local_var_req_builder = local_var_req_builder.json(&remove_blacklist_agent_token_request);
157
158 let local_var_req = local_var_req_builder.build()?;
159 let local_var_resp = local_var_client.execute(local_var_req).await?;
160
161 let local_var_status = local_var_resp.status();
162 let local_var_content = local_var_resp.text().await?;
163
164 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
165 Ok(())
166 } else {
167 let local_var_entity: Option<RemoveBlacklistAgentTokenError> = crate::from_str_patched(&local_var_content).ok();
168 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
169 Err(Error::ResponseError(local_var_error))
170 }
171}
172