1use reqwest;
12use serde::{Deserialize, Serialize, de::Error as _};
13
14use super::{ContentType, Error, configuration};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateClusterError {
21 Status400(models::GetFinances400Response),
22 Status401(models::GetFinances401Response),
23 Status429(models::GetFinances429Response),
24 Status500(models::GetFinances500Response),
25 UnknownValue(serde_json::Value)
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateClusterNodeGroupError {
32 Status400(models::GetFinances400Response),
33 Status401(models::GetFinances401Response),
34 Status403(models::GetAccountStatus403Response),
35 Status404(models::GetImage404Response),
36 Status429(models::GetFinances429Response),
37 Status500(models::GetFinances500Response),
38 UnknownValue(serde_json::Value)
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum DeleteClusterError {
45 Status400(models::GetFinances400Response),
46 Status401(models::GetFinances401Response),
47 Status403(models::GetAccountStatus403Response),
48 Status404(models::GetImage404Response),
49 Status429(models::GetFinances429Response),
50 Status500(models::GetFinances500Response),
51 UnknownValue(serde_json::Value)
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum DeleteClusterNodeError {
58 Status400(models::GetFinances400Response),
59 Status401(models::GetFinances401Response),
60 Status403(models::GetAccountStatus403Response),
61 Status404(models::GetImage404Response),
62 Status429(models::GetFinances429Response),
63 Status500(models::GetFinances500Response),
64 UnknownValue(serde_json::Value)
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum DeleteClusterNodeGroupError {
71 Status400(models::GetFinances400Response),
72 Status401(models::GetFinances401Response),
73 Status403(models::GetAccountStatus403Response),
74 Status404(models::GetImage404Response),
75 Status429(models::GetFinances429Response),
76 Status500(models::GetFinances500Response),
77 UnknownValue(serde_json::Value)
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum DeleteKubernetesAddonsError {
84 Status400(models::GetFinances400Response),
85 Status401(models::GetFinances401Response),
86 Status429(models::GetFinances429Response),
87 Status500(models::GetFinances500Response),
88 UnknownValue(serde_json::Value)
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum GetClusterError {
95 Status400(models::GetFinances400Response),
96 Status401(models::GetFinances401Response),
97 Status403(models::GetAccountStatus403Response),
98 Status404(models::GetImage404Response),
99 Status429(models::GetFinances429Response),
100 Status500(models::GetFinances500Response),
101 UnknownValue(serde_json::Value)
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum GetClusterKubeconfigError {
108 Status400(models::GetFinances400Response),
109 Status401(models::GetFinances401Response),
110 Status403(models::GetAccountStatus403Response),
111 Status404(models::GetImage404Response),
112 Status429(models::GetFinances429Response),
113 Status500(models::GetFinances500Response),
114 UnknownValue(serde_json::Value)
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum GetClusterNodeGroupError {
121 Status400(models::GetFinances400Response),
122 Status401(models::GetFinances401Response),
123 Status403(models::GetAccountStatus403Response),
124 Status404(models::GetImage404Response),
125 Status429(models::GetFinances429Response),
126 Status500(models::GetFinances500Response),
127 UnknownValue(serde_json::Value)
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum GetClusterNodeGroupsError {
134 Status400(models::GetFinances400Response),
135 Status401(models::GetFinances401Response),
136 Status403(models::GetAccountStatus403Response),
137 Status404(models::GetImage404Response),
138 Status429(models::GetFinances429Response),
139 Status500(models::GetFinances500Response),
140 UnknownValue(serde_json::Value)
141}
142
143#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum GetClusterNodesError {
147 Status400(models::GetFinances400Response),
148 Status401(models::GetFinances401Response),
149 Status403(models::GetAccountStatus403Response),
150 Status404(models::GetImage404Response),
151 Status429(models::GetFinances429Response),
152 Status500(models::GetFinances500Response),
153 UnknownValue(serde_json::Value)
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum GetClusterNodesFromGroupError {
160 Status400(models::GetFinances400Response),
161 Status401(models::GetFinances401Response),
162 Status403(models::GetAccountStatus403Response),
163 Status404(models::GetImage404Response),
164 Status429(models::GetFinances429Response),
165 Status500(models::GetFinances500Response),
166 UnknownValue(serde_json::Value)
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum GetClusterResourcesError {
173 Status400(models::GetFinances400Response),
174 Status401(models::GetFinances401Response),
175 Status403(models::GetAccountStatus403Response),
176 Status404(models::GetImage404Response),
177 Status429(models::GetFinances429Response),
178 Status500(models::GetFinances500Response),
179 UnknownValue(serde_json::Value)
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum GetClustersError {
186 Status400(models::GetFinances400Response),
187 Status401(models::GetFinances401Response),
188 Status429(models::GetFinances429Response),
189 Status500(models::GetFinances500Response),
190 UnknownValue(serde_json::Value)
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum GetK8SNetworkDriversError {
197 Status400(models::GetFinances400Response),
198 Status401(models::GetFinances401Response),
199 Status429(models::GetFinances429Response),
200 Status500(models::GetFinances500Response),
201 UnknownValue(serde_json::Value)
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum GetK8SVersionsError {
208 Status400(models::GetFinances400Response),
209 Status401(models::GetFinances401Response),
210 Status429(models::GetFinances429Response),
211 Status500(models::GetFinances500Response),
212 UnknownValue(serde_json::Value)
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum GetKubernetesAddonsError {
219 Status400(models::GetFinances400Response),
220 Status401(models::GetFinances401Response),
221 Status429(models::GetFinances429Response),
222 Status500(models::GetFinances500Response),
223 UnknownValue(serde_json::Value)
224}
225
226#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum GetKubernetesAddonsConfigError {
230 Status400(models::GetFinances400Response),
231 Status401(models::GetFinances401Response),
232 Status429(models::GetFinances429Response),
233 Status500(models::GetFinances500Response),
234 UnknownValue(serde_json::Value)
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize)]
239#[serde(untagged)]
240pub enum GetKubernetesPresetsError {
241 Status400(models::GetFinances400Response),
242 Status401(models::GetFinances401Response),
243 Status429(models::GetFinances429Response),
244 Status500(models::GetFinances500Response),
245 UnknownValue(serde_json::Value)
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum IncreaseCountOfNodesInGroupError {
252 Status400(models::GetFinances400Response),
253 Status401(models::GetFinances401Response),
254 Status403(models::GetAccountStatus403Response),
255 Status404(models::GetImage404Response),
256 Status429(models::GetFinances429Response),
257 Status500(models::GetFinances500Response),
258 UnknownValue(serde_json::Value)
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum PostKubernetesAddonsError {
265 Status400(models::GetFinances400Response),
266 Status401(models::GetFinances401Response),
267 Status429(models::GetFinances429Response),
268 Status500(models::GetFinances500Response),
269 UnknownValue(serde_json::Value)
270}
271
272#[derive(Debug, Clone, Serialize, Deserialize)]
274#[serde(untagged)]
275pub enum PostKubernetesAddonsUpdateError {
276 Status400(models::GetFinances400Response),
277 Status401(models::GetFinances401Response),
278 Status429(models::GetFinances429Response),
279 Status500(models::GetFinances500Response),
280 UnknownValue(serde_json::Value)
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize)]
285#[serde(untagged)]
286pub enum ReduceCountOfNodesInGroupError {
287 Status400(models::GetFinances400Response),
288 Status401(models::GetFinances401Response),
289 Status403(models::GetAccountStatus403Response),
290 Status404(models::GetImage404Response),
291 Status429(models::GetFinances429Response),
292 Status500(models::GetFinances500Response),
293 UnknownValue(serde_json::Value)
294}
295
296#[derive(Debug, Clone, Serialize, Deserialize)]
298#[serde(untagged)]
299pub enum UpdateClusterError {
300 Status400(models::GetFinances400Response),
301 Status401(models::GetFinances401Response),
302 Status403(models::GetAccountStatus403Response),
303 Status404(models::GetImage404Response),
304 Status429(models::GetFinances429Response),
305 Status500(models::GetFinances500Response),
306 UnknownValue(serde_json::Value)
307}
308
309#[derive(Debug, Clone, Serialize, Deserialize)]
311#[serde(untagged)]
312pub enum UpdateClusterVersionError {
313 Status400(models::GetFinances400Response),
314 Status401(models::GetFinances401Response),
315 Status403(models::GetAccountStatus403Response),
316 Status404(models::GetImage404Response),
317 Status429(models::GetFinances429Response),
318 Status500(models::GetFinances500Response),
319 UnknownValue(serde_json::Value)
320}
321
322pub async fn create_cluster(
324 configuration: &configuration::Configuration,
325 cluster_in: models::ClusterIn
326) -> Result<models::CreateCluster201Response, Error<CreateClusterError>> {
327 let p_body_cluster_in = cluster_in;
329
330 let uri_str = format!("{}/api/v1/k8s/clusters", configuration.base_path);
331 let mut req_builder = configuration
332 .client
333 .request(reqwest::Method::POST, &uri_str);
334
335 if let Some(ref user_agent) = configuration.user_agent {
336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337 }
338 if let Some(ref token) = configuration.bearer_access_token {
339 req_builder = req_builder.bearer_auth(token.to_owned());
340 };
341 req_builder = req_builder.json(&p_body_cluster_in);
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => {
359 return Err(Error::from(serde_json::Error::custom(
360 "Received `text/plain` content type response that cannot be converted to `models::CreateCluster201Response`"
361 )));
362 }
363 ContentType::Unsupported(unknown_type) => {
364 return Err(Error::from(serde_json::Error::custom(format!(
365 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateCluster201Response`"
366 ))));
367 }
368 }
369 } else {
370 let content = resp.text().await?;
371 let entity: Option<CreateClusterError> = serde_json::from_str(&content).ok();
372 Err(Error::ResponseError(ResponseContent {
373 status,
374 content,
375 entity
376 }))
377 }
378}
379
380pub async fn create_cluster_node_group(
383 configuration: &configuration::Configuration,
384 cluster_id: i32,
385 node_group_in: models::NodeGroupIn
386) -> Result<models::CreateClusterNodeGroup201Response, Error<CreateClusterNodeGroupError>> {
387 let p_path_cluster_id = cluster_id;
389 let p_body_node_group_in = node_group_in;
390
391 let uri_str = format!(
392 "{}/api/v1/k8s/clusters/{cluster_id}/groups",
393 configuration.base_path,
394 cluster_id = p_path_cluster_id
395 );
396 let mut req_builder = configuration
397 .client
398 .request(reqwest::Method::POST, &uri_str);
399
400 if let Some(ref user_agent) = configuration.user_agent {
401 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
402 }
403 if let Some(ref token) = configuration.bearer_access_token {
404 req_builder = req_builder.bearer_auth(token.to_owned());
405 };
406 req_builder = req_builder.json(&p_body_node_group_in);
407
408 let req = req_builder.build()?;
409 let resp = configuration.client.execute(req).await?;
410
411 let status = resp.status();
412 let content_type = resp
413 .headers()
414 .get("content-type")
415 .and_then(|v| v.to_str().ok())
416 .unwrap_or("application/octet-stream");
417 let content_type = super::ContentType::from(content_type);
418
419 if !status.is_client_error() && !status.is_server_error() {
420 let content = resp.text().await?;
421 match content_type {
422 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
423 ContentType::Text => {
424 return Err(Error::from(serde_json::Error::custom(
425 "Received `text/plain` content type response that cannot be converted to `models::CreateClusterNodeGroup201Response`"
426 )));
427 }
428 ContentType::Unsupported(unknown_type) => {
429 return Err(Error::from(serde_json::Error::custom(format!(
430 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateClusterNodeGroup201Response`"
431 ))));
432 }
433 }
434 } else {
435 let content = resp.text().await?;
436 let entity: Option<CreateClusterNodeGroupError> = serde_json::from_str(&content).ok();
437 Err(Error::ResponseError(ResponseContent {
438 status,
439 content,
440 entity
441 }))
442 }
443}
444
445pub async fn delete_cluster(
448 configuration: &configuration::Configuration,
449 cluster_id: i32,
450 hash: Option<&str>,
451 code: Option<&str>
452) -> Result<models::DeleteCluster200Response, Error<DeleteClusterError>> {
453 let p_path_cluster_id = cluster_id;
455 let p_query_hash = hash;
456 let p_query_code = code;
457
458 let uri_str = format!(
459 "{}/api/v1/k8s/clusters/{cluster_id}",
460 configuration.base_path,
461 cluster_id = p_path_cluster_id
462 );
463 let mut req_builder = configuration
464 .client
465 .request(reqwest::Method::DELETE, &uri_str);
466
467 if let Some(ref param_value) = p_query_hash {
468 req_builder = req_builder.query(&[("hash", ¶m_value.to_string())]);
469 }
470 if let Some(ref param_value) = p_query_code {
471 req_builder = req_builder.query(&[("code", ¶m_value.to_string())]);
472 }
473 if let Some(ref user_agent) = configuration.user_agent {
474 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
475 }
476 if let Some(ref token) = configuration.bearer_access_token {
477 req_builder = req_builder.bearer_auth(token.to_owned());
478 };
479
480 let req = req_builder.build()?;
481 let resp = configuration.client.execute(req).await?;
482
483 let status = resp.status();
484 let content_type = resp
485 .headers()
486 .get("content-type")
487 .and_then(|v| v.to_str().ok())
488 .unwrap_or("application/octet-stream");
489 let content_type = super::ContentType::from(content_type);
490
491 if !status.is_client_error() && !status.is_server_error() {
492 let content = resp.text().await?;
493 match content_type {
494 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
495 ContentType::Text => {
496 return Err(Error::from(serde_json::Error::custom(
497 "Received `text/plain` content type response that cannot be converted to `models::DeleteCluster200Response`"
498 )));
499 }
500 ContentType::Unsupported(unknown_type) => {
501 return Err(Error::from(serde_json::Error::custom(format!(
502 "Received `{unknown_type}` content type response that cannot be converted to `models::DeleteCluster200Response`"
503 ))));
504 }
505 }
506 } else {
507 let content = resp.text().await?;
508 let entity: Option<DeleteClusterError> = serde_json::from_str(&content).ok();
509 Err(Error::ResponseError(ResponseContent {
510 status,
511 content,
512 entity
513 }))
514 }
515}
516
517pub async fn delete_cluster_node(
520 configuration: &configuration::Configuration,
521 cluster_id: i32,
522 node_id: i32
523) -> Result<(), Error<DeleteClusterNodeError>> {
524 let p_path_cluster_id = cluster_id;
526 let p_path_node_id = node_id;
527
528 let uri_str = format!(
529 "{}/api/v1/k8s/clusters/{cluster_id}/nodes/{node_id}",
530 configuration.base_path,
531 cluster_id = p_path_cluster_id,
532 node_id = p_path_node_id
533 );
534 let mut req_builder = configuration
535 .client
536 .request(reqwest::Method::DELETE, &uri_str);
537
538 if let Some(ref user_agent) = configuration.user_agent {
539 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540 }
541 if let Some(ref token) = configuration.bearer_access_token {
542 req_builder = req_builder.bearer_auth(token.to_owned());
543 };
544
545 let req = req_builder.build()?;
546 let resp = configuration.client.execute(req).await?;
547
548 let status = resp.status();
549
550 if !status.is_client_error() && !status.is_server_error() {
551 Ok(())
552 } else {
553 let content = resp.text().await?;
554 let entity: Option<DeleteClusterNodeError> = serde_json::from_str(&content).ok();
555 Err(Error::ResponseError(ResponseContent {
556 status,
557 content,
558 entity
559 }))
560 }
561}
562
563pub async fn delete_cluster_node_group(
566 configuration: &configuration::Configuration,
567 cluster_id: i32,
568 group_id: i32
569) -> Result<(), Error<DeleteClusterNodeGroupError>> {
570 let p_path_cluster_id = cluster_id;
572 let p_path_group_id = group_id;
573
574 let uri_str = format!(
575 "{}/api/v1/k8s/clusters/{cluster_id}/groups/{group_id}",
576 configuration.base_path,
577 cluster_id = p_path_cluster_id,
578 group_id = p_path_group_id
579 );
580 let mut req_builder = configuration
581 .client
582 .request(reqwest::Method::DELETE, &uri_str);
583
584 if let Some(ref user_agent) = configuration.user_agent {
585 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
586 }
587 if let Some(ref token) = configuration.bearer_access_token {
588 req_builder = req_builder.bearer_auth(token.to_owned());
589 };
590
591 let req = req_builder.build()?;
592 let resp = configuration.client.execute(req).await?;
593
594 let status = resp.status();
595
596 if !status.is_client_error() && !status.is_server_error() {
597 Ok(())
598 } else {
599 let content = resp.text().await?;
600 let entity: Option<DeleteClusterNodeGroupError> = serde_json::from_str(&content).ok();
601 Err(Error::ResponseError(ResponseContent {
602 status,
603 content,
604 entity
605 }))
606 }
607}
608
609pub async fn delete_kubernetes_addons(
612 configuration: &configuration::Configuration,
613 cluster_id: i32,
614 addon_id: i32
615) -> Result<(), Error<DeleteKubernetesAddonsError>> {
616 let p_path_cluster_id = cluster_id;
618 let p_path_addon_id = addon_id;
619
620 let uri_str = format!(
621 "{}/api/v1/k8s/clusters/{cluster_id}/addons/{addon_id}",
622 configuration.base_path,
623 cluster_id = p_path_cluster_id,
624 addon_id = p_path_addon_id
625 );
626 let mut req_builder = configuration
627 .client
628 .request(reqwest::Method::DELETE, &uri_str);
629
630 if let Some(ref user_agent) = configuration.user_agent {
631 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
632 }
633 if let Some(ref token) = configuration.bearer_access_token {
634 req_builder = req_builder.bearer_auth(token.to_owned());
635 };
636
637 let req = req_builder.build()?;
638 let resp = configuration.client.execute(req).await?;
639
640 let status = resp.status();
641
642 if !status.is_client_error() && !status.is_server_error() {
643 Ok(())
644 } else {
645 let content = resp.text().await?;
646 let entity: Option<DeleteKubernetesAddonsError> = serde_json::from_str(&content).ok();
647 Err(Error::ResponseError(ResponseContent {
648 status,
649 content,
650 entity
651 }))
652 }
653}
654
655pub async fn get_cluster(
658 configuration: &configuration::Configuration,
659 cluster_id: i32
660) -> Result<models::CreateCluster201Response, Error<GetClusterError>> {
661 let p_path_cluster_id = cluster_id;
663
664 let uri_str = format!(
665 "{}/api/v1/k8s/clusters/{cluster_id}",
666 configuration.base_path,
667 cluster_id = p_path_cluster_id
668 );
669 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
670
671 if let Some(ref user_agent) = configuration.user_agent {
672 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
673 }
674 if let Some(ref token) = configuration.bearer_access_token {
675 req_builder = req_builder.bearer_auth(token.to_owned());
676 };
677
678 let req = req_builder.build()?;
679 let resp = configuration.client.execute(req).await?;
680
681 let status = resp.status();
682 let content_type = resp
683 .headers()
684 .get("content-type")
685 .and_then(|v| v.to_str().ok())
686 .unwrap_or("application/octet-stream");
687 let content_type = super::ContentType::from(content_type);
688
689 if !status.is_client_error() && !status.is_server_error() {
690 let content = resp.text().await?;
691 match content_type {
692 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
693 ContentType::Text => {
694 return Err(Error::from(serde_json::Error::custom(
695 "Received `text/plain` content type response that cannot be converted to `models::CreateCluster201Response`"
696 )));
697 }
698 ContentType::Unsupported(unknown_type) => {
699 return Err(Error::from(serde_json::Error::custom(format!(
700 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateCluster201Response`"
701 ))));
702 }
703 }
704 } else {
705 let content = resp.text().await?;
706 let entity: Option<GetClusterError> = serde_json::from_str(&content).ok();
707 Err(Error::ResponseError(ResponseContent {
708 status,
709 content,
710 entity
711 }))
712 }
713}
714
715pub async fn get_cluster_kubeconfig(
718 configuration: &configuration::Configuration,
719 cluster_id: i32
720) -> Result<String, Error<GetClusterKubeconfigError>> {
721 let p_path_cluster_id = cluster_id;
723
724 let uri_str = format!(
725 "{}/api/v1/k8s/clusters/{cluster_id}/kubeconfig",
726 configuration.base_path,
727 cluster_id = p_path_cluster_id
728 );
729 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
730
731 if let Some(ref user_agent) = configuration.user_agent {
732 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
733 }
734 if let Some(ref token) = configuration.bearer_access_token {
735 req_builder = req_builder.bearer_auth(token.to_owned());
736 };
737
738 let req = req_builder.build()?;
739 let resp = configuration.client.execute(req).await?;
740
741 let status = resp.status();
742 let content_type = resp
743 .headers()
744 .get("content-type")
745 .and_then(|v| v.to_str().ok())
746 .unwrap_or("application/octet-stream");
747 let content_type = super::ContentType::from(content_type);
748
749 if !status.is_client_error() && !status.is_server_error() {
750 let content = resp.text().await?;
751 match content_type {
752 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
753 ContentType::Text => {
754 return Err(Error::from(serde_json::Error::custom(
755 "Received `text/plain` content type response that cannot be converted to `String`"
756 )));
757 }
758 ContentType::Unsupported(unknown_type) => {
759 return Err(Error::from(serde_json::Error::custom(format!(
760 "Received `{unknown_type}` content type response that cannot be converted to `String`"
761 ))));
762 }
763 }
764 } else {
765 let content = resp.text().await?;
766 let entity: Option<GetClusterKubeconfigError> = serde_json::from_str(&content).ok();
767 Err(Error::ResponseError(ResponseContent {
768 status,
769 content,
770 entity
771 }))
772 }
773}
774
775pub async fn get_cluster_node_group(
778 configuration: &configuration::Configuration,
779 cluster_id: i32,
780 group_id: i32
781) -> Result<models::CreateClusterNodeGroup201Response, Error<GetClusterNodeGroupError>> {
782 let p_path_cluster_id = cluster_id;
784 let p_path_group_id = group_id;
785
786 let uri_str = format!(
787 "{}/api/v1/k8s/clusters/{cluster_id}/groups/{group_id}",
788 configuration.base_path,
789 cluster_id = p_path_cluster_id,
790 group_id = p_path_group_id
791 );
792 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
793
794 if let Some(ref user_agent) = configuration.user_agent {
795 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
796 }
797 if let Some(ref token) = configuration.bearer_access_token {
798 req_builder = req_builder.bearer_auth(token.to_owned());
799 };
800
801 let req = req_builder.build()?;
802 let resp = configuration.client.execute(req).await?;
803
804 let status = resp.status();
805 let content_type = resp
806 .headers()
807 .get("content-type")
808 .and_then(|v| v.to_str().ok())
809 .unwrap_or("application/octet-stream");
810 let content_type = super::ContentType::from(content_type);
811
812 if !status.is_client_error() && !status.is_server_error() {
813 let content = resp.text().await?;
814 match content_type {
815 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
816 ContentType::Text => {
817 return Err(Error::from(serde_json::Error::custom(
818 "Received `text/plain` content type response that cannot be converted to `models::CreateClusterNodeGroup201Response`"
819 )));
820 }
821 ContentType::Unsupported(unknown_type) => {
822 return Err(Error::from(serde_json::Error::custom(format!(
823 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateClusterNodeGroup201Response`"
824 ))));
825 }
826 }
827 } else {
828 let content = resp.text().await?;
829 let entity: Option<GetClusterNodeGroupError> = serde_json::from_str(&content).ok();
830 Err(Error::ResponseError(ResponseContent {
831 status,
832 content,
833 entity
834 }))
835 }
836}
837
838pub async fn get_cluster_node_groups(
841 configuration: &configuration::Configuration,
842 cluster_id: i32
843) -> Result<models::GetClusterNodeGroups200Response, Error<GetClusterNodeGroupsError>> {
844 let p_path_cluster_id = cluster_id;
846
847 let uri_str = format!(
848 "{}/api/v1/k8s/clusters/{cluster_id}/groups",
849 configuration.base_path,
850 cluster_id = p_path_cluster_id
851 );
852 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
853
854 if let Some(ref user_agent) = configuration.user_agent {
855 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
856 }
857 if let Some(ref token) = configuration.bearer_access_token {
858 req_builder = req_builder.bearer_auth(token.to_owned());
859 };
860
861 let req = req_builder.build()?;
862 let resp = configuration.client.execute(req).await?;
863
864 let status = resp.status();
865 let content_type = resp
866 .headers()
867 .get("content-type")
868 .and_then(|v| v.to_str().ok())
869 .unwrap_or("application/octet-stream");
870 let content_type = super::ContentType::from(content_type);
871
872 if !status.is_client_error() && !status.is_server_error() {
873 let content = resp.text().await?;
874 match content_type {
875 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
876 ContentType::Text => {
877 return Err(Error::from(serde_json::Error::custom(
878 "Received `text/plain` content type response that cannot be converted to `models::GetClusterNodeGroups200Response`"
879 )));
880 }
881 ContentType::Unsupported(unknown_type) => {
882 return Err(Error::from(serde_json::Error::custom(format!(
883 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusterNodeGroups200Response`"
884 ))));
885 }
886 }
887 } else {
888 let content = resp.text().await?;
889 let entity: Option<GetClusterNodeGroupsError> = serde_json::from_str(&content).ok();
890 Err(Error::ResponseError(ResponseContent {
891 status,
892 content,
893 entity
894 }))
895 }
896}
897
898pub async fn get_cluster_nodes(
901 configuration: &configuration::Configuration,
902 cluster_id: i32
903) -> Result<models::GetClusterNodesFromGroup200Response, Error<GetClusterNodesError>> {
904 let p_path_cluster_id = cluster_id;
906
907 let uri_str = format!(
908 "{}/api/v1/k8s/clusters/{cluster_id}/nodes",
909 configuration.base_path,
910 cluster_id = p_path_cluster_id
911 );
912 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
913
914 if let Some(ref user_agent) = configuration.user_agent {
915 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
916 }
917 if let Some(ref token) = configuration.bearer_access_token {
918 req_builder = req_builder.bearer_auth(token.to_owned());
919 };
920
921 let req = req_builder.build()?;
922 let resp = configuration.client.execute(req).await?;
923
924 let status = resp.status();
925 let content_type = resp
926 .headers()
927 .get("content-type")
928 .and_then(|v| v.to_str().ok())
929 .unwrap_or("application/octet-stream");
930 let content_type = super::ContentType::from(content_type);
931
932 if !status.is_client_error() && !status.is_server_error() {
933 let content = resp.text().await?;
934 match content_type {
935 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
936 ContentType::Text => {
937 return Err(Error::from(serde_json::Error::custom(
938 "Received `text/plain` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
939 )));
940 }
941 ContentType::Unsupported(unknown_type) => {
942 return Err(Error::from(serde_json::Error::custom(format!(
943 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
944 ))));
945 }
946 }
947 } else {
948 let content = resp.text().await?;
949 let entity: Option<GetClusterNodesError> = serde_json::from_str(&content).ok();
950 Err(Error::ResponseError(ResponseContent {
951 status,
952 content,
953 entity
954 }))
955 }
956}
957
958pub async fn get_cluster_nodes_from_group(
961 configuration: &configuration::Configuration,
962 cluster_id: i32,
963 group_id: i32,
964 limit: Option<i32>,
965 offset: Option<i32>
966) -> Result<models::GetClusterNodesFromGroup200Response, Error<GetClusterNodesFromGroupError>> {
967 let p_path_cluster_id = cluster_id;
969 let p_path_group_id = group_id;
970 let p_query_limit = limit;
971 let p_query_offset = offset;
972
973 let uri_str = format!(
974 "{}/api/v1/k8s/clusters/{cluster_id}/groups/{group_id}/nodes",
975 configuration.base_path,
976 cluster_id = p_path_cluster_id,
977 group_id = p_path_group_id
978 );
979 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
980
981 if let Some(ref param_value) = p_query_limit {
982 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
983 }
984 if let Some(ref param_value) = p_query_offset {
985 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
986 }
987 if let Some(ref user_agent) = configuration.user_agent {
988 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
989 }
990 if let Some(ref token) = configuration.bearer_access_token {
991 req_builder = req_builder.bearer_auth(token.to_owned());
992 };
993
994 let req = req_builder.build()?;
995 let resp = configuration.client.execute(req).await?;
996
997 let status = resp.status();
998 let content_type = resp
999 .headers()
1000 .get("content-type")
1001 .and_then(|v| v.to_str().ok())
1002 .unwrap_or("application/octet-stream");
1003 let content_type = super::ContentType::from(content_type);
1004
1005 if !status.is_client_error() && !status.is_server_error() {
1006 let content = resp.text().await?;
1007 match content_type {
1008 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1009 ContentType::Text => {
1010 return Err(Error::from(serde_json::Error::custom(
1011 "Received `text/plain` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
1012 )));
1013 }
1014 ContentType::Unsupported(unknown_type) => {
1015 return Err(Error::from(serde_json::Error::custom(format!(
1016 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
1017 ))));
1018 }
1019 }
1020 } else {
1021 let content = resp.text().await?;
1022 let entity: Option<GetClusterNodesFromGroupError> = serde_json::from_str(&content).ok();
1023 Err(Error::ResponseError(ResponseContent {
1024 status,
1025 content,
1026 entity
1027 }))
1028 }
1029}
1030
1031#[deprecated]
1035pub async fn get_cluster_resources(
1036 configuration: &configuration::Configuration,
1037 cluster_id: i32
1038) -> Result<models::GetClusterResources200Response, Error<GetClusterResourcesError>> {
1039 let p_path_cluster_id = cluster_id;
1041
1042 let uri_str = format!(
1043 "{}/api/v1/k8s/clusters/{cluster_id}/resources",
1044 configuration.base_path,
1045 cluster_id = p_path_cluster_id
1046 );
1047 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1048
1049 if let Some(ref user_agent) = configuration.user_agent {
1050 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1051 }
1052 if let Some(ref token) = configuration.bearer_access_token {
1053 req_builder = req_builder.bearer_auth(token.to_owned());
1054 };
1055
1056 let req = req_builder.build()?;
1057 let resp = configuration.client.execute(req).await?;
1058
1059 let status = resp.status();
1060 let content_type = resp
1061 .headers()
1062 .get("content-type")
1063 .and_then(|v| v.to_str().ok())
1064 .unwrap_or("application/octet-stream");
1065 let content_type = super::ContentType::from(content_type);
1066
1067 if !status.is_client_error() && !status.is_server_error() {
1068 let content = resp.text().await?;
1069 match content_type {
1070 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1071 ContentType::Text => {
1072 return Err(Error::from(serde_json::Error::custom(
1073 "Received `text/plain` content type response that cannot be converted to `models::GetClusterResources200Response`"
1074 )));
1075 }
1076 ContentType::Unsupported(unknown_type) => {
1077 return Err(Error::from(serde_json::Error::custom(format!(
1078 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusterResources200Response`"
1079 ))));
1080 }
1081 }
1082 } else {
1083 let content = resp.text().await?;
1084 let entity: Option<GetClusterResourcesError> = serde_json::from_str(&content).ok();
1085 Err(Error::ResponseError(ResponseContent {
1086 status,
1087 content,
1088 entity
1089 }))
1090 }
1091}
1092
1093pub async fn get_clusters(
1096 configuration: &configuration::Configuration,
1097 limit: Option<i32>,
1098 offset: Option<i32>
1099) -> Result<models::GetClusters200Response, Error<GetClustersError>> {
1100 let p_query_limit = limit;
1102 let p_query_offset = offset;
1103
1104 let uri_str = format!("{}/api/v1/k8s/clusters", configuration.base_path);
1105 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1106
1107 if let Some(ref param_value) = p_query_limit {
1108 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
1109 }
1110 if let Some(ref param_value) = p_query_offset {
1111 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
1112 }
1113 if let Some(ref user_agent) = configuration.user_agent {
1114 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1115 }
1116 if let Some(ref token) = configuration.bearer_access_token {
1117 req_builder = req_builder.bearer_auth(token.to_owned());
1118 };
1119
1120 let req = req_builder.build()?;
1121 let resp = configuration.client.execute(req).await?;
1122
1123 let status = resp.status();
1124 let content_type = resp
1125 .headers()
1126 .get("content-type")
1127 .and_then(|v| v.to_str().ok())
1128 .unwrap_or("application/octet-stream");
1129 let content_type = super::ContentType::from(content_type);
1130
1131 if !status.is_client_error() && !status.is_server_error() {
1132 let content = resp.text().await?;
1133 match content_type {
1134 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1135 ContentType::Text => {
1136 return Err(Error::from(serde_json::Error::custom(
1137 "Received `text/plain` content type response that cannot be converted to `models::GetClusters200Response`"
1138 )));
1139 }
1140 ContentType::Unsupported(unknown_type) => {
1141 return Err(Error::from(serde_json::Error::custom(format!(
1142 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusters200Response`"
1143 ))));
1144 }
1145 }
1146 } else {
1147 let content = resp.text().await?;
1148 let entity: Option<GetClustersError> = serde_json::from_str(&content).ok();
1149 Err(Error::ResponseError(ResponseContent {
1150 status,
1151 content,
1152 entity
1153 }))
1154 }
1155}
1156
1157pub async fn get_k8_s_network_drivers(
1160 configuration: &configuration::Configuration
1161) -> Result<models::GetK8SNetworkDrivers200Response, Error<GetK8SNetworkDriversError>> {
1162 let uri_str = format!("{}/api/v1/k8s/network-drivers", configuration.base_path);
1163 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1164
1165 if let Some(ref user_agent) = configuration.user_agent {
1166 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1167 }
1168 if let Some(ref token) = configuration.bearer_access_token {
1169 req_builder = req_builder.bearer_auth(token.to_owned());
1170 };
1171
1172 let req = req_builder.build()?;
1173 let resp = configuration.client.execute(req).await?;
1174
1175 let status = resp.status();
1176 let content_type = resp
1177 .headers()
1178 .get("content-type")
1179 .and_then(|v| v.to_str().ok())
1180 .unwrap_or("application/octet-stream");
1181 let content_type = super::ContentType::from(content_type);
1182
1183 if !status.is_client_error() && !status.is_server_error() {
1184 let content = resp.text().await?;
1185 match content_type {
1186 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1187 ContentType::Text => {
1188 return Err(Error::from(serde_json::Error::custom(
1189 "Received `text/plain` content type response that cannot be converted to `models::GetK8SNetworkDrivers200Response`"
1190 )));
1191 }
1192 ContentType::Unsupported(unknown_type) => {
1193 return Err(Error::from(serde_json::Error::custom(format!(
1194 "Received `{unknown_type}` content type response that cannot be converted to `models::GetK8SNetworkDrivers200Response`"
1195 ))));
1196 }
1197 }
1198 } else {
1199 let content = resp.text().await?;
1200 let entity: Option<GetK8SNetworkDriversError> = serde_json::from_str(&content).ok();
1201 Err(Error::ResponseError(ResponseContent {
1202 status,
1203 content,
1204 entity
1205 }))
1206 }
1207}
1208
1209pub async fn get_k8_s_versions(
1212 configuration: &configuration::Configuration
1213) -> Result<models::GetK8SVersions200Response, Error<GetK8SVersionsError>> {
1214 let uri_str = format!("{}/api/v1/k8s/k8s-versions", configuration.base_path);
1215 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1216
1217 if let Some(ref user_agent) = configuration.user_agent {
1218 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1219 }
1220 if let Some(ref token) = configuration.bearer_access_token {
1221 req_builder = req_builder.bearer_auth(token.to_owned());
1222 };
1223
1224 let req = req_builder.build()?;
1225 let resp = configuration.client.execute(req).await?;
1226
1227 let status = resp.status();
1228 let content_type = resp
1229 .headers()
1230 .get("content-type")
1231 .and_then(|v| v.to_str().ok())
1232 .unwrap_or("application/octet-stream");
1233 let content_type = super::ContentType::from(content_type);
1234
1235 if !status.is_client_error() && !status.is_server_error() {
1236 let content = resp.text().await?;
1237 match content_type {
1238 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1239 ContentType::Text => {
1240 return Err(Error::from(serde_json::Error::custom(
1241 "Received `text/plain` content type response that cannot be converted to `models::GetK8SVersions200Response`"
1242 )));
1243 }
1244 ContentType::Unsupported(unknown_type) => {
1245 return Err(Error::from(serde_json::Error::custom(format!(
1246 "Received `{unknown_type}` content type response that cannot be converted to `models::GetK8SVersions200Response`"
1247 ))));
1248 }
1249 }
1250 } else {
1251 let content = resp.text().await?;
1252 let entity: Option<GetK8SVersionsError> = serde_json::from_str(&content).ok();
1253 Err(Error::ResponseError(ResponseContent {
1254 status,
1255 content,
1256 entity
1257 }))
1258 }
1259}
1260
1261pub async fn get_kubernetes_addons(
1264 configuration: &configuration::Configuration,
1265 cluster_id: i32
1266) -> Result<models::GetKubernetesAddons200Response, Error<GetKubernetesAddonsError>> {
1267 let p_path_cluster_id = cluster_id;
1269
1270 let uri_str = format!(
1271 "{}/api/v1/k8s/clusters/{cluster_id}/addons",
1272 configuration.base_path,
1273 cluster_id = p_path_cluster_id
1274 );
1275 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1276
1277 if let Some(ref user_agent) = configuration.user_agent {
1278 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1279 }
1280 if let Some(ref token) = configuration.bearer_access_token {
1281 req_builder = req_builder.bearer_auth(token.to_owned());
1282 };
1283
1284 let req = req_builder.build()?;
1285 let resp = configuration.client.execute(req).await?;
1286
1287 let status = resp.status();
1288 let content_type = resp
1289 .headers()
1290 .get("content-type")
1291 .and_then(|v| v.to_str().ok())
1292 .unwrap_or("application/octet-stream");
1293 let content_type = super::ContentType::from(content_type);
1294
1295 if !status.is_client_error() && !status.is_server_error() {
1296 let content = resp.text().await?;
1297 match content_type {
1298 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1299 ContentType::Text => {
1300 return Err(Error::from(serde_json::Error::custom(
1301 "Received `text/plain` content type response that cannot be converted to `models::GetKubernetesAddons200Response`"
1302 )));
1303 }
1304 ContentType::Unsupported(unknown_type) => {
1305 return Err(Error::from(serde_json::Error::custom(format!(
1306 "Received `{unknown_type}` content type response that cannot be converted to `models::GetKubernetesAddons200Response`"
1307 ))));
1308 }
1309 }
1310 } else {
1311 let content = resp.text().await?;
1312 let entity: Option<GetKubernetesAddonsError> = serde_json::from_str(&content).ok();
1313 Err(Error::ResponseError(ResponseContent {
1314 status,
1315 content,
1316 entity
1317 }))
1318 }
1319}
1320
1321pub async fn get_kubernetes_addons_config(
1324 configuration: &configuration::Configuration,
1325 cluster_id: i32
1326) -> Result<models::GetKubernetesAddonsConfig200Response, Error<GetKubernetesAddonsConfigError>> {
1327 let p_path_cluster_id = cluster_id;
1329
1330 let uri_str = format!(
1331 "{}/api/v1/k8s/clusters/{cluster_id}/addons-configs",
1332 configuration.base_path,
1333 cluster_id = p_path_cluster_id
1334 );
1335 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1336
1337 if let Some(ref user_agent) = configuration.user_agent {
1338 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1339 }
1340 if let Some(ref token) = configuration.bearer_access_token {
1341 req_builder = req_builder.bearer_auth(token.to_owned());
1342 };
1343
1344 let req = req_builder.build()?;
1345 let resp = configuration.client.execute(req).await?;
1346
1347 let status = resp.status();
1348 let content_type = resp
1349 .headers()
1350 .get("content-type")
1351 .and_then(|v| v.to_str().ok())
1352 .unwrap_or("application/octet-stream");
1353 let content_type = super::ContentType::from(content_type);
1354
1355 if !status.is_client_error() && !status.is_server_error() {
1356 let content = resp.text().await?;
1357 match content_type {
1358 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1359 ContentType::Text => {
1360 return Err(Error::from(serde_json::Error::custom(
1361 "Received `text/plain` content type response that cannot be converted to `models::GetKubernetesAddonsConfig200Response`"
1362 )));
1363 }
1364 ContentType::Unsupported(unknown_type) => {
1365 return Err(Error::from(serde_json::Error::custom(format!(
1366 "Received `{unknown_type}` content type response that cannot be converted to `models::GetKubernetesAddonsConfig200Response`"
1367 ))));
1368 }
1369 }
1370 } else {
1371 let content = resp.text().await?;
1372 let entity: Option<GetKubernetesAddonsConfigError> = serde_json::from_str(&content).ok();
1373 Err(Error::ResponseError(ResponseContent {
1374 status,
1375 content,
1376 entity
1377 }))
1378 }
1379}
1380
1381pub async fn get_kubernetes_presets(
1383 configuration: &configuration::Configuration
1384) -> Result<models::GetKubernetesPresets200Response, Error<GetKubernetesPresetsError>> {
1385 let uri_str = format!("{}/api/v1/presets/k8s", configuration.base_path);
1386 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1387
1388 if let Some(ref user_agent) = configuration.user_agent {
1389 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1390 }
1391 if let Some(ref token) = configuration.bearer_access_token {
1392 req_builder = req_builder.bearer_auth(token.to_owned());
1393 };
1394
1395 let req = req_builder.build()?;
1396 let resp = configuration.client.execute(req).await?;
1397
1398 let status = resp.status();
1399 let content_type = resp
1400 .headers()
1401 .get("content-type")
1402 .and_then(|v| v.to_str().ok())
1403 .unwrap_or("application/octet-stream");
1404 let content_type = super::ContentType::from(content_type);
1405
1406 if !status.is_client_error() && !status.is_server_error() {
1407 let content = resp.text().await?;
1408 match content_type {
1409 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1410 ContentType::Text => {
1411 return Err(Error::from(serde_json::Error::custom(
1412 "Received `text/plain` content type response that cannot be converted to `models::GetKubernetesPresets200Response`"
1413 )));
1414 }
1415 ContentType::Unsupported(unknown_type) => {
1416 return Err(Error::from(serde_json::Error::custom(format!(
1417 "Received `{unknown_type}` content type response that cannot be converted to `models::GetKubernetesPresets200Response`"
1418 ))));
1419 }
1420 }
1421 } else {
1422 let content = resp.text().await?;
1423 let entity: Option<GetKubernetesPresetsError> = serde_json::from_str(&content).ok();
1424 Err(Error::ResponseError(ResponseContent {
1425 status,
1426 content,
1427 entity
1428 }))
1429 }
1430}
1431
1432pub async fn increase_count_of_nodes_in_group(
1435 configuration: &configuration::Configuration,
1436 cluster_id: i32,
1437 group_id: i32,
1438 increase_nodes: models::IncreaseNodes
1439) -> Result<models::GetClusterNodesFromGroup200Response, Error<IncreaseCountOfNodesInGroupError>> {
1440 let p_path_cluster_id = cluster_id;
1442 let p_path_group_id = group_id;
1443 let p_body_increase_nodes = increase_nodes;
1444
1445 let uri_str = format!(
1446 "{}/api/v1/k8s/clusters/{cluster_id}/groups/{group_id}/nodes",
1447 configuration.base_path,
1448 cluster_id = p_path_cluster_id,
1449 group_id = p_path_group_id
1450 );
1451 let mut req_builder = configuration
1452 .client
1453 .request(reqwest::Method::POST, &uri_str);
1454
1455 if let Some(ref user_agent) = configuration.user_agent {
1456 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1457 }
1458 if let Some(ref token) = configuration.bearer_access_token {
1459 req_builder = req_builder.bearer_auth(token.to_owned());
1460 };
1461 req_builder = req_builder.json(&p_body_increase_nodes);
1462
1463 let req = req_builder.build()?;
1464 let resp = configuration.client.execute(req).await?;
1465
1466 let status = resp.status();
1467 let content_type = resp
1468 .headers()
1469 .get("content-type")
1470 .and_then(|v| v.to_str().ok())
1471 .unwrap_or("application/octet-stream");
1472 let content_type = super::ContentType::from(content_type);
1473
1474 if !status.is_client_error() && !status.is_server_error() {
1475 let content = resp.text().await?;
1476 match content_type {
1477 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1478 ContentType::Text => {
1479 return Err(Error::from(serde_json::Error::custom(
1480 "Received `text/plain` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
1481 )));
1482 }
1483 ContentType::Unsupported(unknown_type) => {
1484 return Err(Error::from(serde_json::Error::custom(format!(
1485 "Received `{unknown_type}` content type response that cannot be converted to `models::GetClusterNodesFromGroup200Response`"
1486 ))));
1487 }
1488 }
1489 } else {
1490 let content = resp.text().await?;
1491 let entity: Option<IncreaseCountOfNodesInGroupError> = serde_json::from_str(&content).ok();
1492 Err(Error::ResponseError(ResponseContent {
1493 status,
1494 content,
1495 entity
1496 }))
1497 }
1498}
1499
1500pub async fn post_kubernetes_addons(
1503 configuration: &configuration::Configuration,
1504 cluster_id: i32,
1505 cluster_in1: models::ClusterIn1
1506) -> Result<(), Error<PostKubernetesAddonsError>> {
1507 let p_path_cluster_id = cluster_id;
1509 let p_body_cluster_in1 = cluster_in1;
1510
1511 let uri_str = format!(
1512 "{}/api/v1/k8s/clusters/{cluster_id}/addons",
1513 configuration.base_path,
1514 cluster_id = p_path_cluster_id
1515 );
1516 let mut req_builder = configuration
1517 .client
1518 .request(reqwest::Method::POST, &uri_str);
1519
1520 if let Some(ref user_agent) = configuration.user_agent {
1521 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1522 }
1523 if let Some(ref token) = configuration.bearer_access_token {
1524 req_builder = req_builder.bearer_auth(token.to_owned());
1525 };
1526 req_builder = req_builder.json(&p_body_cluster_in1);
1527
1528 let req = req_builder.build()?;
1529 let resp = configuration.client.execute(req).await?;
1530
1531 let status = resp.status();
1532
1533 if !status.is_client_error() && !status.is_server_error() {
1534 Ok(())
1535 } else {
1536 let content = resp.text().await?;
1537 let entity: Option<PostKubernetesAddonsError> = serde_json::from_str(&content).ok();
1538 Err(Error::ResponseError(ResponseContent {
1539 status,
1540 content,
1541 entity
1542 }))
1543 }
1544}
1545
1546pub async fn post_kubernetes_addons_update(
1549 configuration: &configuration::Configuration,
1550 cluster_id: i32,
1551 addon_id: i32,
1552 cluster_in1: models::ClusterIn1
1553) -> Result<(), Error<PostKubernetesAddonsUpdateError>> {
1554 let p_path_cluster_id = cluster_id;
1556 let p_path_addon_id = addon_id;
1557 let p_body_cluster_in1 = cluster_in1;
1558
1559 let uri_str = format!(
1560 "{}/api/v1/k8s/clusters/{cluster_id}/addons/{addon_id}",
1561 configuration.base_path,
1562 cluster_id = p_path_cluster_id,
1563 addon_id = p_path_addon_id
1564 );
1565 let mut req_builder = configuration
1566 .client
1567 .request(reqwest::Method::POST, &uri_str);
1568
1569 if let Some(ref user_agent) = configuration.user_agent {
1570 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1571 }
1572 if let Some(ref token) = configuration.bearer_access_token {
1573 req_builder = req_builder.bearer_auth(token.to_owned());
1574 };
1575 req_builder = req_builder.json(&p_body_cluster_in1);
1576
1577 let req = req_builder.build()?;
1578 let resp = configuration.client.execute(req).await?;
1579
1580 let status = resp.status();
1581
1582 if !status.is_client_error() && !status.is_server_error() {
1583 Ok(())
1584 } else {
1585 let content = resp.text().await?;
1586 let entity: Option<PostKubernetesAddonsUpdateError> = serde_json::from_str(&content).ok();
1587 Err(Error::ResponseError(ResponseContent {
1588 status,
1589 content,
1590 entity
1591 }))
1592 }
1593}
1594
1595pub async fn reduce_count_of_nodes_in_group(
1598 configuration: &configuration::Configuration,
1599 cluster_id: i32,
1600 group_id: i32,
1601 reduce_nodes: models::ReduceNodes
1602) -> Result<(), Error<ReduceCountOfNodesInGroupError>> {
1603 let p_path_cluster_id = cluster_id;
1605 let p_path_group_id = group_id;
1606 let p_body_reduce_nodes = reduce_nodes;
1607
1608 let uri_str = format!(
1609 "{}/api/v1/k8s/clusters/{cluster_id}/groups/{group_id}/nodes",
1610 configuration.base_path,
1611 cluster_id = p_path_cluster_id,
1612 group_id = p_path_group_id
1613 );
1614 let mut req_builder = configuration
1615 .client
1616 .request(reqwest::Method::DELETE, &uri_str);
1617
1618 if let Some(ref user_agent) = configuration.user_agent {
1619 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1620 }
1621 if let Some(ref token) = configuration.bearer_access_token {
1622 req_builder = req_builder.bearer_auth(token.to_owned());
1623 };
1624 req_builder = req_builder.json(&p_body_reduce_nodes);
1625
1626 let req = req_builder.build()?;
1627 let resp = configuration.client.execute(req).await?;
1628
1629 let status = resp.status();
1630
1631 if !status.is_client_error() && !status.is_server_error() {
1632 Ok(())
1633 } else {
1634 let content = resp.text().await?;
1635 let entity: Option<ReduceCountOfNodesInGroupError> = serde_json::from_str(&content).ok();
1636 Err(Error::ResponseError(ResponseContent {
1637 status,
1638 content,
1639 entity
1640 }))
1641 }
1642}
1643
1644pub async fn update_cluster(
1647 configuration: &configuration::Configuration,
1648 cluster_id: i32,
1649 cluster_edit: models::ClusterEdit
1650) -> Result<models::CreateCluster201Response, Error<UpdateClusterError>> {
1651 let p_path_cluster_id = cluster_id;
1653 let p_body_cluster_edit = cluster_edit;
1654
1655 let uri_str = format!(
1656 "{}/api/v1/k8s/clusters/{cluster_id}",
1657 configuration.base_path,
1658 cluster_id = p_path_cluster_id
1659 );
1660 let mut req_builder = configuration
1661 .client
1662 .request(reqwest::Method::PATCH, &uri_str);
1663
1664 if let Some(ref user_agent) = configuration.user_agent {
1665 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1666 }
1667 if let Some(ref token) = configuration.bearer_access_token {
1668 req_builder = req_builder.bearer_auth(token.to_owned());
1669 };
1670 req_builder = req_builder.json(&p_body_cluster_edit);
1671
1672 let req = req_builder.build()?;
1673 let resp = configuration.client.execute(req).await?;
1674
1675 let status = resp.status();
1676 let content_type = resp
1677 .headers()
1678 .get("content-type")
1679 .and_then(|v| v.to_str().ok())
1680 .unwrap_or("application/octet-stream");
1681 let content_type = super::ContentType::from(content_type);
1682
1683 if !status.is_client_error() && !status.is_server_error() {
1684 let content = resp.text().await?;
1685 match content_type {
1686 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1687 ContentType::Text => {
1688 return Err(Error::from(serde_json::Error::custom(
1689 "Received `text/plain` content type response that cannot be converted to `models::CreateCluster201Response`"
1690 )));
1691 }
1692 ContentType::Unsupported(unknown_type) => {
1693 return Err(Error::from(serde_json::Error::custom(format!(
1694 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateCluster201Response`"
1695 ))));
1696 }
1697 }
1698 } else {
1699 let content = resp.text().await?;
1700 let entity: Option<UpdateClusterError> = serde_json::from_str(&content).ok();
1701 Err(Error::ResponseError(ResponseContent {
1702 status,
1703 content,
1704 entity
1705 }))
1706 }
1707}
1708
1709pub async fn update_cluster_version(
1712 configuration: &configuration::Configuration,
1713 cluster_id: i32,
1714 cluster_version_edit: models::ClusterVersionEdit
1715) -> Result<(), Error<UpdateClusterVersionError>> {
1716 let p_path_cluster_id = cluster_id;
1718 let p_body_cluster_version_edit = cluster_version_edit;
1719
1720 let uri_str = format!(
1721 "{}/api/v1/k8s/clusters/{cluster_id}/versions/update",
1722 configuration.base_path,
1723 cluster_id = p_path_cluster_id
1724 );
1725 let mut req_builder = configuration
1726 .client
1727 .request(reqwest::Method::PATCH, &uri_str);
1728
1729 if let Some(ref user_agent) = configuration.user_agent {
1730 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1731 }
1732 if let Some(ref token) = configuration.bearer_access_token {
1733 req_builder = req_builder.bearer_auth(token.to_owned());
1734 };
1735 req_builder = req_builder.json(&p_body_cluster_version_edit);
1736
1737 let req = req_builder.build()?;
1738 let resp = configuration.client.execute(req).await?;
1739
1740 let status = resp.status();
1741
1742 if !status.is_client_error() && !status.is_server_error() {
1743 Ok(())
1744 } else {
1745 let content = resp.text().await?;
1746 let entity: Option<UpdateClusterVersionError> = serde_json::from_str(&content).ok();
1747 Err(Error::ResponseError(ResponseContent {
1748 status,
1749 content,
1750 entity
1751 }))
1752 }
1753}