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