Skip to main content

clientapi_pbs/apis/
config_acme_api.rs

1/*
2 * Proxmox Backup Server API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pbs.proxmox.com/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 [`config_acme_create_account`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ConfigAcmeCreateAccountError {
22    Status400(models::PbsError),
23    Status401(models::PbsError),
24    Status403(models::PbsError),
25    Status404(models::PbsError),
26    Status500(models::PbsError),
27    Status501(models::PbsError),
28    Status503(models::PbsError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`config_acme_create_plugins`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConfigAcmeCreatePluginsError {
36    Status400(models::PbsError),
37    Status401(models::PbsError),
38    Status403(models::PbsError),
39    Status404(models::PbsError),
40    Status500(models::PbsError),
41    Status501(models::PbsError),
42    Status503(models::PbsError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`config_acme_delete_account`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ConfigAcmeDeleteAccountError {
50    Status400(models::PbsError),
51    Status401(models::PbsError),
52    Status403(models::PbsError),
53    Status404(models::PbsError),
54    Status500(models::PbsError),
55    Status501(models::PbsError),
56    Status503(models::PbsError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`config_acme_delete_plugins`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ConfigAcmeDeletePluginsError {
64    Status400(models::PbsError),
65    Status401(models::PbsError),
66    Status403(models::PbsError),
67    Status404(models::PbsError),
68    Status500(models::PbsError),
69    Status501(models::PbsError),
70    Status503(models::PbsError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`config_acme_get_account`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConfigAcmeGetAccountError {
78    Status400(models::PbsError),
79    Status401(models::PbsError),
80    Status403(models::PbsError),
81    Status404(models::PbsError),
82    Status500(models::PbsError),
83    Status501(models::PbsError),
84    Status503(models::PbsError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`config_acme_get_acme`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ConfigAcmeGetAcmeError {
92    Status400(models::PbsError),
93    Status401(models::PbsError),
94    Status403(models::PbsError),
95    Status404(models::PbsError),
96    Status500(models::PbsError),
97    Status501(models::PbsError),
98    Status503(models::PbsError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`config_acme_get_challenge_schema`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ConfigAcmeGetChallengeSchemaError {
106    Status400(models::PbsError),
107    Status401(models::PbsError),
108    Status403(models::PbsError),
109    Status404(models::PbsError),
110    Status500(models::PbsError),
111    Status501(models::PbsError),
112    Status503(models::PbsError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`config_acme_get_config_acme_account_by_name`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ConfigAcmeGetConfigAcmeAccountByNameError {
120    Status400(models::PbsError),
121    Status401(models::PbsError),
122    Status403(models::PbsError),
123    Status404(models::PbsError),
124    Status500(models::PbsError),
125    Status501(models::PbsError),
126    Status503(models::PbsError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`config_acme_get_config_acme_plugins_by_id`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum ConfigAcmeGetConfigAcmePluginsByIdError {
134    Status400(models::PbsError),
135    Status401(models::PbsError),
136    Status403(models::PbsError),
137    Status404(models::PbsError),
138    Status500(models::PbsError),
139    Status501(models::PbsError),
140    Status503(models::PbsError),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`config_acme_get_directories`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum ConfigAcmeGetDirectoriesError {
148    Status400(models::PbsError),
149    Status401(models::PbsError),
150    Status403(models::PbsError),
151    Status404(models::PbsError),
152    Status500(models::PbsError),
153    Status501(models::PbsError),
154    Status503(models::PbsError),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`config_acme_get_plugins`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum ConfigAcmeGetPluginsError {
162    Status400(models::PbsError),
163    Status401(models::PbsError),
164    Status403(models::PbsError),
165    Status404(models::PbsError),
166    Status500(models::PbsError),
167    Status501(models::PbsError),
168    Status503(models::PbsError),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`config_acme_get_tos`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum ConfigAcmeGetTosError {
176    Status400(models::PbsError),
177    Status401(models::PbsError),
178    Status403(models::PbsError),
179    Status404(models::PbsError),
180    Status500(models::PbsError),
181    Status501(models::PbsError),
182    Status503(models::PbsError),
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`config_acme_update_account`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum ConfigAcmeUpdateAccountError {
190    Status400(models::PbsError),
191    Status401(models::PbsError),
192    Status403(models::PbsError),
193    Status404(models::PbsError),
194    Status500(models::PbsError),
195    Status501(models::PbsError),
196    Status503(models::PbsError),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`config_acme_update_plugins`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum ConfigAcmeUpdatePluginsError {
204    Status400(models::PbsError),
205    Status401(models::PbsError),
206    Status403(models::PbsError),
207    Status404(models::PbsError),
208    Status500(models::PbsError),
209    Status501(models::PbsError),
210    Status503(models::PbsError),
211    UnknownValue(serde_json::Value),
212}
213
214
215/// Register an ACME account.
216pub async fn config_acme_create_account(configuration: &configuration::Configuration, config_acme_create_account_request: models::ConfigAcmeCreateAccountRequest) -> Result<models::ConfigAcmeCreateAccountResponse, Error<ConfigAcmeCreateAccountError>> {
217    // add a prefix to parameters to efficiently prevent name collisions
218    let p_body_config_acme_create_account_request = config_acme_create_account_request;
219
220    let uri_str = format!("{}/config/acme/account", configuration.base_path);
221    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
222
223    if let Some(ref user_agent) = configuration.user_agent {
224        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225    }
226    if let Some(ref apikey) = configuration.api_key {
227        let key = apikey.key.clone();
228        let value = match apikey.prefix {
229            Some(ref prefix) => format!("{} {}", prefix, key),
230            None => key,
231        };
232        req_builder = req_builder.header("Authorization", value);
233    };
234    if let Some(ref apikey) = configuration.api_key {
235        let key = apikey.key.clone();
236        let value = match apikey.prefix {
237            Some(ref prefix) => format!("{} {}", prefix, key),
238            None => key,
239        };
240        req_builder = req_builder.header("CSRFPreventionToken", value);
241    };
242    req_builder = req_builder.json(&p_body_config_acme_create_account_request);
243
244    let req = req_builder.build()?;
245    let resp = configuration.client.execute(req).await?;
246
247    let status = resp.status();
248    let content_type = resp
249        .headers()
250        .get("content-type")
251        .and_then(|v| v.to_str().ok())
252        .unwrap_or("application/octet-stream");
253    let content_type = super::ContentType::from(content_type);
254
255    if !status.is_client_error() && !status.is_server_error() {
256        let content = resp.text().await?;
257        match content_type {
258            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
259            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeCreateAccountResponse`"))),
260            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::ConfigAcmeCreateAccountResponse`")))),
261        }
262    } else {
263        let content = resp.text().await?;
264        let entity: Option<ConfigAcmeCreateAccountError> = serde_json::from_str(&content).ok();
265        Err(Error::ResponseError(ResponseContent { status, content, entity }))
266    }
267}
268
269/// Add ACME plugin configuration.
270pub async fn config_acme_create_plugins(configuration: &configuration::Configuration, config_acme_create_plugins_request: models::ConfigAcmeCreatePluginsRequest) -> Result<models::ConfigAcmeCreatePluginsResponse, Error<ConfigAcmeCreatePluginsError>> {
271    // add a prefix to parameters to efficiently prevent name collisions
272    let p_body_config_acme_create_plugins_request = config_acme_create_plugins_request;
273
274    let uri_str = format!("{}/config/acme/plugins", configuration.base_path);
275    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
276
277    if let Some(ref user_agent) = configuration.user_agent {
278        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
279    }
280    if let Some(ref apikey) = configuration.api_key {
281        let key = apikey.key.clone();
282        let value = match apikey.prefix {
283            Some(ref prefix) => format!("{} {}", prefix, key),
284            None => key,
285        };
286        req_builder = req_builder.header("Authorization", value);
287    };
288    if let Some(ref apikey) = configuration.api_key {
289        let key = apikey.key.clone();
290        let value = match apikey.prefix {
291            Some(ref prefix) => format!("{} {}", prefix, key),
292            None => key,
293        };
294        req_builder = req_builder.header("CSRFPreventionToken", value);
295    };
296    req_builder = req_builder.json(&p_body_config_acme_create_plugins_request);
297
298    let req = req_builder.build()?;
299    let resp = configuration.client.execute(req).await?;
300
301    let status = resp.status();
302    let content_type = resp
303        .headers()
304        .get("content-type")
305        .and_then(|v| v.to_str().ok())
306        .unwrap_or("application/octet-stream");
307    let content_type = super::ContentType::from(content_type);
308
309    if !status.is_client_error() && !status.is_server_error() {
310        let content = resp.text().await?;
311        match content_type {
312            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
313            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeCreatePluginsResponse`"))),
314            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::ConfigAcmeCreatePluginsResponse`")))),
315        }
316    } else {
317        let content = resp.text().await?;
318        let entity: Option<ConfigAcmeCreatePluginsError> = serde_json::from_str(&content).ok();
319        Err(Error::ResponseError(ResponseContent { status, content, entity }))
320    }
321}
322
323/// Deactivate an ACME account.
324pub async fn config_acme_delete_account(configuration: &configuration::Configuration, name: &str, force: Option<bool>) -> Result<models::ConfigAcmeDeleteAccountResponse, Error<ConfigAcmeDeleteAccountError>> {
325    // add a prefix to parameters to efficiently prevent name collisions
326    let p_path_name = name;
327    let p_query_force = force;
328
329    let uri_str = format!("{}/config/acme/account/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
330    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
331
332    if let Some(ref param_value) = p_query_force {
333        req_builder = req_builder.query(&[("force", &param_value.to_string())]);
334    }
335    if let Some(ref user_agent) = configuration.user_agent {
336        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337    }
338    if let Some(ref apikey) = configuration.api_key {
339        let key = apikey.key.clone();
340        let value = match apikey.prefix {
341            Some(ref prefix) => format!("{} {}", prefix, key),
342            None => key,
343        };
344        req_builder = req_builder.header("Authorization", value);
345    };
346    if let Some(ref apikey) = configuration.api_key {
347        let key = apikey.key.clone();
348        let value = match apikey.prefix {
349            Some(ref prefix) => format!("{} {}", prefix, key),
350            None => key,
351        };
352        req_builder = req_builder.header("CSRFPreventionToken", value);
353    };
354
355    let req = req_builder.build()?;
356    let resp = configuration.client.execute(req).await?;
357
358    let status = resp.status();
359    let content_type = resp
360        .headers()
361        .get("content-type")
362        .and_then(|v| v.to_str().ok())
363        .unwrap_or("application/octet-stream");
364    let content_type = super::ContentType::from(content_type);
365
366    if !status.is_client_error() && !status.is_server_error() {
367        let content = resp.text().await?;
368        match content_type {
369            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeDeleteAccountResponse`"))),
371            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::ConfigAcmeDeleteAccountResponse`")))),
372        }
373    } else {
374        let content = resp.text().await?;
375        let entity: Option<ConfigAcmeDeleteAccountError> = serde_json::from_str(&content).ok();
376        Err(Error::ResponseError(ResponseContent { status, content, entity }))
377    }
378}
379
380/// Delete an ACME plugin configuration.
381pub async fn config_acme_delete_plugins(configuration: &configuration::Configuration, id: &str) -> Result<models::ConfigAcmeDeletePluginsResponse, Error<ConfigAcmeDeletePluginsError>> {
382    // add a prefix to parameters to efficiently prevent name collisions
383    let p_path_id = id;
384
385    let uri_str = format!("{}/config/acme/plugins/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
386    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
387
388    if let Some(ref user_agent) = configuration.user_agent {
389        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
390    }
391    if let Some(ref apikey) = configuration.api_key {
392        let key = apikey.key.clone();
393        let value = match apikey.prefix {
394            Some(ref prefix) => format!("{} {}", prefix, key),
395            None => key,
396        };
397        req_builder = req_builder.header("Authorization", value);
398    };
399    if let Some(ref apikey) = configuration.api_key {
400        let key = apikey.key.clone();
401        let value = match apikey.prefix {
402            Some(ref prefix) => format!("{} {}", prefix, key),
403            None => key,
404        };
405        req_builder = req_builder.header("CSRFPreventionToken", value);
406    };
407
408    let req = req_builder.build()?;
409    let resp = configuration.client.execute(req).await?;
410
411    let status = resp.status();
412    let content_type = resp
413        .headers()
414        .get("content-type")
415        .and_then(|v| v.to_str().ok())
416        .unwrap_or("application/octet-stream");
417    let content_type = super::ContentType::from(content_type);
418
419    if !status.is_client_error() && !status.is_server_error() {
420        let content = resp.text().await?;
421        match content_type {
422            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
423            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeDeletePluginsResponse`"))),
424            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::ConfigAcmeDeletePluginsResponse`")))),
425        }
426    } else {
427        let content = resp.text().await?;
428        let entity: Option<ConfigAcmeDeletePluginsError> = serde_json::from_str(&content).ok();
429        Err(Error::ResponseError(ResponseContent { status, content, entity }))
430    }
431}
432
433/// List ACME accounts.
434pub async fn config_acme_get_account(configuration: &configuration::Configuration, ) -> Result<models::ConfigAcmeGetAccountResponse, Error<ConfigAcmeGetAccountError>> {
435
436    let uri_str = format!("{}/config/acme/account", configuration.base_path);
437    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
438
439    if let Some(ref user_agent) = configuration.user_agent {
440        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
441    }
442    if let Some(ref apikey) = configuration.api_key {
443        let key = apikey.key.clone();
444        let value = match apikey.prefix {
445            Some(ref prefix) => format!("{} {}", prefix, key),
446            None => key,
447        };
448        req_builder = req_builder.header("Authorization", value);
449    };
450    if let Some(ref apikey) = configuration.api_key {
451        let key = apikey.key.clone();
452        let value = match apikey.prefix {
453            Some(ref prefix) => format!("{} {}", prefix, key),
454            None => key,
455        };
456        req_builder = req_builder.header("CSRFPreventionToken", value);
457    };
458
459    let req = req_builder.build()?;
460    let resp = configuration.client.execute(req).await?;
461
462    let status = resp.status();
463    let content_type = resp
464        .headers()
465        .get("content-type")
466        .and_then(|v| v.to_str().ok())
467        .unwrap_or("application/octet-stream");
468    let content_type = super::ContentType::from(content_type);
469
470    if !status.is_client_error() && !status.is_server_error() {
471        let content = resp.text().await?;
472        match content_type {
473            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
474            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetAccountResponse`"))),
475            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::ConfigAcmeGetAccountResponse`")))),
476        }
477    } else {
478        let content = resp.text().await?;
479        let entity: Option<ConfigAcmeGetAccountError> = serde_json::from_str(&content).ok();
480        Err(Error::ResponseError(ResponseContent { status, content, entity }))
481    }
482}
483
484/// Directory index.
485pub async fn config_acme_get_acme(configuration: &configuration::Configuration, ) -> Result<models::ConfigAcmeGetAcmeResponse, Error<ConfigAcmeGetAcmeError>> {
486
487    let uri_str = format!("{}/config/acme", configuration.base_path);
488    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
489
490    if let Some(ref user_agent) = configuration.user_agent {
491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492    }
493    if let Some(ref apikey) = configuration.api_key {
494        let key = apikey.key.clone();
495        let value = match apikey.prefix {
496            Some(ref prefix) => format!("{} {}", prefix, key),
497            None => key,
498        };
499        req_builder = req_builder.header("Authorization", value);
500    };
501    if let Some(ref apikey) = configuration.api_key {
502        let key = apikey.key.clone();
503        let value = match apikey.prefix {
504            Some(ref prefix) => format!("{} {}", prefix, key),
505            None => key,
506        };
507        req_builder = req_builder.header("CSRFPreventionToken", value);
508    };
509
510    let req = req_builder.build()?;
511    let resp = configuration.client.execute(req).await?;
512
513    let status = resp.status();
514    let content_type = resp
515        .headers()
516        .get("content-type")
517        .and_then(|v| v.to_str().ok())
518        .unwrap_or("application/octet-stream");
519    let content_type = super::ContentType::from(content_type);
520
521    if !status.is_client_error() && !status.is_server_error() {
522        let content = resp.text().await?;
523        match content_type {
524            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
525            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetAcmeResponse`"))),
526            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::ConfigAcmeGetAcmeResponse`")))),
527        }
528    } else {
529        let content = resp.text().await?;
530        let entity: Option<ConfigAcmeGetAcmeError> = serde_json::from_str(&content).ok();
531        Err(Error::ResponseError(ResponseContent { status, content, entity }))
532    }
533}
534
535/// Get named known ACME directory endpoints.
536pub async fn config_acme_get_challenge_schema(configuration: &configuration::Configuration, ) -> Result<models::ConfigAcmeGetChallengeSchemaResponse, Error<ConfigAcmeGetChallengeSchemaError>> {
537
538    let uri_str = format!("{}/config/acme/challenge-schema", configuration.base_path);
539    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
540
541    if let Some(ref user_agent) = configuration.user_agent {
542        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
543    }
544    if let Some(ref apikey) = configuration.api_key {
545        let key = apikey.key.clone();
546        let value = match apikey.prefix {
547            Some(ref prefix) => format!("{} {}", prefix, key),
548            None => key,
549        };
550        req_builder = req_builder.header("Authorization", value);
551    };
552    if let Some(ref apikey) = configuration.api_key {
553        let key = apikey.key.clone();
554        let value = match apikey.prefix {
555            Some(ref prefix) => format!("{} {}", prefix, key),
556            None => key,
557        };
558        req_builder = req_builder.header("CSRFPreventionToken", value);
559    };
560
561    let req = req_builder.build()?;
562    let resp = configuration.client.execute(req).await?;
563
564    let status = resp.status();
565    let content_type = resp
566        .headers()
567        .get("content-type")
568        .and_then(|v| v.to_str().ok())
569        .unwrap_or("application/octet-stream");
570    let content_type = super::ContentType::from(content_type);
571
572    if !status.is_client_error() && !status.is_server_error() {
573        let content = resp.text().await?;
574        match content_type {
575            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
576            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetChallengeSchemaResponse`"))),
577            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::ConfigAcmeGetChallengeSchemaResponse`")))),
578        }
579    } else {
580        let content = resp.text().await?;
581        let entity: Option<ConfigAcmeGetChallengeSchemaError> = serde_json::from_str(&content).ok();
582        Err(Error::ResponseError(ResponseContent { status, content, entity }))
583    }
584}
585
586/// Return existing ACME account information.
587pub async fn config_acme_get_config_acme_account_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::ConfigAcmeGetConfigAcmeAccountByNameResponse, Error<ConfigAcmeGetConfigAcmeAccountByNameError>> {
588    // add a prefix to parameters to efficiently prevent name collisions
589    let p_path_name = name;
590
591    let uri_str = format!("{}/config/acme/account/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
592    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
593
594    if let Some(ref user_agent) = configuration.user_agent {
595        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
596    }
597    if let Some(ref apikey) = configuration.api_key {
598        let key = apikey.key.clone();
599        let value = match apikey.prefix {
600            Some(ref prefix) => format!("{} {}", prefix, key),
601            None => key,
602        };
603        req_builder = req_builder.header("Authorization", value);
604    };
605    if let Some(ref apikey) = configuration.api_key {
606        let key = apikey.key.clone();
607        let value = match apikey.prefix {
608            Some(ref prefix) => format!("{} {}", prefix, key),
609            None => key,
610        };
611        req_builder = req_builder.header("CSRFPreventionToken", value);
612    };
613
614    let req = req_builder.build()?;
615    let resp = configuration.client.execute(req).await?;
616
617    let status = resp.status();
618    let content_type = resp
619        .headers()
620        .get("content-type")
621        .and_then(|v| v.to_str().ok())
622        .unwrap_or("application/octet-stream");
623    let content_type = super::ContentType::from(content_type);
624
625    if !status.is_client_error() && !status.is_server_error() {
626        let content = resp.text().await?;
627        match content_type {
628            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
629            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetConfigAcmeAccountByNameResponse`"))),
630            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::ConfigAcmeGetConfigAcmeAccountByNameResponse`")))),
631        }
632    } else {
633        let content = resp.text().await?;
634        let entity: Option<ConfigAcmeGetConfigAcmeAccountByNameError> = serde_json::from_str(&content).ok();
635        Err(Error::ResponseError(ResponseContent { status, content, entity }))
636    }
637}
638
639/// List ACME challenge plugins.
640pub async fn config_acme_get_config_acme_plugins_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::ConfigAcmeGetConfigAcmePluginsByIdResponse, Error<ConfigAcmeGetConfigAcmePluginsByIdError>> {
641    // add a prefix to parameters to efficiently prevent name collisions
642    let p_path_id = id;
643
644    let uri_str = format!("{}/config/acme/plugins/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
645    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
646
647    if let Some(ref user_agent) = configuration.user_agent {
648        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
649    }
650    if let Some(ref apikey) = configuration.api_key {
651        let key = apikey.key.clone();
652        let value = match apikey.prefix {
653            Some(ref prefix) => format!("{} {}", prefix, key),
654            None => key,
655        };
656        req_builder = req_builder.header("Authorization", value);
657    };
658    if let Some(ref apikey) = configuration.api_key {
659        let key = apikey.key.clone();
660        let value = match apikey.prefix {
661            Some(ref prefix) => format!("{} {}", prefix, key),
662            None => key,
663        };
664        req_builder = req_builder.header("CSRFPreventionToken", value);
665    };
666
667    let req = req_builder.build()?;
668    let resp = configuration.client.execute(req).await?;
669
670    let status = resp.status();
671    let content_type = resp
672        .headers()
673        .get("content-type")
674        .and_then(|v| v.to_str().ok())
675        .unwrap_or("application/octet-stream");
676    let content_type = super::ContentType::from(content_type);
677
678    if !status.is_client_error() && !status.is_server_error() {
679        let content = resp.text().await?;
680        match content_type {
681            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
682            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetConfigAcmePluginsByIdResponse`"))),
683            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::ConfigAcmeGetConfigAcmePluginsByIdResponse`")))),
684        }
685    } else {
686        let content = resp.text().await?;
687        let entity: Option<ConfigAcmeGetConfigAcmePluginsByIdError> = serde_json::from_str(&content).ok();
688        Err(Error::ResponseError(ResponseContent { status, content, entity }))
689    }
690}
691
692/// Get named known ACME directory endpoints.
693pub async fn config_acme_get_directories(configuration: &configuration::Configuration, ) -> Result<models::ConfigAcmeGetDirectoriesResponse, Error<ConfigAcmeGetDirectoriesError>> {
694
695    let uri_str = format!("{}/config/acme/directories", configuration.base_path);
696    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
697
698    if let Some(ref user_agent) = configuration.user_agent {
699        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
700    }
701    if let Some(ref apikey) = configuration.api_key {
702        let key = apikey.key.clone();
703        let value = match apikey.prefix {
704            Some(ref prefix) => format!("{} {}", prefix, key),
705            None => key,
706        };
707        req_builder = req_builder.header("Authorization", value);
708    };
709    if let Some(ref apikey) = configuration.api_key {
710        let key = apikey.key.clone();
711        let value = match apikey.prefix {
712            Some(ref prefix) => format!("{} {}", prefix, key),
713            None => key,
714        };
715        req_builder = req_builder.header("CSRFPreventionToken", value);
716    };
717
718    let req = req_builder.build()?;
719    let resp = configuration.client.execute(req).await?;
720
721    let status = resp.status();
722    let content_type = resp
723        .headers()
724        .get("content-type")
725        .and_then(|v| v.to_str().ok())
726        .unwrap_or("application/octet-stream");
727    let content_type = super::ContentType::from(content_type);
728
729    if !status.is_client_error() && !status.is_server_error() {
730        let content = resp.text().await?;
731        match content_type {
732            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
733            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetDirectoriesResponse`"))),
734            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::ConfigAcmeGetDirectoriesResponse`")))),
735        }
736    } else {
737        let content = resp.text().await?;
738        let entity: Option<ConfigAcmeGetDirectoriesError> = serde_json::from_str(&content).ok();
739        Err(Error::ResponseError(ResponseContent { status, content, entity }))
740    }
741}
742
743/// List ACME challenge plugins.
744pub async fn config_acme_get_plugins(configuration: &configuration::Configuration, ) -> Result<models::ConfigAcmeGetPluginsResponse, Error<ConfigAcmeGetPluginsError>> {
745
746    let uri_str = format!("{}/config/acme/plugins", configuration.base_path);
747    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
748
749    if let Some(ref user_agent) = configuration.user_agent {
750        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
751    }
752    if let Some(ref apikey) = configuration.api_key {
753        let key = apikey.key.clone();
754        let value = match apikey.prefix {
755            Some(ref prefix) => format!("{} {}", prefix, key),
756            None => key,
757        };
758        req_builder = req_builder.header("Authorization", value);
759    };
760    if let Some(ref apikey) = configuration.api_key {
761        let key = apikey.key.clone();
762        let value = match apikey.prefix {
763            Some(ref prefix) => format!("{} {}", prefix, key),
764            None => key,
765        };
766        req_builder = req_builder.header("CSRFPreventionToken", value);
767    };
768
769    let req = req_builder.build()?;
770    let resp = configuration.client.execute(req).await?;
771
772    let status = resp.status();
773    let content_type = resp
774        .headers()
775        .get("content-type")
776        .and_then(|v| v.to_str().ok())
777        .unwrap_or("application/octet-stream");
778    let content_type = super::ContentType::from(content_type);
779
780    if !status.is_client_error() && !status.is_server_error() {
781        let content = resp.text().await?;
782        match content_type {
783            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
784            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetPluginsResponse`"))),
785            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::ConfigAcmeGetPluginsResponse`")))),
786        }
787    } else {
788        let content = resp.text().await?;
789        let entity: Option<ConfigAcmeGetPluginsError> = serde_json::from_str(&content).ok();
790        Err(Error::ResponseError(ResponseContent { status, content, entity }))
791    }
792}
793
794/// Get the Terms of Service URL for an ACME directory.
795pub async fn config_acme_get_tos(configuration: &configuration::Configuration, directory: Option<&str>) -> Result<models::ConfigAcmeGetTosResponse, Error<ConfigAcmeGetTosError>> {
796    // add a prefix to parameters to efficiently prevent name collisions
797    let p_query_directory = directory;
798
799    let uri_str = format!("{}/config/acme/tos", configuration.base_path);
800    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
801
802    if let Some(ref param_value) = p_query_directory {
803        req_builder = req_builder.query(&[("directory", &param_value.to_string())]);
804    }
805    if let Some(ref user_agent) = configuration.user_agent {
806        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
807    }
808    if let Some(ref apikey) = configuration.api_key {
809        let key = apikey.key.clone();
810        let value = match apikey.prefix {
811            Some(ref prefix) => format!("{} {}", prefix, key),
812            None => key,
813        };
814        req_builder = req_builder.header("Authorization", value);
815    };
816    if let Some(ref apikey) = configuration.api_key {
817        let key = apikey.key.clone();
818        let value = match apikey.prefix {
819            Some(ref prefix) => format!("{} {}", prefix, key),
820            None => key,
821        };
822        req_builder = req_builder.header("CSRFPreventionToken", value);
823    };
824
825    let req = req_builder.build()?;
826    let resp = configuration.client.execute(req).await?;
827
828    let status = resp.status();
829    let content_type = resp
830        .headers()
831        .get("content-type")
832        .and_then(|v| v.to_str().ok())
833        .unwrap_or("application/octet-stream");
834    let content_type = super::ContentType::from(content_type);
835
836    if !status.is_client_error() && !status.is_server_error() {
837        let content = resp.text().await?;
838        match content_type {
839            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
840            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeGetTosResponse`"))),
841            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::ConfigAcmeGetTosResponse`")))),
842        }
843    } else {
844        let content = resp.text().await?;
845        let entity: Option<ConfigAcmeGetTosError> = serde_json::from_str(&content).ok();
846        Err(Error::ResponseError(ResponseContent { status, content, entity }))
847    }
848}
849
850/// Update an ACME account.
851pub async fn config_acme_update_account(configuration: &configuration::Configuration, name: &str, config_acme_update_account_request: Option<models::ConfigAcmeUpdateAccountRequest>) -> Result<models::ConfigAcmeUpdateAccountResponse, Error<ConfigAcmeUpdateAccountError>> {
852    // add a prefix to parameters to efficiently prevent name collisions
853    let p_path_name = name;
854    let p_body_config_acme_update_account_request = config_acme_update_account_request;
855
856    let uri_str = format!("{}/config/acme/account/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name));
857    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
858
859    if let Some(ref user_agent) = configuration.user_agent {
860        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
861    }
862    if let Some(ref apikey) = configuration.api_key {
863        let key = apikey.key.clone();
864        let value = match apikey.prefix {
865            Some(ref prefix) => format!("{} {}", prefix, key),
866            None => key,
867        };
868        req_builder = req_builder.header("Authorization", value);
869    };
870    if let Some(ref apikey) = configuration.api_key {
871        let key = apikey.key.clone();
872        let value = match apikey.prefix {
873            Some(ref prefix) => format!("{} {}", prefix, key),
874            None => key,
875        };
876        req_builder = req_builder.header("CSRFPreventionToken", value);
877    };
878    req_builder = req_builder.json(&p_body_config_acme_update_account_request);
879
880    let req = req_builder.build()?;
881    let resp = configuration.client.execute(req).await?;
882
883    let status = resp.status();
884    let content_type = resp
885        .headers()
886        .get("content-type")
887        .and_then(|v| v.to_str().ok())
888        .unwrap_or("application/octet-stream");
889    let content_type = super::ContentType::from(content_type);
890
891    if !status.is_client_error() && !status.is_server_error() {
892        let content = resp.text().await?;
893        match content_type {
894            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
895            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeUpdateAccountResponse`"))),
896            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::ConfigAcmeUpdateAccountResponse`")))),
897        }
898    } else {
899        let content = resp.text().await?;
900        let entity: Option<ConfigAcmeUpdateAccountError> = serde_json::from_str(&content).ok();
901        Err(Error::ResponseError(ResponseContent { status, content, entity }))
902    }
903}
904
905/// Update an ACME plugin configuration.
906pub async fn config_acme_update_plugins(configuration: &configuration::Configuration, id: &str, config_acme_update_plugins_request: Option<models::ConfigAcmeUpdatePluginsRequest>) -> Result<models::ConfigAcmeUpdatePluginsResponse, Error<ConfigAcmeUpdatePluginsError>> {
907    // add a prefix to parameters to efficiently prevent name collisions
908    let p_path_id = id;
909    let p_body_config_acme_update_plugins_request = config_acme_update_plugins_request;
910
911    let uri_str = format!("{}/config/acme/plugins/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
912    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
913
914    if let Some(ref user_agent) = configuration.user_agent {
915        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
916    }
917    if let Some(ref apikey) = configuration.api_key {
918        let key = apikey.key.clone();
919        let value = match apikey.prefix {
920            Some(ref prefix) => format!("{} {}", prefix, key),
921            None => key,
922        };
923        req_builder = req_builder.header("Authorization", value);
924    };
925    if let Some(ref apikey) = configuration.api_key {
926        let key = apikey.key.clone();
927        let value = match apikey.prefix {
928            Some(ref prefix) => format!("{} {}", prefix, key),
929            None => key,
930        };
931        req_builder = req_builder.header("CSRFPreventionToken", value);
932    };
933    req_builder = req_builder.json(&p_body_config_acme_update_plugins_request);
934
935    let req = req_builder.build()?;
936    let resp = configuration.client.execute(req).await?;
937
938    let status = resp.status();
939    let content_type = resp
940        .headers()
941        .get("content-type")
942        .and_then(|v| v.to_str().ok())
943        .unwrap_or("application/octet-stream");
944    let content_type = super::ContentType::from(content_type);
945
946    if !status.is_client_error() && !status.is_server_error() {
947        let content = resp.text().await?;
948        match content_type {
949            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
950            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigAcmeUpdatePluginsResponse`"))),
951            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::ConfigAcmeUpdatePluginsResponse`")))),
952        }
953    } else {
954        let content = resp.text().await?;
955        let entity: Option<ConfigAcmeUpdatePluginsError> = serde_json::from_str(&content).ok();
956        Err(Error::ResponseError(ResponseContent { status, content, entity }))
957    }
958}
959