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 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 NativeKubernetesAutoscalingHealthcheckError {
64 Status400(String),
65 UnknownValue(serde_json::Value),
66}
67
68#[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(&local_var_content).map_err(Error::from)
99 } else {
100 let local_var_entity: Option<DeleteConfigError> = crate::from_str_patched(&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(&local_var_content).map_err(Error::from)
129 } else {
130 let local_var_entity: Option<GetConfigError> = crate::from_str_patched(&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, page: Option<i32>, per_page: Option<i32>) -> 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_str) = page {
145 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
146 }
147 if let Some(ref local_var_str) = per_page {
148 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
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
157 let local_var_req = local_var_req_builder.build()?;
158 let local_var_resp = local_var_client.execute(local_var_req).await?;
159
160 let local_var_status = local_var_resp.status();
161 let local_var_content = local_var_resp.text().await?;
162
163 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
164 crate::from_str_patched(&local_var_content).map_err(Error::from)
165 } else {
166 let local_var_entity: Option<ListAutoscalingEventsError> = crate::from_str_patched(&local_var_content).ok();
167 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
168 Err(Error::ResponseError(local_var_error))
169 }
170}
171
172pub async fn list_available_python_versions(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<ListAvailablePythonVersionsError>> {
173 let local_var_configuration = configuration;
174
175 let local_var_client = &local_var_configuration.client;
176
177 let local_var_uri_str = format!("{}/configs/list_available_python_versions", local_var_configuration.base_path);
178 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
179
180 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
181 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
182 }
183 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
184 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
185 };
186
187 let local_var_req = local_var_req_builder.build()?;
188 let local_var_resp = local_var_client.execute(local_var_req).await?;
189
190 let local_var_status = local_var_resp.status();
191 let local_var_content = local_var_resp.text().await?;
192
193 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
194 crate::from_str_patched(&local_var_content).map_err(Error::from)
195 } else {
196 let local_var_entity: Option<ListAvailablePythonVersionsError> = crate::from_str_patched(&local_var_content).ok();
197 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
198 Err(Error::ResponseError(local_var_error))
199 }
200}
201
202pub async fn list_configs(configuration: &configuration::Configuration, ) -> Result<Vec<models::Config>, Error<ListConfigsError>> {
203 let local_var_configuration = configuration;
204
205 let local_var_client = &local_var_configuration.client;
206
207 let local_var_uri_str = format!("{}/configs/list", local_var_configuration.base_path);
208 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
209
210 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
212 }
213 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
214 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
215 };
216
217 let local_var_req = local_var_req_builder.build()?;
218 let local_var_resp = local_var_client.execute(local_var_req).await?;
219
220 let local_var_status = local_var_resp.status();
221 let local_var_content = local_var_resp.text().await?;
222
223 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
224 crate::from_str_patched(&local_var_content).map_err(Error::from)
225 } else {
226 let local_var_entity: Option<ListConfigsError> = crate::from_str_patched(&local_var_content).ok();
227 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
228 Err(Error::ResponseError(local_var_error))
229 }
230}
231
232pub async fn list_worker_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ListWorkerGroups200ResponseInner>, Error<ListWorkerGroupsError>> {
233 let local_var_configuration = configuration;
234
235 let local_var_client = &local_var_configuration.client;
236
237 let local_var_uri_str = format!("{}/configs/list_worker_groups", local_var_configuration.base_path);
238 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
239
240 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
241 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
242 }
243 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
244 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
245 };
246
247 let local_var_req = local_var_req_builder.build()?;
248 let local_var_resp = local_var_client.execute(local_var_req).await?;
249
250 let local_var_status = local_var_resp.status();
251 let local_var_content = local_var_resp.text().await?;
252
253 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
254 crate::from_str_patched(&local_var_content).map_err(Error::from)
255 } else {
256 let local_var_entity: Option<ListWorkerGroupsError> = crate::from_str_patched(&local_var_content).ok();
257 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
258 Err(Error::ResponseError(local_var_error))
259 }
260}
261
262pub async fn native_kubernetes_autoscaling_healthcheck(configuration: &configuration::Configuration, ) -> Result<(), Error<NativeKubernetesAutoscalingHealthcheckError>> {
263 let local_var_configuration = configuration;
264
265 let local_var_client = &local_var_configuration.client;
266
267 let local_var_uri_str = format!("{}/configs/native_kubernetes_autoscaling_healthcheck", local_var_configuration.base_path);
268 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
269
270 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
271 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
272 }
273 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
274 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
275 };
276
277 let local_var_req = local_var_req_builder.build()?;
278 let local_var_resp = local_var_client.execute(local_var_req).await?;
279
280 let local_var_status = local_var_resp.status();
281 let local_var_content = local_var_resp.text().await?;
282
283 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
284 Ok(())
285 } else {
286 let local_var_entity: Option<NativeKubernetesAutoscalingHealthcheckError> = crate::from_str_patched(&local_var_content).ok();
287 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
288 Err(Error::ResponseError(local_var_error))
289 }
290}
291
292pub async fn update_config(configuration: &configuration::Configuration, name: &str, body: Option<serde_json::Value>) -> Result<String, Error<UpdateConfigError>> {
293 let local_var_configuration = configuration;
294
295 let local_var_client = &local_var_configuration.client;
296
297 let local_var_uri_str = format!("{}/configs/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
298 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
299
300 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
301 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
302 }
303 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
304 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
305 };
306 local_var_req_builder = local_var_req_builder.json(&body);
307
308 let local_var_req = local_var_req_builder.build()?;
309 let local_var_resp = local_var_client.execute(local_var_req).await?;
310
311 let local_var_status = local_var_resp.status();
312 let local_var_content = local_var_resp.text().await?;
313
314 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315 crate::from_str_patched(&local_var_content).map_err(Error::from)
316 } else {
317 let local_var_entity: Option<UpdateConfigError> = crate::from_str_patched(&local_var_content).ok();
318 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
319 Err(Error::ResponseError(local_var_error))
320 }
321}
322