nomad_client/apis/
system_api.rs

1/*
2 * Nomad
3 *
4 * Nomad OpenApi specification
5 *
6 * The version of the OpenAPI document: 0.11.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method `force_gc`
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ForceGcError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method `reconcile_summary`
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ReconcileSummaryError {
29    UnknownValue(serde_json::Value),
30}
31
32
33pub async fn force_gc(configuration: &configuration::Configuration, namespace: Option<&str>, region: Option<&str>, index: Option<i64>, wait: Option<&str>) -> Result<(), Error<ForceGcError>> {
34
35    let local_var_client = &configuration.client;
36
37    let local_var_uri_str = format!("{}/system/gc", configuration.base_path);
38    let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
39
40    if let Some(ref local_var_str) = namespace {
41        local_var_req_builder = local_var_req_builder.query(&[("namespace", &local_var_str.to_string())]);
42    }
43    if let Some(ref local_var_str) = region {
44        local_var_req_builder = local_var_req_builder.query(&[("region", &local_var_str.to_string())]);
45    }
46    if let Some(ref local_var_str) = index {
47        local_var_req_builder = local_var_req_builder.query(&[("index", &local_var_str.to_string())]);
48    }
49    if let Some(ref local_var_str) = wait {
50        local_var_req_builder = local_var_req_builder.query(&[("wait", &local_var_str.to_string())]);
51    }
52    if let Some(ref local_var_user_agent) = configuration.user_agent {
53        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
54    }
55
56    let local_var_req = local_var_req_builder.build()?;
57    let local_var_resp = local_var_client.execute(local_var_req).await?;
58
59    let local_var_status = local_var_resp.status();
60    let local_var_content = local_var_resp.text().await?;
61
62    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
63        Ok(())
64    } else {
65        let local_var_entity: Option<ForceGcError> = serde_json::from_str(&local_var_content).ok();
66        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
67        Err(Error::ResponseError(local_var_error))
68    }
69}
70
71pub async fn reconcile_summary(configuration: &configuration::Configuration, namespace: Option<&str>, region: Option<&str>, index: Option<i64>, wait: Option<&str>) -> Result<(), Error<ReconcileSummaryError>> {
72
73    let local_var_client = &configuration.client;
74
75    let local_var_uri_str = format!("{}/system/reconcile/summaries", configuration.base_path);
76    let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
77
78    if let Some(ref local_var_str) = namespace {
79        local_var_req_builder = local_var_req_builder.query(&[("namespace", &local_var_str.to_string())]);
80    }
81    if let Some(ref local_var_str) = region {
82        local_var_req_builder = local_var_req_builder.query(&[("region", &local_var_str.to_string())]);
83    }
84    if let Some(ref local_var_str) = index {
85        local_var_req_builder = local_var_req_builder.query(&[("index", &local_var_str.to_string())]);
86    }
87    if let Some(ref local_var_str) = wait {
88        local_var_req_builder = local_var_req_builder.query(&[("wait", &local_var_str.to_string())]);
89    }
90    if let Some(ref local_var_user_agent) = configuration.user_agent {
91        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
92    }
93
94    let local_var_req = local_var_req_builder.build()?;
95    let local_var_resp = local_var_client.execute(local_var_req).await?;
96
97    let local_var_status = local_var_resp.status();
98    let local_var_content = local_var_resp.text().await?;
99
100    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
101        Ok(())
102    } else {
103        let local_var_entity: Option<ReconcileSummaryError> = serde_json::from_str(&local_var_content).ok();
104        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
105        Err(Error::ResponseError(local_var_error))
106    }
107}
108