Skip to main content

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.675.0
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_all_dedicated_with_deps`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListAllDedicatedWithDepsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_all_workspace_dependencies`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListAllWorkspaceDependenciesError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_autoscaling_events`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListAutoscalingEventsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_available_python_versions`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListAvailablePythonVersionsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_configs`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListConfigsError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_worker_groups`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListWorkerGroupsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`native_kubernetes_autoscaling_healthcheck`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum NativeKubernetesAutoscalingHealthcheckError {
78    Status400(String),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`update_config`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum UpdateConfigError {
86    UnknownValue(serde_json::Value),
87}
88
89
90pub async fn delete_config(configuration: &configuration::Configuration, name: &str) -> Result<String, Error<DeleteConfigError>> {
91    let local_var_configuration = configuration;
92
93    let local_var_client = &local_var_configuration.client;
94
95    let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
96    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
97
98    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
99        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
102        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
103    };
104
105    let local_var_req = local_var_req_builder.build()?;
106    let local_var_resp = local_var_client.execute(local_var_req).await?;
107
108    let local_var_status = local_var_resp.status();
109    let local_var_content = local_var_resp.text().await?;
110
111    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
112        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
113    } else {
114        let local_var_entity: Option<DeleteConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
115        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
116        Err(Error::ResponseError(local_var_error))
117    }
118}
119
120pub async fn get_config(configuration: &configuration::Configuration, name: &str) -> Result<models::Configs, Error<GetConfigError>> {
121    let local_var_configuration = configuration;
122
123    let local_var_client = &local_var_configuration.client;
124
125    let local_var_uri_str = format!("{}/configs/get/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
126    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
127
128    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
129        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
130    }
131    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
132        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
133    };
134
135    let local_var_req = local_var_req_builder.build()?;
136    let local_var_resp = local_var_client.execute(local_var_req).await?;
137
138    let local_var_status = local_var_resp.status();
139    let local_var_content = local_var_resp.text().await?;
140
141    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
142        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
143    } else {
144        let local_var_entity: Option<GetConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
145        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
146        Err(Error::ResponseError(local_var_error))
147    }
148}
149
150pub async fn list_all_dedicated_with_deps(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListAllDedicatedWithDeps200ResponseInner>, Error<ListAllDedicatedWithDepsError>> {
151    let local_var_configuration = configuration;
152
153    let local_var_client = &local_var_configuration.client;
154
155    let local_var_uri_str = format!("{}/configs/list_all_dedicated_with_deps", local_var_configuration.base_path);
156    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
157
158    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
159        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160    }
161    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
162        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
163    };
164
165    let local_var_req = local_var_req_builder.build()?;
166    let local_var_resp = local_var_client.execute(local_var_req).await?;
167
168    let local_var_status = local_var_resp.status();
169    let local_var_content = local_var_resp.text().await?;
170
171    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
172        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
173    } else {
174        let local_var_entity: Option<ListAllDedicatedWithDepsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
175        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
176        Err(Error::ResponseError(local_var_error))
177    }
178}
179
180pub async fn list_all_workspace_dependencies(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListAllWorkspaceDependencies200ResponseInner>, Error<ListAllWorkspaceDependenciesError>> {
181    let local_var_configuration = configuration;
182
183    let local_var_client = &local_var_configuration.client;
184
185    let local_var_uri_str = format!("{}/configs/list_all_workspace_dependencies", local_var_configuration.base_path);
186    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
187
188    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
189        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
190    }
191    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
192        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
193    };
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        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
203    } else {
204        let local_var_entity: Option<ListAllWorkspaceDependenciesError> = crate::from_str_patched/* Externally injected from /build.nu */(&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
210pub async fn list_autoscaling_events(configuration: &configuration::Configuration, worker_group: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::AutoscalingEvent>, Error<ListAutoscalingEventsError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/configs/list_autoscaling_events/{worker_group}", local_var_configuration.base_path, worker_group=crate::apis::urlencode(worker_group));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_str) = page {
219        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
220    }
221    if let Some(ref local_var_str) = per_page {
222        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
223    }
224    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
225        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
226    }
227    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
228        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
229    };
230
231    let local_var_req = local_var_req_builder.build()?;
232    let local_var_resp = local_var_client.execute(local_var_req).await?;
233
234    let local_var_status = local_var_resp.status();
235    let local_var_content = local_var_resp.text().await?;
236
237    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
238        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
239    } else {
240        let local_var_entity: Option<ListAutoscalingEventsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
241        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
242        Err(Error::ResponseError(local_var_error))
243    }
244}
245
246pub async fn list_available_python_versions(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListAvailablePythonVersionsError>> {
247    let local_var_configuration = configuration;
248
249    let local_var_client = &local_var_configuration.client;
250
251    let local_var_uri_str = format!("{}/configs/list_available_python_versions", local_var_configuration.base_path);
252    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
253
254    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
255        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
256    }
257    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
258        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
259    };
260
261    let local_var_req = local_var_req_builder.build()?;
262    let local_var_resp = local_var_client.execute(local_var_req).await?;
263
264    let local_var_status = local_var_resp.status();
265    let local_var_content = local_var_resp.text().await?;
266
267    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
268        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
269    } else {
270        let local_var_entity: Option<ListAvailablePythonVersionsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
271        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
272        Err(Error::ResponseError(local_var_error))
273    }
274}
275
276pub async fn list_configs(configuration: &configuration::Configuration, ) -> Result<Vec<models::Config>, Error<ListConfigsError>> {
277    let local_var_configuration = configuration;
278
279    let local_var_client = &local_var_configuration.client;
280
281    let local_var_uri_str = format!("{}/configs/list", local_var_configuration.base_path);
282    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
283
284    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
285        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
286    }
287    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
288        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
289    };
290
291    let local_var_req = local_var_req_builder.build()?;
292    let local_var_resp = local_var_client.execute(local_var_req).await?;
293
294    let local_var_status = local_var_resp.status();
295    let local_var_content = local_var_resp.text().await?;
296
297    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
298        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
299    } else {
300        let local_var_entity: Option<ListConfigsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
301        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
302        Err(Error::ResponseError(local_var_error))
303    }
304}
305
306pub async fn list_worker_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListWorkerGroups200ResponseInner>, Error<ListWorkerGroupsError>> {
307    let local_var_configuration = configuration;
308
309    let local_var_client = &local_var_configuration.client;
310
311    let local_var_uri_str = format!("{}/configs/list_worker_groups", local_var_configuration.base_path);
312    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
313
314    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
315        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
316    }
317    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
318        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
319    };
320
321    let local_var_req = local_var_req_builder.build()?;
322    let local_var_resp = local_var_client.execute(local_var_req).await?;
323
324    let local_var_status = local_var_resp.status();
325    let local_var_content = local_var_resp.text().await?;
326
327    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
328        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
329    } else {
330        let local_var_entity: Option<ListWorkerGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
331        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
332        Err(Error::ResponseError(local_var_error))
333    }
334}
335
336pub async fn native_kubernetes_autoscaling_healthcheck(configuration: &configuration::Configuration, ) -> Result<(), Error<NativeKubernetesAutoscalingHealthcheckError>> {
337    let local_var_configuration = configuration;
338
339    let local_var_client = &local_var_configuration.client;
340
341    let local_var_uri_str = format!("{}/configs/native_kubernetes_autoscaling_healthcheck", local_var_configuration.base_path);
342    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
343
344    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
345        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346    }
347    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
348        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
349    };
350
351    let local_var_req = local_var_req_builder.build()?;
352    let local_var_resp = local_var_client.execute(local_var_req).await?;
353
354    let local_var_status = local_var_resp.status();
355    let local_var_content = local_var_resp.text().await?;
356
357    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358        Ok(())
359    } else {
360        let local_var_entity: Option<NativeKubernetesAutoscalingHealthcheckError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
361        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
362        Err(Error::ResponseError(local_var_error))
363    }
364}
365
366pub async fn update_config(configuration: &configuration::Configuration, name: &str, body: Option<serde_json::Value>) -> Result<String, Error<UpdateConfigError>> {
367    let local_var_configuration = configuration;
368
369    let local_var_client = &local_var_configuration.client;
370
371    let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
372    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
373
374    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
375        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
376    }
377    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
378        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
379    };
380    local_var_req_builder = local_var_req_builder.json(&body);
381
382    let local_var_req = local_var_req_builder.build()?;
383    let local_var_resp = local_var_client.execute(local_var_req).await?;
384
385    let local_var_status = local_var_resp.status();
386    let local_var_content = local_var_resp.text().await?;
387
388    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
389        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
390    } else {
391        let local_var_entity: Option<UpdateConfigError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
392        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
393        Err(Error::ResponseError(local_var_error))
394    }
395}
396