icinga2_api/api/action/
restart_process.rs

1//! API Action restart-process
2//!
3//! [Official Documentation](https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#restart-process)
4
5use serde::{Deserialize, Serialize};
6
7use crate::types::action::StatusResponse;
8use crate::types::query::ResultsWrapper;
9use crate::types::rest::{RestApiEndpoint, RestApiResponse};
10
11/// REST API Endpoint for the restart-process call
12#[derive(Debug, Clone, derive_builder::Builder, Serialize, Deserialize)]
13pub struct RestartProcess {}
14
15impl RestartProcess {
16    /// create a new builder for this endpoint
17    ///
18    /// this is usually the first step to calling this REST API endpoint
19    #[must_use]
20    pub fn builder() -> RestartProcessBuilder {
21        RestartProcessBuilder::default()
22    }
23}
24
25impl RestApiEndpoint for RestartProcess {
26    type RequestBody = RestartProcess;
27
28    fn method(&self) -> Result<reqwest::Method, crate::error::Error> {
29        Ok(reqwest::Method::POST)
30    }
31
32    fn url(&self, base_url: &url::Url) -> Result<url::Url, crate::error::Error> {
33        base_url
34            .join("v1/actions/restart-process")
35            .map_err(crate::error::Error::CouldNotParseUrlFragment)
36    }
37
38    fn request_body(
39        &self,
40    ) -> Result<Option<std::borrow::Cow<Self::RequestBody>>, crate::error::Error>
41    where
42        Self::RequestBody: Clone + serde::Serialize + std::fmt::Debug,
43    {
44        Ok(Some(std::borrow::Cow::Borrowed(self)))
45    }
46}
47
48impl RestApiResponse<RestartProcess> for ResultsWrapper<StatusResponse> {}