windmill_api/apis/
config_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 DeleteConfigError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetConfigError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListAutoscalingEventsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListAvailablePythonVersionsError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListConfigsError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListWorkerGroupsError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum UpdateConfigError {
64 UnknownValue(serde_json::Value),
65}
66
67
68pub async fn delete_config(configuration: &configuration::Configuration, name: &str) -> Result<String, Error<DeleteConfigError>> {
69 let local_var_configuration = configuration;
70
71 let local_var_client = &local_var_configuration.client;
72
73 let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
74 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
75
76 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
77 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
78 }
79 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
80 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
81 };
82
83 let local_var_req = local_var_req_builder.build()?;
84 let local_var_resp = local_var_client.execute(local_var_req).await?;
85
86 let local_var_status = local_var_resp.status();
87 let local_var_content = local_var_resp.text().await?;
88
89 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
90 crate::from_str_patched(&local_var_content).map_err(Error::from)
91 } else {
92 let local_var_entity: Option<DeleteConfigError> = crate::from_str_patched(&local_var_content).ok();
93 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
94 Err(Error::ResponseError(local_var_error))
95 }
96}
97
98pub async fn get_config(configuration: &configuration::Configuration, name: &str) -> Result<models::Configs, Error<GetConfigError>> {
99 let local_var_configuration = configuration;
100
101 let local_var_client = &local_var_configuration.client;
102
103 let local_var_uri_str = format!("{}/configs/get/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
104 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
105
106 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
107 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
108 }
109 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
110 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
111 };
112
113 let local_var_req = local_var_req_builder.build()?;
114 let local_var_resp = local_var_client.execute(local_var_req).await?;
115
116 let local_var_status = local_var_resp.status();
117 let local_var_content = local_var_resp.text().await?;
118
119 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
120 crate::from_str_patched(&local_var_content).map_err(Error::from)
121 } else {
122 let local_var_entity: Option<GetConfigError> = crate::from_str_patched(&local_var_content).ok();
123 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
124 Err(Error::ResponseError(local_var_error))
125 }
126}
127
128pub async fn list_autoscaling_events(configuration: &configuration::Configuration, worker_group: &str) -> Result<Vec<models::AutoscalingEvent>, Error<ListAutoscalingEventsError>> {
129 let local_var_configuration = configuration;
130
131 let local_var_client = &local_var_configuration.client;
132
133 let local_var_uri_str = format!("{}/configs/list_autoscaling_events/{worker_group}", local_var_configuration.base_path, worker_group=crate::apis::urlencode(worker_group));
134 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
135
136 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
137 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
138 }
139 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
140 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
141 };
142
143 let local_var_req = local_var_req_builder.build()?;
144 let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146 let local_var_status = local_var_resp.status();
147 let local_var_content = local_var_resp.text().await?;
148
149 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150 crate::from_str_patched(&local_var_content).map_err(Error::from)
151 } else {
152 let local_var_entity: Option<ListAutoscalingEventsError> = crate::from_str_patched(&local_var_content).ok();
153 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
154 Err(Error::ResponseError(local_var_error))
155 }
156}
157
158pub async fn list_available_python_versions(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListAvailablePythonVersionsError>> {
159 let local_var_configuration = configuration;
160
161 let local_var_client = &local_var_configuration.client;
162
163 let local_var_uri_str = format!("{}/configs/list_available_python_versions", local_var_configuration.base_path);
164 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
165
166 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
168 }
169 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
170 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
171 };
172
173 let local_var_req = local_var_req_builder.build()?;
174 let local_var_resp = local_var_client.execute(local_var_req).await?;
175
176 let local_var_status = local_var_resp.status();
177 let local_var_content = local_var_resp.text().await?;
178
179 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180 crate::from_str_patched(&local_var_content).map_err(Error::from)
181 } else {
182 let local_var_entity: Option<ListAvailablePythonVersionsError> = crate::from_str_patched(&local_var_content).ok();
183 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184 Err(Error::ResponseError(local_var_error))
185 }
186}
187
188pub async fn list_configs(configuration: &configuration::Configuration, ) -> Result<Vec<models::Config>, Error<ListConfigsError>> {
189 let local_var_configuration = configuration;
190
191 let local_var_client = &local_var_configuration.client;
192
193 let local_var_uri_str = format!("{}/configs/list", local_var_configuration.base_path);
194 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
195
196 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
198 }
199 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
200 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
201 };
202
203 let local_var_req = local_var_req_builder.build()?;
204 let local_var_resp = local_var_client.execute(local_var_req).await?;
205
206 let local_var_status = local_var_resp.status();
207 let local_var_content = local_var_resp.text().await?;
208
209 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
210 crate::from_str_patched(&local_var_content).map_err(Error::from)
211 } else {
212 let local_var_entity: Option<ListConfigsError> = crate::from_str_patched(&local_var_content).ok();
213 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
214 Err(Error::ResponseError(local_var_error))
215 }
216}
217
218pub async fn list_worker_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListWorkerGroups200ResponseInner>, Error<ListWorkerGroupsError>> {
219 let local_var_configuration = configuration;
220
221 let local_var_client = &local_var_configuration.client;
222
223 let local_var_uri_str = format!("{}/configs/list_worker_groups", local_var_configuration.base_path);
224 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
225
226 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
227 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228 }
229 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
230 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
231 };
232
233 let local_var_req = local_var_req_builder.build()?;
234 let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236 let local_var_status = local_var_resp.status();
237 let local_var_content = local_var_resp.text().await?;
238
239 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240 crate::from_str_patched(&local_var_content).map_err(Error::from)
241 } else {
242 let local_var_entity: Option<ListWorkerGroupsError> = crate::from_str_patched(&local_var_content).ok();
243 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244 Err(Error::ResponseError(local_var_error))
245 }
246}
247
248pub async fn update_config(configuration: &configuration::Configuration, name: &str, body: Option<serde_json::Value>) -> Result<String, Error<UpdateConfigError>> {
249 let local_var_configuration = configuration;
250
251 let local_var_client = &local_var_configuration.client;
252
253 let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
254 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
258 }
259 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
260 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
261 };
262 local_var_req_builder = local_var_req_builder.json(&body);
263
264 let local_var_req = local_var_req_builder.build()?;
265 let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267 let local_var_status = local_var_resp.status();
268 let local_var_content = local_var_resp.text().await?;
269
270 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271 crate::from_str_patched(&local_var_content).map_err(Error::from)
272 } else {
273 let local_var_entity: Option<UpdateConfigError> = crate::from_str_patched(&local_var_content).ok();
274 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275 Err(Error::ResponseError(local_var_error))
276 }
277}
278