Skip to main content

proxmox_api/generated/nodes/node/certificates/
custom.rs

1#[derive(Debug, Clone)]
2pub struct CustomClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> CustomClient<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, "/custom"),
14        }
15    }
16}
17impl<T> CustomClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "DELETE custom certificate chain and key."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
24    pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
25        let path = self.path.to_string();
26        self.client.delete(&path, &params).await
27    }
28}
29impl<T> CustomClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Upload or update custom certificate chain and key."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Modify\"])"]
36    pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
37        let path = self.path.to_string();
38        self.client.post(&path, &params).await
39    }
40}
41#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
42pub struct DeleteParams {
43    #[serde(
44        serialize_with = "crate::types::serialize_bool_optional",
45        deserialize_with = "crate::types::deserialize_bool_optional"
46    )]
47    #[serde(skip_serializing_if = "Option::is_none", default)]
48    #[doc = "Restart pveproxy."]
49    #[doc = ""]
50    pub restart: Option<bool>,
51    #[serde(
52        flatten,
53        default,
54        skip_serializing_if = "::std::collections::HashMap::is_empty"
55    )]
56    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
57}
58#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
59pub struct PostOutput {
60    #[serde(skip_serializing_if = "Option::is_none", default)]
61    pub filename: Option<String>,
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    #[doc = "Certificate SHA 256 fingerprint."]
64    #[doc = ""]
65    pub fingerprint: Option<FingerprintStr>,
66    #[serde(skip_serializing_if = "Option::is_none", default)]
67    #[doc = "Certificate issuer name."]
68    #[doc = ""]
69    pub issuer: Option<String>,
70    #[serde(
71        serialize_with = "crate::types::serialize_int_optional",
72        deserialize_with = "crate::types::deserialize_int_optional"
73    )]
74    #[serde(skip_serializing_if = "Option::is_none", default)]
75    #[doc = "Certificate's notAfter timestamp (UNIX epoch)."]
76    #[doc = ""]
77    pub notafter: Option<i64>,
78    #[serde(
79        serialize_with = "crate::types::serialize_int_optional",
80        deserialize_with = "crate::types::deserialize_int_optional"
81    )]
82    #[serde(skip_serializing_if = "Option::is_none", default)]
83    #[doc = "Certificate's notBefore timestamp (UNIX epoch)."]
84    #[doc = ""]
85    pub notbefore: Option<i64>,
86    #[serde(skip_serializing_if = "Option::is_none", default)]
87    #[doc = "Certificate in PEM format"]
88    #[doc = ""]
89    pub pem: Option<String>,
90    #[serde(rename = "public-key-bits")]
91    #[serde(
92        serialize_with = "crate::types::serialize_int_optional",
93        deserialize_with = "crate::types::deserialize_int_optional"
94    )]
95    #[serde(skip_serializing_if = "Option::is_none", default)]
96    #[doc = "Certificate's public key size"]
97    #[doc = ""]
98    pub public_key_bits: Option<i64>,
99    #[serde(rename = "public-key-type")]
100    #[serde(skip_serializing_if = "Option::is_none", default)]
101    #[doc = "Certificate's public key algorithm"]
102    #[doc = ""]
103    pub public_key_type: Option<String>,
104    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
105    #[doc = "List of Certificate's SubjectAlternativeName entries."]
106    #[doc = ""]
107    pub san: Vec<String>,
108    #[serde(skip_serializing_if = "Option::is_none", default)]
109    #[doc = "Certificate subject name."]
110    #[doc = ""]
111    pub subject: Option<String>,
112    #[serde(
113        flatten,
114        default,
115        skip_serializing_if = "::std::collections::HashMap::is_empty"
116    )]
117    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
118}
119impl PostParams {
120    pub fn new(certificates: String) -> Self {
121        Self {
122            certificates,
123            force: ::std::default::Default::default(),
124            key: ::std::default::Default::default(),
125            restart: ::std::default::Default::default(),
126            additional_properties: ::std::default::Default::default(),
127        }
128    }
129}
130#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
131pub struct PostParams {
132    #[doc = "PEM encoded certificate (chain)."]
133    #[doc = ""]
134    pub certificates: String,
135    #[serde(
136        serialize_with = "crate::types::serialize_bool_optional",
137        deserialize_with = "crate::types::deserialize_bool_optional"
138    )]
139    #[serde(skip_serializing_if = "Option::is_none", default)]
140    #[doc = "Overwrite existing custom or ACME certificate files."]
141    #[doc = ""]
142    pub force: Option<bool>,
143    #[serde(skip_serializing_if = "Option::is_none", default)]
144    #[doc = "PEM encoded private key."]
145    #[doc = ""]
146    pub key: Option<String>,
147    #[serde(
148        serialize_with = "crate::types::serialize_bool_optional",
149        deserialize_with = "crate::types::deserialize_bool_optional"
150    )]
151    #[serde(skip_serializing_if = "Option::is_none", default)]
152    #[doc = "Restart pveproxy."]
153    #[doc = ""]
154    pub restart: Option<bool>,
155    #[serde(
156        flatten,
157        default,
158        skip_serializing_if = "::std::collections::HashMap::is_empty"
159    )]
160    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
161}
162#[derive(Debug, Clone, PartialEq, PartialOrd)]
163pub struct FingerprintStr {
164    value: String,
165}
166impl crate::types::bounded_string::BoundedString for FingerprintStr {
167    const MIN_LENGTH: Option<usize> = None::<usize>;
168    const MAX_LENGTH: Option<usize> = None::<usize>;
169    const DEFAULT: Option<&'static str> = None::<&'static str>;
170    const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
171    const TYPE_DESCRIPTION: &'static str =
172        "a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
173    fn get_value(&self) -> &str {
174        &self.value
175    }
176    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
177        Self::validate(&value)?;
178        Ok(Self { value })
179    }
180}
181impl std::convert::TryFrom<String> for FingerprintStr {
182    type Error = crate::types::bounded_string::BoundedStringError;
183    fn try_from(value: String) -> Result<Self, Self::Error> {
184        crate::types::bounded_string::BoundedString::new(value)
185    }
186}
187impl ::serde::Serialize for FingerprintStr {
188    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
189    where
190        S: ::serde::Serializer,
191    {
192        crate::types::bounded_string::serialize_bounded_string(self, serializer)
193    }
194}
195impl<'de> ::serde::Deserialize<'de> for FingerprintStr {
196    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
197    where
198        D: ::serde::Deserializer<'de>,
199    {
200        crate::types::bounded_string::deserialize_bounded_string(deserializer)
201    }
202}