hcloud/apis/
certificates_api.rs

1/*
2 * Hetzner Cloud API
3 *
4 * Copied from the official API documentation for the Public Hetzner Cloud.
5 *
6 * The version of the OpenAPI document: 0.28.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize};
15
16/// struct for passing parameters to the method [`create_certificate`]
17#[derive(Clone, Debug, Default)]
18pub struct CreateCertificateParams {
19    pub create_certificate_request: models::CreateCertificateRequest,
20}
21
22/// struct for passing parameters to the method [`delete_certificate`]
23#[derive(Clone, Debug, Default)]
24pub struct DeleteCertificateParams {
25    /// ID of the Certificate.
26    pub id: i64,
27}
28
29/// struct for passing parameters to the method [`get_action_for_certificate`]
30#[derive(Clone, Debug, Default)]
31pub struct GetActionForCertificateParams {
32    /// ID of the Certificate.
33    pub id: i64,
34    /// ID of the Action.
35    pub action_id: i64,
36}
37
38/// struct for passing parameters to the method [`get_certificate`]
39#[derive(Clone, Debug, Default)]
40pub struct GetCertificateParams {
41    /// ID of the Certificate.
42    pub id: i64,
43}
44
45/// struct for passing parameters to the method [`get_certificate_action`]
46#[derive(Clone, Debug, Default)]
47pub struct GetCertificateActionParams {
48    /// ID of the Action.
49    pub id: i64,
50}
51
52/// struct for passing parameters to the method [`list_actions_for_certificate`]
53#[derive(Clone, Debug, Default)]
54pub struct ListActionsForCertificateParams {
55    /// ID of the Certificate.
56    pub id: i64,
57    /// Sort actions by field and direction. Can be used multiple times. For more information, see \"Sorting\".
58    pub sort: Option<Vec<String>>,
59    /// Filter the actions by status. Can be used multiple times. The response will only contain actions matching the specified statuses.
60    pub status: Option<Vec<String>>,
61    /// Page number to return. For more information, see \"Pagination\".
62    pub page: Option<i64>,
63    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
64    pub per_page: Option<i64>,
65}
66
67/// struct for passing parameters to the method [`list_certificate_actions`]
68#[derive(Clone, Debug, Default)]
69pub struct ListCertificateActionsParams {
70    /// Filter the actions by ID. Can be used multiple times. The response will only contain actions matching the specified IDs.
71    pub id: Option<Vec<i64>>,
72    /// Sort actions by field and direction. Can be used multiple times. For more information, see \"Sorting\".
73    pub sort: Option<Vec<String>>,
74    /// Filter the actions by status. Can be used multiple times. The response will only contain actions matching the specified statuses.
75    pub status: Option<Vec<String>>,
76    /// Page number to return. For more information, see \"Pagination\".
77    pub page: Option<i64>,
78    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
79    pub per_page: Option<i64>,
80}
81
82/// struct for passing parameters to the method [`list_certificates`]
83#[derive(Clone, Debug, Default)]
84pub struct ListCertificatesParams {
85    /// Sort resources by field and direction. Can be used multiple times. For more information, see \"Sorting\".
86    pub sort: Option<Vec<String>>,
87    /// Filter resources by their name. The response will only contain the resources matching exactly the specified name.
88    pub name: Option<String>,
89    /// Filter resources by labels. The response will only contain resources matching the label selector. For more information, see \"Label Selector\".
90    pub label_selector: Option<String>,
91    /// Filter resources by type. Can be used multiple times. The response will only contain the resources with the specified type.
92    pub r#type: Option<Vec<String>>,
93    /// Page number to return. For more information, see \"Pagination\".
94    pub page: Option<i64>,
95    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
96    pub per_page: Option<i64>,
97}
98
99/// struct for passing parameters to the method [`replace_certificate`]
100#[derive(Clone, Debug, Default)]
101pub struct ReplaceCertificateParams {
102    /// ID of the Certificate.
103    pub id: i64,
104    pub replace_certificate_request: models::ReplaceCertificateRequest,
105}
106
107/// struct for passing parameters to the method [`retry_issuance_or_renewal`]
108#[derive(Clone, Debug, Default)]
109pub struct RetryIssuanceOrRenewalParams {
110    /// ID of the Certificate.
111    pub id: i64,
112}
113
114/// struct for typed errors of method [`create_certificate`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum CreateCertificateError {
118    UnknownValue(serde_json::Value),
119}
120
121/// struct for typed errors of method [`delete_certificate`]
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum DeleteCertificateError {
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`get_action_for_certificate`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum GetActionForCertificateError {
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`get_certificate`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum GetCertificateError {
139    UnknownValue(serde_json::Value),
140}
141
142/// struct for typed errors of method [`get_certificate_action`]
143#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum GetCertificateActionError {
146    UnknownValue(serde_json::Value),
147}
148
149/// struct for typed errors of method [`list_actions_for_certificate`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum ListActionsForCertificateError {
153    UnknownValue(serde_json::Value),
154}
155
156/// struct for typed errors of method [`list_certificate_actions`]
157#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum ListCertificateActionsError {
160    UnknownValue(serde_json::Value),
161}
162
163/// struct for typed errors of method [`list_certificates`]
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum ListCertificatesError {
167    UnknownValue(serde_json::Value),
168}
169
170/// struct for typed errors of method [`replace_certificate`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum ReplaceCertificateError {
174    UnknownValue(serde_json::Value),
175}
176
177/// struct for typed errors of method [`retry_issuance_or_renewal`]
178#[derive(Debug, Clone, Serialize, Deserialize)]
179#[serde(untagged)]
180pub enum RetryIssuanceOrRenewalError {
181    UnknownValue(serde_json::Value),
182}
183
184/// Creates a new Certificate.  The default type **uploaded** allows for uploading your existing `certificate` and `private_key` in PEM format. You have to monitor its expiration date and handle renewal yourself.  In contrast, type **managed** requests a new Certificate from *Let's Encrypt* for the specified `domain_names`. Only domains managed by *Hetzner DNS* are supported. We handle renewal and timely alert the project owner via email if problems occur.  For type `managed` Certificates the `action` key of the response contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null.
185pub async fn create_certificate(
186    configuration: &configuration::Configuration,
187    params: CreateCertificateParams,
188) -> Result<models::CreateCertificateResponse, Error<CreateCertificateError>> {
189    let local_var_configuration = configuration;
190
191    // unbox the parameters
192    let create_certificate_request = params.create_certificate_request;
193
194    let local_var_client = &local_var_configuration.client;
195
196    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
197    let local_var_uri_str = format!("{}/certificates", local_base_path);
198    let mut local_var_req_builder =
199        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
200
201    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202        local_var_req_builder =
203            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
204    }
205    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
206        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
207    };
208    local_var_req_builder = local_var_req_builder.json(&create_certificate_request);
209
210    let local_var_req = local_var_req_builder.build()?;
211    let local_var_resp = local_var_client.execute(local_var_req).await?;
212
213    let local_var_status = local_var_resp.status();
214    let local_var_content = local_var_resp.text().await?;
215
216    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
217        serde_json::from_str(&local_var_content).map_err(Error::from)
218    } else {
219        let local_var_entity: Option<CreateCertificateError> =
220            serde_json::from_str(&local_var_content).ok();
221        let local_var_error = ResponseContent {
222            status: local_var_status,
223            content: local_var_content,
224            entity: local_var_entity,
225        };
226        Err(Error::ResponseError(local_var_error))
227    }
228}
229
230/// Deletes a Certificate.
231pub async fn delete_certificate(
232    configuration: &configuration::Configuration,
233    params: DeleteCertificateParams,
234) -> Result<(), Error<DeleteCertificateError>> {
235    let local_var_configuration = configuration;
236
237    // unbox the parameters
238    let id = params.id;
239
240    let local_var_client = &local_var_configuration.client;
241
242    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
243    let local_var_uri_str = format!("{}/certificates/{id}", local_base_path, id = id);
244    let mut local_var_req_builder =
245        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
246
247    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
248        local_var_req_builder =
249            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
250    }
251    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
252        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
253    };
254
255    let local_var_req = local_var_req_builder.build()?;
256    let local_var_resp = local_var_client.execute(local_var_req).await?;
257
258    let local_var_status = local_var_resp.status();
259    let local_var_content = local_var_resp.text().await?;
260
261    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
262        Ok(())
263    } else {
264        let local_var_entity: Option<DeleteCertificateError> =
265            serde_json::from_str(&local_var_content).ok();
266        let local_var_error = ResponseContent {
267            status: local_var_status,
268            content: local_var_content,
269            entity: local_var_entity,
270        };
271        Err(Error::ResponseError(local_var_error))
272    }
273}
274
275/// Returns a specific Action for a Certificate. Only type `managed` Certificates have Actions.
276pub async fn get_action_for_certificate(
277    configuration: &configuration::Configuration,
278    params: GetActionForCertificateParams,
279) -> Result<models::GetActionResponse, Error<GetActionForCertificateError>> {
280    let local_var_configuration = configuration;
281
282    // unbox the parameters
283    let id = params.id;
284    let action_id = params.action_id;
285
286    let local_var_client = &local_var_configuration.client;
287
288    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
289    let local_var_uri_str = format!(
290        "{}/certificates/{id}/actions/{action_id}",
291        local_base_path,
292        id = id,
293        action_id = action_id
294    );
295    let mut local_var_req_builder =
296        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
297
298    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
299        local_var_req_builder =
300            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
301    }
302    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
303        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
304    };
305
306    let local_var_req = local_var_req_builder.build()?;
307    let local_var_resp = local_var_client.execute(local_var_req).await?;
308
309    let local_var_status = local_var_resp.status();
310    let local_var_content = local_var_resp.text().await?;
311
312    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
313        serde_json::from_str(&local_var_content).map_err(Error::from)
314    } else {
315        let local_var_entity: Option<GetActionForCertificateError> =
316            serde_json::from_str(&local_var_content).ok();
317        let local_var_error = ResponseContent {
318            status: local_var_status,
319            content: local_var_content,
320            entity: local_var_entity,
321        };
322        Err(Error::ResponseError(local_var_error))
323    }
324}
325
326/// Gets a specific Certificate object.
327pub async fn get_certificate(
328    configuration: &configuration::Configuration,
329    params: GetCertificateParams,
330) -> Result<models::GetCertificateResponse, Error<GetCertificateError>> {
331    let local_var_configuration = configuration;
332
333    // unbox the parameters
334    let id = params.id;
335
336    let local_var_client = &local_var_configuration.client;
337
338    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
339    let local_var_uri_str = format!("{}/certificates/{id}", local_base_path, id = id);
340    let mut local_var_req_builder =
341        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
342
343    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
344        local_var_req_builder =
345            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346    }
347    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
348        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
349    };
350
351    let local_var_req = local_var_req_builder.build()?;
352    let local_var_resp = local_var_client.execute(local_var_req).await?;
353
354    let local_var_status = local_var_resp.status();
355    let local_var_content = local_var_resp.text().await?;
356
357    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358        serde_json::from_str(&local_var_content).map_err(Error::from)
359    } else {
360        let local_var_entity: Option<GetCertificateError> =
361            serde_json::from_str(&local_var_content).ok();
362        let local_var_error = ResponseContent {
363            status: local_var_status,
364            content: local_var_content,
365            entity: local_var_entity,
366        };
367        Err(Error::ResponseError(local_var_error))
368    }
369}
370
371/// Returns a specific Action object.
372pub async fn get_certificate_action(
373    configuration: &configuration::Configuration,
374    params: GetCertificateActionParams,
375) -> Result<models::GetActionResponse, Error<GetCertificateActionError>> {
376    let local_var_configuration = configuration;
377
378    // unbox the parameters
379    let id = params.id;
380
381    let local_var_client = &local_var_configuration.client;
382
383    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
384    let local_var_uri_str = format!("{}/certificates/actions/{id}", local_base_path, id = id);
385    let mut local_var_req_builder =
386        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
387
388    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
389        local_var_req_builder =
390            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
391    }
392    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
393        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
394    };
395
396    let local_var_req = local_var_req_builder.build()?;
397    let local_var_resp = local_var_client.execute(local_var_req).await?;
398
399    let local_var_status = local_var_resp.status();
400    let local_var_content = local_var_resp.text().await?;
401
402    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
403        serde_json::from_str(&local_var_content).map_err(Error::from)
404    } else {
405        let local_var_entity: Option<GetCertificateActionError> =
406            serde_json::from_str(&local_var_content).ok();
407        let local_var_error = ResponseContent {
408            status: local_var_status,
409            content: local_var_content,
410            entity: local_var_entity,
411        };
412        Err(Error::ResponseError(local_var_error))
413    }
414}
415
416/// Returns all Action objects for a Certificate. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.  Only type `managed` Certificates can have Actions. For type `uploaded` Certificates the `actions` key will always contain an empty array.
417pub async fn list_actions_for_certificate(
418    configuration: &configuration::Configuration,
419    params: ListActionsForCertificateParams,
420) -> Result<models::ListActionsResponse, Error<ListActionsForCertificateError>> {
421    let local_var_configuration = configuration;
422
423    // unbox the parameters
424    let id = params.id;
425    let sort = params.sort;
426    let status = params.status;
427    let page = params.page;
428    let per_page = params.per_page;
429
430    let local_var_client = &local_var_configuration.client;
431
432    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
433    let local_var_uri_str = format!("{}/certificates/{id}/actions", local_base_path, id = id);
434    let mut local_var_req_builder =
435        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
436
437    if let Some(ref local_var_str) = sort {
438        local_var_req_builder = match "multi" {
439            "multi" => local_var_req_builder.query(
440                &local_var_str
441                    .iter()
442                    .map(|p| ("sort".to_owned(), p.to_string()))
443                    .collect::<Vec<(std::string::String, std::string::String)>>(),
444            ),
445            _ => local_var_req_builder.query(&[(
446                "sort",
447                &local_var_str
448                    .iter()
449                    .map(|p| p.to_string())
450                    .collect::<Vec<String>>()
451                    .join(",")
452                    .to_string(),
453            )]),
454        };
455    }
456    if let Some(ref local_var_str) = status {
457        local_var_req_builder = match "multi" {
458            "multi" => local_var_req_builder.query(
459                &local_var_str
460                    .iter()
461                    .map(|p| ("status".to_owned(), p.to_string()))
462                    .collect::<Vec<(std::string::String, std::string::String)>>(),
463            ),
464            _ => local_var_req_builder.query(&[(
465                "status",
466                &local_var_str
467                    .iter()
468                    .map(|p| p.to_string())
469                    .collect::<Vec<String>>()
470                    .join(",")
471                    .to_string(),
472            )]),
473        };
474    }
475    if let Some(ref local_var_str) = page {
476        local_var_req_builder =
477            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
478    }
479    if let Some(ref local_var_str) = per_page {
480        local_var_req_builder =
481            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
482    }
483    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
484        local_var_req_builder =
485            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
486    }
487    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
488        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
489    };
490
491    let local_var_req = local_var_req_builder.build()?;
492    let local_var_resp = local_var_client.execute(local_var_req).await?;
493
494    let local_var_status = local_var_resp.status();
495    let local_var_content = local_var_resp.text().await?;
496
497    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
498        serde_json::from_str(&local_var_content).map_err(Error::from)
499    } else {
500        let local_var_entity: Option<ListActionsForCertificateError> =
501            serde_json::from_str(&local_var_content).ok();
502        let local_var_error = ResponseContent {
503            status: local_var_status,
504            content: local_var_content,
505            entity: local_var_entity,
506        };
507        Err(Error::ResponseError(local_var_error))
508    }
509}
510
511/// Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.
512pub async fn list_certificate_actions(
513    configuration: &configuration::Configuration,
514    params: ListCertificateActionsParams,
515) -> Result<models::ListActionsResponse, Error<ListCertificateActionsError>> {
516    let local_var_configuration = configuration;
517
518    // unbox the parameters
519    let id = params.id;
520    let sort = params.sort;
521    let status = params.status;
522    let page = params.page;
523    let per_page = params.per_page;
524
525    let local_var_client = &local_var_configuration.client;
526
527    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
528    let local_var_uri_str = format!("{}/certificates/actions", local_base_path);
529    let mut local_var_req_builder =
530        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
531
532    if let Some(ref local_var_str) = id {
533        local_var_req_builder = match "multi" {
534            "multi" => local_var_req_builder.query(
535                &local_var_str
536                    .iter()
537                    .map(|p| ("id".to_owned(), p.to_string()))
538                    .collect::<Vec<(std::string::String, std::string::String)>>(),
539            ),
540            _ => local_var_req_builder.query(&[(
541                "id",
542                &local_var_str
543                    .iter()
544                    .map(|p| p.to_string())
545                    .collect::<Vec<String>>()
546                    .join(",")
547                    .to_string(),
548            )]),
549        };
550    }
551    if let Some(ref local_var_str) = sort {
552        local_var_req_builder = match "multi" {
553            "multi" => local_var_req_builder.query(
554                &local_var_str
555                    .iter()
556                    .map(|p| ("sort".to_owned(), p.to_string()))
557                    .collect::<Vec<(std::string::String, std::string::String)>>(),
558            ),
559            _ => local_var_req_builder.query(&[(
560                "sort",
561                &local_var_str
562                    .iter()
563                    .map(|p| p.to_string())
564                    .collect::<Vec<String>>()
565                    .join(",")
566                    .to_string(),
567            )]),
568        };
569    }
570    if let Some(ref local_var_str) = status {
571        local_var_req_builder = match "multi" {
572            "multi" => local_var_req_builder.query(
573                &local_var_str
574                    .iter()
575                    .map(|p| ("status".to_owned(), p.to_string()))
576                    .collect::<Vec<(std::string::String, std::string::String)>>(),
577            ),
578            _ => local_var_req_builder.query(&[(
579                "status",
580                &local_var_str
581                    .iter()
582                    .map(|p| p.to_string())
583                    .collect::<Vec<String>>()
584                    .join(",")
585                    .to_string(),
586            )]),
587        };
588    }
589    if let Some(ref local_var_str) = page {
590        local_var_req_builder =
591            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
592    }
593    if let Some(ref local_var_str) = per_page {
594        local_var_req_builder =
595            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
596    }
597    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
598        local_var_req_builder =
599            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
600    }
601    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
602        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
603    };
604
605    let local_var_req = local_var_req_builder.build()?;
606    let local_var_resp = local_var_client.execute(local_var_req).await?;
607
608    let local_var_status = local_var_resp.status();
609    let local_var_content = local_var_resp.text().await?;
610
611    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
612        serde_json::from_str(&local_var_content).map_err(Error::from)
613    } else {
614        let local_var_entity: Option<ListCertificateActionsError> =
615            serde_json::from_str(&local_var_content).ok();
616        let local_var_error = ResponseContent {
617            status: local_var_status,
618            content: local_var_content,
619            entity: local_var_entity,
620        };
621        Err(Error::ResponseError(local_var_error))
622    }
623}
624
625/// Returns all Certificate objects.
626pub async fn list_certificates(
627    configuration: &configuration::Configuration,
628    params: ListCertificatesParams,
629) -> Result<models::ListCertificatesResponse, Error<ListCertificatesError>> {
630    let local_var_configuration = configuration;
631
632    // unbox the parameters
633    let sort = params.sort;
634    let name = params.name;
635    let label_selector = params.label_selector;
636    let r#type = params.r#type;
637    let page = params.page;
638    let per_page = params.per_page;
639
640    let local_var_client = &local_var_configuration.client;
641
642    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
643    let local_var_uri_str = format!("{}/certificates", local_base_path);
644    let mut local_var_req_builder =
645        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
646
647    if let Some(ref local_var_str) = sort {
648        local_var_req_builder = match "multi" {
649            "multi" => local_var_req_builder.query(
650                &local_var_str
651                    .iter()
652                    .map(|p| ("sort".to_owned(), p.to_string()))
653                    .collect::<Vec<(std::string::String, std::string::String)>>(),
654            ),
655            _ => local_var_req_builder.query(&[(
656                "sort",
657                &local_var_str
658                    .iter()
659                    .map(|p| p.to_string())
660                    .collect::<Vec<String>>()
661                    .join(",")
662                    .to_string(),
663            )]),
664        };
665    }
666    if let Some(ref local_var_str) = name {
667        local_var_req_builder =
668            local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
669    }
670    if let Some(ref local_var_str) = label_selector {
671        local_var_req_builder =
672            local_var_req_builder.query(&[("label_selector", &local_var_str.to_string())]);
673    }
674    if let Some(ref local_var_str) = r#type {
675        local_var_req_builder = match "multi" {
676            "multi" => local_var_req_builder.query(
677                &local_var_str
678                    .iter()
679                    .map(|p| ("type".to_owned(), p.to_string()))
680                    .collect::<Vec<(std::string::String, std::string::String)>>(),
681            ),
682            _ => local_var_req_builder.query(&[(
683                "type",
684                &local_var_str
685                    .iter()
686                    .map(|p| p.to_string())
687                    .collect::<Vec<String>>()
688                    .join(",")
689                    .to_string(),
690            )]),
691        };
692    }
693    if let Some(ref local_var_str) = page {
694        local_var_req_builder =
695            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
696    }
697    if let Some(ref local_var_str) = per_page {
698        local_var_req_builder =
699            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
700    }
701    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
702        local_var_req_builder =
703            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
704    }
705    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
706        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
707    };
708
709    let local_var_req = local_var_req_builder.build()?;
710    let local_var_resp = local_var_client.execute(local_var_req).await?;
711
712    let local_var_status = local_var_resp.status();
713    let local_var_content = local_var_resp.text().await?;
714
715    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
716        serde_json::from_str(&local_var_content).map_err(Error::from)
717    } else {
718        let local_var_entity: Option<ListCertificatesError> =
719            serde_json::from_str(&local_var_content).ok();
720        let local_var_error = ResponseContent {
721            status: local_var_status,
722            content: local_var_content,
723            entity: local_var_entity,
724        };
725        Err(Error::ResponseError(local_var_error))
726    }
727}
728
729/// Updates the Certificate properties.  Note: if the Certificate object changes during the request, the response will be a “conflict” error.
730pub async fn replace_certificate(
731    configuration: &configuration::Configuration,
732    params: ReplaceCertificateParams,
733) -> Result<models::ReplaceCertificateResponse, Error<ReplaceCertificateError>> {
734    let local_var_configuration = configuration;
735
736    // unbox the parameters
737    let id = params.id;
738    let replace_certificate_request = params.replace_certificate_request;
739
740    let local_var_client = &local_var_configuration.client;
741
742    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
743    let local_var_uri_str = format!("{}/certificates/{id}", local_base_path, id = id);
744    let mut local_var_req_builder =
745        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
746
747    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
748        local_var_req_builder =
749            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
750    }
751    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
752        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
753    };
754    local_var_req_builder = local_var_req_builder.json(&replace_certificate_request);
755
756    let local_var_req = local_var_req_builder.build()?;
757    let local_var_resp = local_var_client.execute(local_var_req).await?;
758
759    let local_var_status = local_var_resp.status();
760    let local_var_content = local_var_resp.text().await?;
761
762    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
763        serde_json::from_str(&local_var_content).map_err(Error::from)
764    } else {
765        let local_var_entity: Option<ReplaceCertificateError> =
766            serde_json::from_str(&local_var_content).ok();
767        let local_var_error = ResponseContent {
768            status: local_var_status,
769            content: local_var_content,
770            entity: local_var_entity,
771        };
772        Err(Error::ResponseError(local_var_error))
773    }
774}
775
776/// Retry a failed Certificate issuance or renewal.  Only applicable if the type of the Certificate is `managed` and the issuance or renewal status is `failed`.  #### Call specific error codes  | Code                                                    | Description                                                               | |---------------------------------------------------------|---------------------------------------------------------------------------| | `caa_record_does_not_allow_ca`                          | CAA record does not allow certificate authority                           | | `ca_dns_validation_failed`                              | Certificate Authority: DNS validation failed                              | | `ca_too_many_authorizations_failed_recently`            | Certificate Authority: Too many authorizations failed recently            | | `ca_too_many_certificates_issued_for_registered_domain` | Certificate Authority: Too many certificates issued for registered domain | | `ca_too_many_duplicate_certificates`                    | Certificate Authority: Too many duplicate certificates                    | | `could_not_verify_domain_delegated_to_zone`             | Could not verify domain delegated to zone                                 | | `dns_zone_not_found`                                    | DNS zone not found                                                        | | `dns_zone_is_secondary_zone`                            | DNS zone is a secondary zone                                              |
777pub async fn retry_issuance_or_renewal(
778    configuration: &configuration::Configuration,
779    params: RetryIssuanceOrRenewalParams,
780) -> Result<models::RetryIssuanceOrRenewalResponse, Error<RetryIssuanceOrRenewalError>> {
781    let local_var_configuration = configuration;
782
783    // unbox the parameters
784    let id = params.id;
785
786    let local_var_client = &local_var_configuration.client;
787
788    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
789    let local_var_uri_str = format!(
790        "{}/certificates/{id}/actions/retry",
791        local_base_path,
792        id = id
793    );
794    let mut local_var_req_builder =
795        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
796
797    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
798        local_var_req_builder =
799            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
800    }
801    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
802        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
803    };
804
805    let local_var_req = local_var_req_builder.build()?;
806    let local_var_resp = local_var_client.execute(local_var_req).await?;
807
808    let local_var_status = local_var_resp.status();
809    let local_var_content = local_var_resp.text().await?;
810
811    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
812        serde_json::from_str(&local_var_content).map_err(Error::from)
813    } else {
814        let local_var_entity: Option<RetryIssuanceOrRenewalError> =
815            serde_json::from_str(&local_var_content).ok();
816        let local_var_error = ResponseContent {
817            status: local_var_status,
818            content: local_var_content,
819            entity: local_var_entity,
820        };
821        Err(Error::ResponseError(local_var_error))
822    }
823}