Skip to main content

clientapi_pve/apis/
nodes_certificates_api.rs

1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`nodes_certificates_get_acme`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum NodesCertificatesGetAcmeError {
22    Status400(models::PveError),
23    Status401(models::PveError),
24    Status403(models::PveError),
25    Status404(models::PveError),
26    Status500(models::PveError),
27    Status501(models::PveError),
28    Status503(models::PveError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`nodes_certificates_get_certificates`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum NodesCertificatesGetCertificatesError {
36    Status400(models::PveError),
37    Status401(models::PveError),
38    Status403(models::PveError),
39    Status404(models::PveError),
40    Status500(models::PveError),
41    Status501(models::PveError),
42    Status503(models::PveError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`nodes_certificates_info`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum NodesCertificatesInfoError {
50    Status400(models::PveError),
51    Status401(models::PveError),
52    Status403(models::PveError),
53    Status404(models::PveError),
54    Status500(models::PveError),
55    Status501(models::PveError),
56    Status503(models::PveError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`nodes_certificates_new_certificate`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum NodesCertificatesNewCertificateError {
64    Status400(models::PveError),
65    Status401(models::PveError),
66    Status403(models::PveError),
67    Status404(models::PveError),
68    Status500(models::PveError),
69    Status501(models::PveError),
70    Status503(models::PveError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`nodes_certificates_remove_custom_cert`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum NodesCertificatesRemoveCustomCertError {
78    Status400(models::PveError),
79    Status401(models::PveError),
80    Status403(models::PveError),
81    Status404(models::PveError),
82    Status500(models::PveError),
83    Status501(models::PveError),
84    Status503(models::PveError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`nodes_certificates_renew_certificate`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum NodesCertificatesRenewCertificateError {
92    Status400(models::PveError),
93    Status401(models::PveError),
94    Status403(models::PveError),
95    Status404(models::PveError),
96    Status500(models::PveError),
97    Status501(models::PveError),
98    Status503(models::PveError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`nodes_certificates_revoke_certificate`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum NodesCertificatesRevokeCertificateError {
106    Status400(models::PveError),
107    Status401(models::PveError),
108    Status403(models::PveError),
109    Status404(models::PveError),
110    Status500(models::PveError),
111    Status501(models::PveError),
112    Status503(models::PveError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`nodes_certificates_upload_custom_cert`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum NodesCertificatesUploadCustomCertError {
120    Status400(models::PveError),
121    Status401(models::PveError),
122    Status403(models::PveError),
123    Status404(models::PveError),
124    Status500(models::PveError),
125    Status501(models::PveError),
126    Status503(models::PveError),
127    UnknownValue(serde_json::Value),
128}
129
130
131/// ACME index.
132pub async fn nodes_certificates_get_acme(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCertificatesGetAcmeResponse, Error<NodesCertificatesGetAcmeError>> {
133    // add a prefix to parameters to efficiently prevent name collisions
134    let p_path_node = node;
135
136    let uri_str = format!("{}/nodes/{node}/certificates/acme", configuration.base_path, node=crate::apis::urlencode(p_path_node));
137    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
138
139    if let Some(ref user_agent) = configuration.user_agent {
140        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
141    }
142    if let Some(ref apikey) = configuration.api_key {
143        let key = apikey.key.clone();
144        let value = match apikey.prefix {
145            Some(ref prefix) => format!("{} {}", prefix, key),
146            None => key,
147        };
148        req_builder = req_builder.header("Authorization", value);
149    };
150    if let Some(ref apikey) = configuration.api_key {
151        let key = apikey.key.clone();
152        let value = match apikey.prefix {
153            Some(ref prefix) => format!("{} {}", prefix, key),
154            None => key,
155        };
156        req_builder = req_builder.header("CSRFPreventionToken", value);
157    };
158
159    let req = req_builder.build()?;
160    let resp = configuration.client.execute(req).await?;
161
162    let status = resp.status();
163    let content_type = resp
164        .headers()
165        .get("content-type")
166        .and_then(|v| v.to_str().ok())
167        .unwrap_or("application/octet-stream");
168    let content_type = super::ContentType::from(content_type);
169
170    if !status.is_client_error() && !status.is_server_error() {
171        let content = resp.text().await?;
172        match content_type {
173            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
174            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesGetAcmeResponse`"))),
175            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesGetAcmeResponse`")))),
176        }
177    } else {
178        let content = resp.text().await?;
179        let entity: Option<NodesCertificatesGetAcmeError> = serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent { status, content, entity }))
181    }
182}
183
184/// Node index.
185pub async fn nodes_certificates_get_certificates(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCertificatesGetCertificatesResponse, Error<NodesCertificatesGetCertificatesError>> {
186    // add a prefix to parameters to efficiently prevent name collisions
187    let p_path_node = node;
188
189    let uri_str = format!("{}/nodes/{node}/certificates", configuration.base_path, node=crate::apis::urlencode(p_path_node));
190    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
191
192    if let Some(ref user_agent) = configuration.user_agent {
193        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
194    }
195    if let Some(ref apikey) = configuration.api_key {
196        let key = apikey.key.clone();
197        let value = match apikey.prefix {
198            Some(ref prefix) => format!("{} {}", prefix, key),
199            None => key,
200        };
201        req_builder = req_builder.header("Authorization", value);
202    };
203    if let Some(ref apikey) = configuration.api_key {
204        let key = apikey.key.clone();
205        let value = match apikey.prefix {
206            Some(ref prefix) => format!("{} {}", prefix, key),
207            None => key,
208        };
209        req_builder = req_builder.header("CSRFPreventionToken", value);
210    };
211
212    let req = req_builder.build()?;
213    let resp = configuration.client.execute(req).await?;
214
215    let status = resp.status();
216    let content_type = resp
217        .headers()
218        .get("content-type")
219        .and_then(|v| v.to_str().ok())
220        .unwrap_or("application/octet-stream");
221    let content_type = super::ContentType::from(content_type);
222
223    if !status.is_client_error() && !status.is_server_error() {
224        let content = resp.text().await?;
225        match content_type {
226            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
227            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesGetCertificatesResponse`"))),
228            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesGetCertificatesResponse`")))),
229        }
230    } else {
231        let content = resp.text().await?;
232        let entity: Option<NodesCertificatesGetCertificatesError> = serde_json::from_str(&content).ok();
233        Err(Error::ResponseError(ResponseContent { status, content, entity }))
234    }
235}
236
237/// Get information about node's certificates.
238pub async fn nodes_certificates_info(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCertificatesInfoResponse, Error<NodesCertificatesInfoError>> {
239    // add a prefix to parameters to efficiently prevent name collisions
240    let p_path_node = node;
241
242    let uri_str = format!("{}/nodes/{node}/certificates/info", configuration.base_path, node=crate::apis::urlencode(p_path_node));
243    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
244
245    if let Some(ref user_agent) = configuration.user_agent {
246        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
247    }
248    if let Some(ref apikey) = configuration.api_key {
249        let key = apikey.key.clone();
250        let value = match apikey.prefix {
251            Some(ref prefix) => format!("{} {}", prefix, key),
252            None => key,
253        };
254        req_builder = req_builder.header("Authorization", value);
255    };
256    if let Some(ref apikey) = configuration.api_key {
257        let key = apikey.key.clone();
258        let value = match apikey.prefix {
259            Some(ref prefix) => format!("{} {}", prefix, key),
260            None => key,
261        };
262        req_builder = req_builder.header("CSRFPreventionToken", value);
263    };
264
265    let req = req_builder.build()?;
266    let resp = configuration.client.execute(req).await?;
267
268    let status = resp.status();
269    let content_type = resp
270        .headers()
271        .get("content-type")
272        .and_then(|v| v.to_str().ok())
273        .unwrap_or("application/octet-stream");
274    let content_type = super::ContentType::from(content_type);
275
276    if !status.is_client_error() && !status.is_server_error() {
277        let content = resp.text().await?;
278        match content_type {
279            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
280            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesInfoResponse`"))),
281            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesInfoResponse`")))),
282        }
283    } else {
284        let content = resp.text().await?;
285        let entity: Option<NodesCertificatesInfoError> = serde_json::from_str(&content).ok();
286        Err(Error::ResponseError(ResponseContent { status, content, entity }))
287    }
288}
289
290/// Order a new certificate from ACME-compatible CA.
291pub async fn nodes_certificates_new_certificate(configuration: &configuration::Configuration, node: &str, nodes_certificates_new_certificate_request: Option<models::NodesCertificatesNewCertificateRequest>) -> Result<models::NodesCertificatesNewCertificateResponse, Error<NodesCertificatesNewCertificateError>> {
292    // add a prefix to parameters to efficiently prevent name collisions
293    let p_path_node = node;
294    let p_body_nodes_certificates_new_certificate_request = nodes_certificates_new_certificate_request;
295
296    let uri_str = format!("{}/nodes/{node}/certificates/acme/certificate", configuration.base_path, node=crate::apis::urlencode(p_path_node));
297    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
298
299    if let Some(ref user_agent) = configuration.user_agent {
300        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
301    }
302    if let Some(ref apikey) = configuration.api_key {
303        let key = apikey.key.clone();
304        let value = match apikey.prefix {
305            Some(ref prefix) => format!("{} {}", prefix, key),
306            None => key,
307        };
308        req_builder = req_builder.header("Authorization", value);
309    };
310    if let Some(ref apikey) = configuration.api_key {
311        let key = apikey.key.clone();
312        let value = match apikey.prefix {
313            Some(ref prefix) => format!("{} {}", prefix, key),
314            None => key,
315        };
316        req_builder = req_builder.header("CSRFPreventionToken", value);
317    };
318    req_builder = req_builder.json(&p_body_nodes_certificates_new_certificate_request);
319
320    let req = req_builder.build()?;
321    let resp = configuration.client.execute(req).await?;
322
323    let status = resp.status();
324    let content_type = resp
325        .headers()
326        .get("content-type")
327        .and_then(|v| v.to_str().ok())
328        .unwrap_or("application/octet-stream");
329    let content_type = super::ContentType::from(content_type);
330
331    if !status.is_client_error() && !status.is_server_error() {
332        let content = resp.text().await?;
333        match content_type {
334            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
335            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesNewCertificateResponse`"))),
336            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesNewCertificateResponse`")))),
337        }
338    } else {
339        let content = resp.text().await?;
340        let entity: Option<NodesCertificatesNewCertificateError> = serde_json::from_str(&content).ok();
341        Err(Error::ResponseError(ResponseContent { status, content, entity }))
342    }
343}
344
345/// DELETE custom certificate chain and key.
346pub async fn nodes_certificates_remove_custom_cert(configuration: &configuration::Configuration, node: &str, restart: Option<&str>) -> Result<models::NodesCertificatesRemoveCustomCertResponse, Error<NodesCertificatesRemoveCustomCertError>> {
347    // add a prefix to parameters to efficiently prevent name collisions
348    let p_path_node = node;
349    let p_query_restart = restart;
350
351    let uri_str = format!("{}/nodes/{node}/certificates/custom", configuration.base_path, node=crate::apis::urlencode(p_path_node));
352    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
353
354    if let Some(ref param_value) = p_query_restart {
355        req_builder = req_builder.query(&[("restart", &param_value.to_string())]);
356    }
357    if let Some(ref user_agent) = configuration.user_agent {
358        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359    }
360    if let Some(ref apikey) = configuration.api_key {
361        let key = apikey.key.clone();
362        let value = match apikey.prefix {
363            Some(ref prefix) => format!("{} {}", prefix, key),
364            None => key,
365        };
366        req_builder = req_builder.header("Authorization", value);
367    };
368    if let Some(ref apikey) = configuration.api_key {
369        let key = apikey.key.clone();
370        let value = match apikey.prefix {
371            Some(ref prefix) => format!("{} {}", prefix, key),
372            None => key,
373        };
374        req_builder = req_builder.header("CSRFPreventionToken", value);
375    };
376
377    let req = req_builder.build()?;
378    let resp = configuration.client.execute(req).await?;
379
380    let status = resp.status();
381    let content_type = resp
382        .headers()
383        .get("content-type")
384        .and_then(|v| v.to_str().ok())
385        .unwrap_or("application/octet-stream");
386    let content_type = super::ContentType::from(content_type);
387
388    if !status.is_client_error() && !status.is_server_error() {
389        let content = resp.text().await?;
390        match content_type {
391            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
392            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesRemoveCustomCertResponse`"))),
393            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesRemoveCustomCertResponse`")))),
394        }
395    } else {
396        let content = resp.text().await?;
397        let entity: Option<NodesCertificatesRemoveCustomCertError> = serde_json::from_str(&content).ok();
398        Err(Error::ResponseError(ResponseContent { status, content, entity }))
399    }
400}
401
402/// Renew existing certificate from CA.
403pub async fn nodes_certificates_renew_certificate(configuration: &configuration::Configuration, node: &str, nodes_certificates_renew_certificate_request: Option<models::NodesCertificatesRenewCertificateRequest>) -> Result<models::NodesCertificatesRenewCertificateResponse, Error<NodesCertificatesRenewCertificateError>> {
404    // add a prefix to parameters to efficiently prevent name collisions
405    let p_path_node = node;
406    let p_body_nodes_certificates_renew_certificate_request = nodes_certificates_renew_certificate_request;
407
408    let uri_str = format!("{}/nodes/{node}/certificates/acme/certificate", configuration.base_path, node=crate::apis::urlencode(p_path_node));
409    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
410
411    if let Some(ref user_agent) = configuration.user_agent {
412        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413    }
414    if let Some(ref apikey) = configuration.api_key {
415        let key = apikey.key.clone();
416        let value = match apikey.prefix {
417            Some(ref prefix) => format!("{} {}", prefix, key),
418            None => key,
419        };
420        req_builder = req_builder.header("Authorization", value);
421    };
422    if let Some(ref apikey) = configuration.api_key {
423        let key = apikey.key.clone();
424        let value = match apikey.prefix {
425            Some(ref prefix) => format!("{} {}", prefix, key),
426            None => key,
427        };
428        req_builder = req_builder.header("CSRFPreventionToken", value);
429    };
430    req_builder = req_builder.json(&p_body_nodes_certificates_renew_certificate_request);
431
432    let req = req_builder.build()?;
433    let resp = configuration.client.execute(req).await?;
434
435    let status = resp.status();
436    let content_type = resp
437        .headers()
438        .get("content-type")
439        .and_then(|v| v.to_str().ok())
440        .unwrap_or("application/octet-stream");
441    let content_type = super::ContentType::from(content_type);
442
443    if !status.is_client_error() && !status.is_server_error() {
444        let content = resp.text().await?;
445        match content_type {
446            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
447            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesRenewCertificateResponse`"))),
448            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesRenewCertificateResponse`")))),
449        }
450    } else {
451        let content = resp.text().await?;
452        let entity: Option<NodesCertificatesRenewCertificateError> = serde_json::from_str(&content).ok();
453        Err(Error::ResponseError(ResponseContent { status, content, entity }))
454    }
455}
456
457/// Revoke existing certificate from CA.
458pub async fn nodes_certificates_revoke_certificate(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCertificatesRevokeCertificateResponse, Error<NodesCertificatesRevokeCertificateError>> {
459    // add a prefix to parameters to efficiently prevent name collisions
460    let p_path_node = node;
461
462    let uri_str = format!("{}/nodes/{node}/certificates/acme/certificate", configuration.base_path, node=crate::apis::urlencode(p_path_node));
463    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
464
465    if let Some(ref user_agent) = configuration.user_agent {
466        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
467    }
468    if let Some(ref apikey) = configuration.api_key {
469        let key = apikey.key.clone();
470        let value = match apikey.prefix {
471            Some(ref prefix) => format!("{} {}", prefix, key),
472            None => key,
473        };
474        req_builder = req_builder.header("Authorization", value);
475    };
476    if let Some(ref apikey) = configuration.api_key {
477        let key = apikey.key.clone();
478        let value = match apikey.prefix {
479            Some(ref prefix) => format!("{} {}", prefix, key),
480            None => key,
481        };
482        req_builder = req_builder.header("CSRFPreventionToken", value);
483    };
484
485    let req = req_builder.build()?;
486    let resp = configuration.client.execute(req).await?;
487
488    let status = resp.status();
489    let content_type = resp
490        .headers()
491        .get("content-type")
492        .and_then(|v| v.to_str().ok())
493        .unwrap_or("application/octet-stream");
494    let content_type = super::ContentType::from(content_type);
495
496    if !status.is_client_error() && !status.is_server_error() {
497        let content = resp.text().await?;
498        match content_type {
499            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
500            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesRevokeCertificateResponse`"))),
501            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesRevokeCertificateResponse`")))),
502        }
503    } else {
504        let content = resp.text().await?;
505        let entity: Option<NodesCertificatesRevokeCertificateError> = serde_json::from_str(&content).ok();
506        Err(Error::ResponseError(ResponseContent { status, content, entity }))
507    }
508}
509
510/// Upload or update custom certificate chain and key.
511pub async fn nodes_certificates_upload_custom_cert(configuration: &configuration::Configuration, node: &str, nodes_certificates_upload_custom_cert_request: models::NodesCertificatesUploadCustomCertRequest) -> Result<models::NodesCertificatesUploadCustomCertResponse, Error<NodesCertificatesUploadCustomCertError>> {
512    // add a prefix to parameters to efficiently prevent name collisions
513    let p_path_node = node;
514    let p_body_nodes_certificates_upload_custom_cert_request = nodes_certificates_upload_custom_cert_request;
515
516    let uri_str = format!("{}/nodes/{node}/certificates/custom", configuration.base_path, node=crate::apis::urlencode(p_path_node));
517    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
518
519    if let Some(ref user_agent) = configuration.user_agent {
520        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
521    }
522    if let Some(ref apikey) = configuration.api_key {
523        let key = apikey.key.clone();
524        let value = match apikey.prefix {
525            Some(ref prefix) => format!("{} {}", prefix, key),
526            None => key,
527        };
528        req_builder = req_builder.header("Authorization", value);
529    };
530    if let Some(ref apikey) = configuration.api_key {
531        let key = apikey.key.clone();
532        let value = match apikey.prefix {
533            Some(ref prefix) => format!("{} {}", prefix, key),
534            None => key,
535        };
536        req_builder = req_builder.header("CSRFPreventionToken", value);
537    };
538    req_builder = req_builder.json(&p_body_nodes_certificates_upload_custom_cert_request);
539
540    let req = req_builder.build()?;
541    let resp = configuration.client.execute(req).await?;
542
543    let status = resp.status();
544    let content_type = resp
545        .headers()
546        .get("content-type")
547        .and_then(|v| v.to_str().ok())
548        .unwrap_or("application/octet-stream");
549    let content_type = super::ContentType::from(content_type);
550
551    if !status.is_client_error() && !status.is_server_error() {
552        let content = resp.text().await?;
553        match content_type {
554            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
555            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCertificatesUploadCustomCertResponse`"))),
556            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCertificatesUploadCustomCertResponse`")))),
557        }
558    } else {
559        let content = resp.text().await?;
560        let entity: Option<NodesCertificatesUploadCustomCertError> = serde_json::from_str(&content).ok();
561        Err(Error::ResponseError(ResponseContent { status, content, entity }))
562    }
563}
564