proxmox_api/generated/nodes/node/
time.rs1#[derive(Debug, Clone)]
2pub struct TimeClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> TimeClient<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, "/time"),
14 }
15 }
16}
17impl<T> TimeClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Read server time and time zone settings."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Audit\"])"]
24 pub async fn get(&self) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, &()).await
27 }
28}
29impl<T> TimeClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Set time zone."]
34 #[doc = ""]
35 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
36 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
37 let path = self.path.to_string();
38 self.client.put(&path, ¶ms).await
39 }
40}
41impl GetOutput {
42 pub fn new(localtime: LocaltimeInt, time: TimeInt, timezone: String) -> Self {
43 Self {
44 localtime,
45 time,
46 timezone,
47 }
48 }
49}
50#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
51pub struct GetOutput {
52 #[doc = "Seconds since 1970-01-01 00:00:00 (local time)"]
53 #[doc = ""]
54 pub localtime: LocaltimeInt,
55 #[doc = "Seconds since 1970-01-01 00:00:00 UTC."]
56 #[doc = ""]
57 pub time: TimeInt,
58 #[doc = "Time zone"]
59 #[doc = ""]
60 pub timezone: String,
61}
62impl PutParams {
63 pub fn new(timezone: String) -> Self {
64 Self {
65 timezone,
66 additional_properties: ::std::default::Default::default(),
67 }
68 }
69}
70#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
71pub struct PutParams {
72 #[doc = "Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names."]
73 #[doc = ""]
74 pub timezone: String,
75 #[serde(
76 flatten,
77 default,
78 skip_serializing_if = "::std::collections::HashMap::is_empty"
79 )]
80 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
81}
82#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
83pub struct LocaltimeInt(i128);
84impl crate::types::bounded_integer::BoundedInteger for LocaltimeInt {
85 const MIN: Option<i128> = Some(1297163644i128);
86 const MAX: Option<i128> = None::<i128>;
87 const DEFAULT: Option<i128> = None::<i128>;
88 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 1297163644";
89 fn get(&self) -> i128 {
90 self.0
91 }
92 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
93 Self::validate(value)?;
94 Ok(Self(value))
95 }
96}
97impl std::convert::TryFrom<i128> for LocaltimeInt {
98 type Error = crate::types::bounded_integer::BoundedIntegerError;
99 fn try_from(value: i128) -> Result<Self, Self::Error> {
100 crate::types::bounded_integer::BoundedInteger::new(value)
101 }
102}
103impl ::serde::Serialize for LocaltimeInt {
104 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
105 where
106 S: ::serde::Serializer,
107 {
108 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
109 }
110}
111impl<'de> ::serde::Deserialize<'de> for LocaltimeInt {
112 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
113 where
114 D: ::serde::Deserializer<'de>,
115 {
116 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
117 }
118}
119#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
120pub struct TimeInt(i128);
121impl crate::types::bounded_integer::BoundedInteger for TimeInt {
122 const MIN: Option<i128> = Some(1297163644i128);
123 const MAX: Option<i128> = None::<i128>;
124 const DEFAULT: Option<i128> = None::<i128>;
125 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 1297163644";
126 fn get(&self) -> i128 {
127 self.0
128 }
129 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
130 Self::validate(value)?;
131 Ok(Self(value))
132 }
133}
134impl std::convert::TryFrom<i128> for TimeInt {
135 type Error = crate::types::bounded_integer::BoundedIntegerError;
136 fn try_from(value: i128) -> Result<Self, Self::Error> {
137 crate::types::bounded_integer::BoundedInteger::new(value)
138 }
139}
140impl ::serde::Serialize for TimeInt {
141 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
142 where
143 S: ::serde::Serializer,
144 {
145 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
146 }
147}
148impl<'de> ::serde::Deserialize<'de> for TimeInt {
149 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
150 where
151 D: ::serde::Deserializer<'de>,
152 {
153 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
154 }
155}