1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use reqwest::Method;
use crate::api::deployment::models::{DeploymentFailResponse, DeploymentListParams};
use crate::models::allocation::Allocation;
use crate::models::deployment::Deployment;
use crate::{ClientError, NomadClient};
impl NomadClient {
pub async fn deployment_list(
&self,
params: Option<DeploymentListParams>,
) -> Result<Vec<Deployment>, ClientError> {
let req = self.request(Method::GET, "/deployments").query(¶ms);
self.send::<Vec<Deployment>>(req).await
}
pub async fn deployment_get(&self, id: &str) -> Result<Deployment, ClientError> {
let req = self.request(Method::GET, &format!("/deployment/{}", id));
self.send::<Deployment>(req).await
}
pub async fn deployment_allocation_list(
&self,
id: &str,
) -> Result<Vec<Allocation>, ClientError> {
let req = self.request(Method::GET, &format!("/deployment/allocations/{}", id));
self.send::<Vec<Allocation>>(req).await
}
pub async fn deployment_fail(&self, id: &str) -> Result<DeploymentFailResponse, ClientError> {
let req = self.request(Method::POST, &format!("/deployment/fail/{}", id));
self.send::<DeploymentFailResponse>(req).await
}
}
pub mod models {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DeploymentListParams {
pub prefix: Option<String>,
pub namespace: Option<String>,
pub next_token: Option<String>,
pub per_page: Option<i32>,
pub filter: Option<String>,
pub reverse: Option<bool>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct DeploymentFailResponse {
#[serde(alias = "EvalID")]
pub eval_id: String,
pub eval_create_index: i32,
pub deployment_modify_index: i32,
pub reverted_job_version: i32,
pub index: i32,
}
}