nomad_client_rs/api/
allocation.rs

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
use reqwest::Method;

use crate::api::allocation::models::AllocationRestartRequest;
use crate::{ClientError, NomadClient};

impl NomadClient {
    pub async fn allocation_restart(
        &self,
        alloc_id: &str,
        req: &AllocationRestartRequest,
    ) -> Result<(), ClientError> {
        let req = self
            .request(
                Method::POST,
                &format!("/client/allocation/{}/restart", alloc_id),
            )
            .json(req);

        self.send::<()>(req).await
    }
}

pub mod models {
    use serde::{Deserialize, Serialize};

    #[derive(Debug, Default, Serialize)]
    #[serde(rename_all = "camelCase")]
    pub struct AllocationRestartRequest {
        pub task_name: Option<String>,
        pub all_tasks: Option<bool>,
    }

    #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
    pub struct AllocStopResponse {
        #[serde(rename = "EvalID", skip_serializing_if = "Option::is_none")]
        pub eval_id: Option<String>,
        #[serde(rename = "Index", skip_serializing_if = "Option::is_none")]
        pub index: Option<i32>,
    }
}