windmill_api/apis/
config_api.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.539.1
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_config`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteConfigError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_config`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetConfigError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`list_autoscaling_events`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListAutoscalingEventsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_available_python_versions`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListAvailablePythonVersionsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_configs`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListConfigsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_worker_groups`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListWorkerGroupsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`native_kubernetes_autoscaling_healthcheck`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum NativeKubernetesAutoscalingHealthcheckError {
64    Status400(String),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`update_config`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum UpdateConfigError {
72    UnknownValue(serde_json::Value),
73}
74
75
76pub async fn delete_config(configuration: &configuration::Configuration, name: &str) -> Result<String, Error<DeleteConfigError>> {
77    let local_var_configuration = configuration;
78
79    let local_var_client = &local_var_configuration.client;
80
81    let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
82    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
86    }
87    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
88        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
89    };
90
91    let local_var_req = local_var_req_builder.build()?;
92    let local_var_resp = local_var_client.execute(local_var_req).await?;
93
94    let local_var_status = local_var_resp.status();
95    let local_var_content = local_var_resp.text().await?;
96
97    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
98        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
99    } else {
100        let local_var_entity: Option<DeleteConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
101        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
102        Err(Error::ResponseError(local_var_error))
103    }
104}
105
106pub async fn get_config(configuration: &configuration::Configuration, name: &str) -> Result<models::Configs, Error<GetConfigError>> {
107    let local_var_configuration = configuration;
108
109    let local_var_client = &local_var_configuration.client;
110
111    let local_var_uri_str = format!("{}/configs/get/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
112    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
113
114    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
115        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
116    }
117    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
118        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
119    };
120
121    let local_var_req = local_var_req_builder.build()?;
122    let local_var_resp = local_var_client.execute(local_var_req).await?;
123
124    let local_var_status = local_var_resp.status();
125    let local_var_content = local_var_resp.text().await?;
126
127    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
129    } else {
130        let local_var_entity: Option<GetConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
131        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
132        Err(Error::ResponseError(local_var_error))
133    }
134}
135
136pub async fn list_autoscaling_events(configuration: &configuration::Configuration, worker_group: &str) -> Result<Vec<models::AutoscalingEvent>, Error<ListAutoscalingEventsError>> {
137    let local_var_configuration = configuration;
138
139    let local_var_client = &local_var_configuration.client;
140
141    let local_var_uri_str = format!("{}/configs/list_autoscaling_events/{worker_group}", local_var_configuration.base_path, worker_group=crate::apis::urlencode(worker_group));
142    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
143
144    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
146    }
147    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
148        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
149    };
150
151    let local_var_req = local_var_req_builder.build()?;
152    let local_var_resp = local_var_client.execute(local_var_req).await?;
153
154    let local_var_status = local_var_resp.status();
155    let local_var_content = local_var_resp.text().await?;
156
157    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
158        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
159    } else {
160        let local_var_entity: Option<ListAutoscalingEventsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
161        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
162        Err(Error::ResponseError(local_var_error))
163    }
164}
165
166pub async fn list_available_python_versions(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListAvailablePythonVersionsError>> {
167    let local_var_configuration = configuration;
168
169    let local_var_client = &local_var_configuration.client;
170
171    let local_var_uri_str = format!("{}/configs/list_available_python_versions", local_var_configuration.base_path);
172    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
173
174    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
175        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
176    }
177    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
178        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
179    };
180
181    let local_var_req = local_var_req_builder.build()?;
182    let local_var_resp = local_var_client.execute(local_var_req).await?;
183
184    let local_var_status = local_var_resp.status();
185    let local_var_content = local_var_resp.text().await?;
186
187    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
188        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
189    } else {
190        let local_var_entity: Option<ListAvailablePythonVersionsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
191        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
192        Err(Error::ResponseError(local_var_error))
193    }
194}
195
196pub async fn list_configs(configuration: &configuration::Configuration, ) -> Result<Vec<models::Config>, Error<ListConfigsError>> {
197    let local_var_configuration = configuration;
198
199    let local_var_client = &local_var_configuration.client;
200
201    let local_var_uri_str = format!("{}/configs/list", local_var_configuration.base_path);
202    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
203
204    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210
211    let local_var_req = local_var_req_builder.build()?;
212    let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214    let local_var_status = local_var_resp.status();
215    let local_var_content = local_var_resp.text().await?;
216
217    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
219    } else {
220        let local_var_entity: Option<ListConfigsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
221        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222        Err(Error::ResponseError(local_var_error))
223    }
224}
225
226pub async fn list_worker_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListWorkerGroups200ResponseInner>, Error<ListWorkerGroupsError>> {
227    let local_var_configuration = configuration;
228
229    let local_var_client = &local_var_configuration.client;
230
231    let local_var_uri_str = format!("{}/configs/list_worker_groups", local_var_configuration.base_path);
232    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
233
234    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
235        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
236    }
237    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
238        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
239    };
240
241    let local_var_req = local_var_req_builder.build()?;
242    let local_var_resp = local_var_client.execute(local_var_req).await?;
243
244    let local_var_status = local_var_resp.status();
245    let local_var_content = local_var_resp.text().await?;
246
247    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
248        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
249    } else {
250        let local_var_entity: Option<ListWorkerGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
251        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
252        Err(Error::ResponseError(local_var_error))
253    }
254}
255
256pub async fn native_kubernetes_autoscaling_healthcheck(configuration: &configuration::Configuration, ) -> Result<(), Error<NativeKubernetesAutoscalingHealthcheckError>> {
257    let local_var_configuration = configuration;
258
259    let local_var_client = &local_var_configuration.client;
260
261    let local_var_uri_str = format!("{}/configs/native_kubernetes_autoscaling_healthcheck", local_var_configuration.base_path);
262    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
263
264    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
265        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
266    }
267    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
268        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
269    };
270
271    let local_var_req = local_var_req_builder.build()?;
272    let local_var_resp = local_var_client.execute(local_var_req).await?;
273
274    let local_var_status = local_var_resp.status();
275    let local_var_content = local_var_resp.text().await?;
276
277    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
278        Ok(())
279    } else {
280        let local_var_entity: Option<NativeKubernetesAutoscalingHealthcheckError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
281        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
282        Err(Error::ResponseError(local_var_error))
283    }
284}
285
286pub async fn update_config(configuration: &configuration::Configuration, name: &str, body: Option<serde_json::Value>) -> Result<String, Error<UpdateConfigError>> {
287    let local_var_configuration = configuration;
288
289    let local_var_client = &local_var_configuration.client;
290
291    let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
292    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
293
294    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
295        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296    }
297    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
298        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
299    };
300    local_var_req_builder = local_var_req_builder.json(&body);
301
302    let local_var_req = local_var_req_builder.build()?;
303    let local_var_resp = local_var_client.execute(local_var_req).await?;
304
305    let local_var_status = local_var_resp.status();
306    let local_var_content = local_var_resp.text().await?;
307
308    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
309        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
310    } else {
311        let local_var_entity: Option<UpdateConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
312        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
313        Err(Error::ResponseError(local_var_error))
314    }
315}
316