proxmox_api/generated/nodes/node/
subscription.rs1#[derive(Debug, Clone)]
2pub struct SubscriptionClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> SubscriptionClient<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, "/subscription"),
14 }
15 }
16}
17impl<T> SubscriptionClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Delete subscription key of this node."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
24 pub async fn delete(&self) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.delete(&path, &()).await
27 }
28}
29impl<T> SubscriptionClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Read subscription info."]
34 #[doc = ""]
35 pub async fn get(&self) -> Result<GetOutput, T::Error> {
36 let path = self.path.to_string();
37 self.client.get(&path, &()).await
38 }
39}
40impl<T> SubscriptionClient<T>
41where
42 T: crate::client::Client,
43{
44 #[doc = "Update subscription info."]
45 #[doc = ""]
46 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
47 pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
48 let path = self.path.to_string();
49 self.client.post(&path, ¶ms).await
50 }
51}
52impl<T> SubscriptionClient<T>
53where
54 T: crate::client::Client,
55{
56 #[doc = "Set subscription key."]
57 #[doc = ""]
58 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
59 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
60 let path = self.path.to_string();
61 self.client.put(&path, ¶ms).await
62 }
63}
64impl GetOutput {
65 pub fn new(status: Status) -> Self {
66 Self {
67 status,
68 checktime: ::std::default::Default::default(),
69 key: ::std::default::Default::default(),
70 level: ::std::default::Default::default(),
71 message: ::std::default::Default::default(),
72 nextduedate: ::std::default::Default::default(),
73 productname: ::std::default::Default::default(),
74 regdate: ::std::default::Default::default(),
75 serverid: ::std::default::Default::default(),
76 signature: ::std::default::Default::default(),
77 sockets: ::std::default::Default::default(),
78 url: ::std::default::Default::default(),
79 }
80 }
81}
82#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
83pub struct GetOutput {
84 #[serde(
85 serialize_with = "crate::types::serialize_int_optional",
86 deserialize_with = "crate::types::deserialize_int_optional"
87 )]
88 #[serde(skip_serializing_if = "Option::is_none", default)]
89 #[doc = "Timestamp of the last check done."]
90 #[doc = ""]
91 pub checktime: Option<i64>,
92 #[serde(skip_serializing_if = "Option::is_none", default)]
93 #[doc = "The subscription key, if set and permitted to access."]
94 #[doc = ""]
95 pub key: Option<String>,
96 #[serde(skip_serializing_if = "Option::is_none", default)]
97 #[doc = "A short code for the subscription level."]
98 #[doc = ""]
99 pub level: Option<String>,
100 #[serde(skip_serializing_if = "Option::is_none", default)]
101 #[doc = "A more human readable status message."]
102 #[doc = ""]
103 pub message: Option<String>,
104 #[serde(skip_serializing_if = "Option::is_none", default)]
105 #[doc = "Next due date of the set subscription."]
106 #[doc = ""]
107 pub nextduedate: Option<String>,
108 #[serde(skip_serializing_if = "Option::is_none", default)]
109 #[doc = "Human readable productname of the set subscription."]
110 #[doc = ""]
111 pub productname: Option<String>,
112 #[serde(skip_serializing_if = "Option::is_none", default)]
113 #[doc = "Register date of the set subscription."]
114 #[doc = ""]
115 pub regdate: Option<String>,
116 #[serde(skip_serializing_if = "Option::is_none", default)]
117 #[doc = "The server ID, if permitted to access."]
118 #[doc = ""]
119 pub serverid: Option<String>,
120 #[serde(skip_serializing_if = "Option::is_none", default)]
121 #[doc = "Signature for offline keys"]
122 #[doc = ""]
123 pub signature: Option<String>,
124 #[serde(
125 serialize_with = "crate::types::serialize_int_optional",
126 deserialize_with = "crate::types::deserialize_int_optional"
127 )]
128 #[serde(skip_serializing_if = "Option::is_none", default)]
129 #[doc = "The number of sockets for this host."]
130 #[doc = ""]
131 pub sockets: Option<i64>,
132 #[doc = "The current subscription status."]
133 #[doc = ""]
134 pub status: Status,
135 #[serde(skip_serializing_if = "Option::is_none", default)]
136 #[doc = "URL to the web shop."]
137 #[doc = ""]
138 pub url: Option<String>,
139}
140#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
141pub struct PostParams {
142 #[serde(
143 serialize_with = "crate::types::serialize_bool_optional",
144 deserialize_with = "crate::types::deserialize_bool_optional"
145 )]
146 #[serde(skip_serializing_if = "Option::is_none", default)]
147 #[doc = "Always connect to server, even if local cache is still valid."]
148 #[doc = ""]
149 pub force: Option<bool>,
150 #[serde(
151 flatten,
152 default,
153 skip_serializing_if = "::std::collections::HashMap::is_empty"
154 )]
155 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
156}
157impl PutParams {
158 pub fn new(key: KeyStr) -> Self {
159 Self {
160 key,
161 additional_properties: ::std::default::Default::default(),
162 }
163 }
164}
165#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
166pub struct PutParams {
167 #[doc = "Proxmox VE subscription key"]
168 #[doc = ""]
169 pub key: KeyStr,
170 #[serde(
171 flatten,
172 default,
173 skip_serializing_if = "::std::collections::HashMap::is_empty"
174 )]
175 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
176}
177#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
178#[doc = "The current subscription status."]
179#[doc = ""]
180pub enum Status {
181 #[serde(rename = "active")]
182 Active,
183 #[serde(rename = "expired")]
184 Expired,
185 #[serde(rename = "invalid")]
186 Invalid,
187 #[serde(rename = "new")]
188 New,
189 #[serde(rename = "notfound")]
190 Notfound,
191 #[serde(rename = "suspended")]
192 Suspended,
193}
194impl TryFrom<&str> for Status {
195 type Error = String;
196 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
197 match value {
198 "active" => Ok(Self::Active),
199 "expired" => Ok(Self::Expired),
200 "invalid" => Ok(Self::Invalid),
201 "new" => Ok(Self::New),
202 "notfound" => Ok(Self::Notfound),
203 "suspended" => Ok(Self::Suspended),
204 v => Err(format!("Unknown variant {v}")),
205 }
206 }
207}
208#[derive(Debug, Clone, PartialEq, PartialOrd)]
209pub struct KeyStr {
210 value: String,
211}
212impl crate::types::bounded_string::BoundedString for KeyStr {
213 const MIN_LENGTH: Option<usize> = None::<usize>;
214 const MAX_LENGTH: Option<usize> = Some(32usize);
215 const DEFAULT: Option<&'static str> = None::<&'static str>;
216 const PATTERN: Option<&'static str> = Some("\\s*pve([1248])([cbsp])-[0-9a-f]{10}\\s*");
217 const TYPE_DESCRIPTION: &'static str =
218 "a string with pattern r\"\\s*pve([1248])([cbsp])-[0-9a-f]{10}\\s*\" and length at most 32";
219 fn get_value(&self) -> &str {
220 &self.value
221 }
222 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
223 Self::validate(&value)?;
224 Ok(Self { value })
225 }
226}
227impl std::convert::TryFrom<String> for KeyStr {
228 type Error = crate::types::bounded_string::BoundedStringError;
229 fn try_from(value: String) -> Result<Self, Self::Error> {
230 crate::types::bounded_string::BoundedString::new(value)
231 }
232}
233impl ::serde::Serialize for KeyStr {
234 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
235 where
236 S: ::serde::Serializer,
237 {
238 crate::types::bounded_string::serialize_bounded_string(self, serializer)
239 }
240}
241impl<'de> ::serde::Deserialize<'de> for KeyStr {
242 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
243 where
244 D: ::serde::Deserializer<'de>,
245 {
246 crate::types::bounded_string::deserialize_bounded_string(deserializer)
247 }
248}