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
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::Serialize;

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