Skip to main content

proxmox_api/generated/nodes/node/lxc/vmid/status/
shutdown.rs

1#[derive(Debug, Clone)]
2pub struct ShutdownClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> ShutdownClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/shutdown"),
14        }
15    }
16}
17impl<T> ShutdownClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Shutdown the container. This will trigger a clean shutdown of the container, see lxc-stop(1) for details."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.PowerMgmt\"])"]
24    pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
25        let path = self.path.to_string();
26        self.client.post(&path, &params).await
27    }
28}
29#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
30pub struct PostParams {
31    #[serde(rename = "forceStop")]
32    #[serde(
33        serialize_with = "crate::types::serialize_bool_optional",
34        deserialize_with = "crate::types::deserialize_bool_optional"
35    )]
36    #[serde(skip_serializing_if = "Option::is_none", default)]
37    #[doc = "Make sure the Container stops."]
38    #[doc = ""]
39    pub forcestop: Option<bool>,
40    #[serde(skip_serializing_if = "Option::is_none", default)]
41    #[doc = "Wait maximal timeout seconds."]
42    #[doc = ""]
43    pub timeout: Option<TimeoutInt>,
44    #[serde(
45        flatten,
46        default,
47        skip_serializing_if = "::std::collections::HashMap::is_empty"
48    )]
49    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
50}
51#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
52pub struct TimeoutInt(i128);
53impl crate::types::bounded_integer::BoundedInteger for TimeoutInt {
54    const MIN: Option<i128> = Some(0i128);
55    const MAX: Option<i128> = None::<i128>;
56    const DEFAULT: Option<i128> = Some(60i128);
57    const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
58    fn get(&self) -> i128 {
59        self.0
60    }
61    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
62        Self::validate(value)?;
63        Ok(Self(value))
64    }
65}
66impl std::convert::TryFrom<i128> for TimeoutInt {
67    type Error = crate::types::bounded_integer::BoundedIntegerError;
68    fn try_from(value: i128) -> Result<Self, Self::Error> {
69        crate::types::bounded_integer::BoundedInteger::new(value)
70    }
71}
72impl ::serde::Serialize for TimeoutInt {
73    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
74    where
75        S: ::serde::Serializer,
76    {
77        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
78    }
79}
80impl<'de> ::serde::Deserialize<'de> for TimeoutInt {
81    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
82    where
83        D: ::serde::Deserializer<'de>,
84    {
85        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
86    }
87}