hcloud/apis/
servers_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 [`add_server_to_placement_group`]
17#[derive(Clone, Debug, Default)]
18pub struct AddServerToPlacementGroupParams {
19    /// ID of the Server.
20    pub id: i64,
21    pub add_server_to_placement_group_request: models::AddServerToPlacementGroupRequest,
22}
23
24/// struct for passing parameters to the method [`attach_iso_to_server`]
25#[derive(Clone, Debug, Default)]
26pub struct AttachIsoToServerParams {
27    /// ID of the Server.
28    pub id: i64,
29    pub attach_iso_to_server_request: models::AttachIsoToServerRequest,
30}
31
32/// struct for passing parameters to the method [`attach_server_to_network`]
33#[derive(Clone, Debug, Default)]
34pub struct AttachServerToNetworkParams {
35    /// ID of the Server.
36    pub id: i64,
37    pub attach_server_to_network_request: models::AttachServerToNetworkRequest,
38}
39
40/// struct for passing parameters to the method [`change_alias_ips_of_network`]
41#[derive(Clone, Debug, Default)]
42pub struct ChangeAliasIpsOfNetworkParams {
43    /// ID of the Server.
44    pub id: i64,
45    pub change_alias_ips_of_network_request: models::ChangeAliasIpsOfNetworkRequest,
46}
47
48/// struct for passing parameters to the method [`change_reverse_dns_entry_for_this_server`]
49#[derive(Clone, Debug, Default)]
50pub struct ChangeReverseDnsEntryForThisServerParams {
51    /// ID of the Server.
52    pub id: i64,
53    /// Select the IP address for which to change the DNS entry by passing `ip`. It can be either IPv4 or IPv6. The target hostname is set by passing `dns_ptr`, which must be a fully qualified domain name (FQDN) without trailing dot.
54    pub change_reverse_dns_entry_for_this_server_request:
55        models::ChangeReverseDnsEntryForThisServerRequest,
56}
57
58/// struct for passing parameters to the method [`change_server_protection`]
59#[derive(Clone, Debug, Default)]
60pub struct ChangeServerProtectionParams {
61    /// ID of the Server.
62    pub id: i64,
63    pub change_server_protection_request: models::ChangeServerProtectionRequest,
64}
65
66/// struct for passing parameters to the method [`change_type_of_server`]
67#[derive(Clone, Debug, Default)]
68pub struct ChangeTypeOfServerParams {
69    /// ID of the Server.
70    pub id: i64,
71    pub change_type_of_server_request: models::ChangeTypeOfServerRequest,
72}
73
74/// struct for passing parameters to the method [`create_image_from_server`]
75#[derive(Clone, Debug, Default)]
76pub struct CreateImageFromServerParams {
77    /// ID of the Server.
78    pub id: i64,
79    pub create_image_from_server_request: models::CreateImageFromServerRequest,
80}
81
82/// struct for passing parameters to the method [`create_server`]
83#[derive(Clone, Debug, Default)]
84pub struct CreateServerParams {
85    /// Please note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).  For `server_type` you can either use the ID as listed in `/server_types` or its name.  For `image` you can either use the ID as listed in `/images` or its name.  If you want to create the Server in a Location, you must set `location` to the ID or name as listed in `/locations`. This is the recommended way. You can be even more specific by setting `datacenter` to the ID or name as listed in `/datacenters`. However we only recommend this if you want to assign a specific Primary IP to the Server which is located in the specified Data Center.  Some properties like `start_after_create` or `automount` will trigger Actions after the Server is created. Those Actions are listed in the `next_actions` field in the response.  For accessing your Server we strongly recommend to use SSH keys by passing the respective key IDs in `ssh_keys`. If you do not specify any `ssh_keys` we will generate a root password for you and return it in the response.  Please note that provided user-data is stored in our systems. While we take measures to protect it we highly recommend that you don’t use it to store passwords or other sensitive information.  #### Call specific error codes  | Code                             | Description                                                | |----------------------------------|------------------------------------------------------------| | `placement_error`                | An error during the placement occurred                     | | `primary_ip_assigned`            | The specified Primary IP is already assigned to a server   | | `primary_ip_datacenter_mismatch` | The specified Primary IP is in a different datacenter      | | `primary_ip_version_mismatch`    | The specified Primary IP has the wrong IP Version          |
86    pub create_server_request: models::CreateServerRequest,
87}
88
89/// struct for passing parameters to the method [`delete_server`]
90#[derive(Clone, Debug, Default)]
91pub struct DeleteServerParams {
92    /// ID of the Server.
93    pub id: i64,
94}
95
96/// struct for passing parameters to the method [`detach_iso_from_server`]
97#[derive(Clone, Debug, Default)]
98pub struct DetachIsoFromServerParams {
99    /// ID of the Server.
100    pub id: i64,
101}
102
103/// struct for passing parameters to the method [`detach_server_from_network`]
104#[derive(Clone, Debug, Default)]
105pub struct DetachServerFromNetworkParams {
106    /// ID of the Server.
107    pub id: i64,
108    pub detach_server_from_network_request: models::DetachServerFromNetworkRequest,
109}
110
111/// struct for passing parameters to the method [`disable_backups_for_server`]
112#[derive(Clone, Debug, Default)]
113pub struct DisableBackupsForServerParams {
114    /// ID of the Server.
115    pub id: i64,
116}
117
118/// struct for passing parameters to the method [`disable_rescue_mode_for_server`]
119#[derive(Clone, Debug, Default)]
120pub struct DisableRescueModeForServerParams {
121    /// ID of the Server.
122    pub id: i64,
123}
124
125/// struct for passing parameters to the method [`enable_and_configure_backups_for_server`]
126#[derive(Clone, Debug, Default)]
127pub struct EnableAndConfigureBackupsForServerParams {
128    /// ID of the Server.
129    pub id: i64,
130}
131
132/// struct for passing parameters to the method [`enable_rescue_mode_for_server`]
133#[derive(Clone, Debug, Default)]
134pub struct EnableRescueModeForServerParams {
135    /// ID of the Server.
136    pub id: i64,
137    pub enable_rescue_mode_for_server_request: models::EnableRescueModeForServerRequest,
138}
139
140/// struct for passing parameters to the method [`get_action_for_server`]
141#[derive(Clone, Debug, Default)]
142pub struct GetActionForServerParams {
143    /// ID of the Server.
144    pub id: i64,
145    /// ID of the Action.
146    pub action_id: i64,
147}
148
149/// struct for passing parameters to the method [`get_metrics_for_server`]
150#[derive(Clone, Debug, Default)]
151pub struct GetMetricsForServerParams {
152    /// ID of the Server.
153    pub id: i64,
154    /// Type of metrics to get.
155    pub r#type: Vec<String>,
156    /// Start of period to get Metrics for (in ISO-8601 format).
157    pub start: String,
158    /// End of period to get Metrics for (in ISO-8601 format).
159    pub end: String,
160    /// Resolution of results in seconds.
161    pub step: Option<String>,
162}
163
164/// struct for passing parameters to the method [`get_server`]
165#[derive(Clone, Debug, Default)]
166pub struct GetServerParams {
167    /// ID of the Server.
168    pub id: i64,
169}
170
171/// struct for passing parameters to the method [`get_server_action`]
172#[derive(Clone, Debug, Default)]
173pub struct GetServerActionParams {
174    /// ID of the Action.
175    pub id: i64,
176}
177
178/// struct for passing parameters to the method [`list_actions_for_server`]
179#[derive(Clone, Debug, Default)]
180pub struct ListActionsForServerParams {
181    /// ID of the Server.
182    pub id: i64,
183    /// Sort actions by field and direction. Can be used multiple times. For more information, see \"Sorting\".
184    pub sort: Option<Vec<String>>,
185    /// Filter the actions by status. Can be used multiple times. The response will only contain actions matching the specified statuses.
186    pub status: Option<Vec<String>>,
187    /// Page number to return. For more information, see \"Pagination\".
188    pub page: Option<i64>,
189    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
190    pub per_page: Option<i64>,
191}
192
193/// struct for passing parameters to the method [`list_server_actions`]
194#[derive(Clone, Debug, Default)]
195pub struct ListServerActionsParams {
196    /// Filter the actions by ID. Can be used multiple times. The response will only contain actions matching the specified IDs.
197    pub id: Option<Vec<i64>>,
198    /// Sort actions by field and direction. Can be used multiple times. For more information, see \"Sorting\".
199    pub sort: Option<Vec<String>>,
200    /// Filter the actions by status. Can be used multiple times. The response will only contain actions matching the specified statuses.
201    pub status: Option<Vec<String>>,
202    /// Page number to return. For more information, see \"Pagination\".
203    pub page: Option<i64>,
204    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
205    pub per_page: Option<i64>,
206}
207
208/// struct for passing parameters to the method [`list_servers`]
209#[derive(Clone, Debug, Default)]
210pub struct ListServersParams {
211    /// Filter resources by their name. The response will only contain the resources matching exactly the specified name.
212    pub name: Option<String>,
213    /// Filter resources by labels. The response will only contain resources matching the label selector. For more information, see \"Label Selector\".
214    pub label_selector: Option<String>,
215    /// Sort resources by field and direction. Can be used multiple times. For more information, see \"Sorting\".
216    pub sort: Option<Vec<String>>,
217    /// Filter resources by status. Can be used multiple times. The response will only contain the resources with the specified status.
218    pub status: Option<Vec<String>>,
219    /// Page number to return. For more information, see \"Pagination\".
220    pub page: Option<i64>,
221    /// Maximum number of entries returned per page. For more information, see \"Pagination\".
222    pub per_page: Option<i64>,
223}
224
225/// struct for passing parameters to the method [`power_off_server`]
226#[derive(Clone, Debug, Default)]
227pub struct PowerOffServerParams {
228    /// ID of the Server.
229    pub id: i64,
230}
231
232/// struct for passing parameters to the method [`power_on_server`]
233#[derive(Clone, Debug, Default)]
234pub struct PowerOnServerParams {
235    /// ID of the Server.
236    pub id: i64,
237}
238
239/// struct for passing parameters to the method [`rebuild_server_from_image`]
240#[derive(Clone, Debug, Default)]
241pub struct RebuildServerFromImageParams {
242    /// ID of the Server.
243    pub id: i64,
244    /// To select which Image to rebuild from you can either pass an ID or a name as the `image` argument. Passing a name only works for `system` Images since the other Image types do not have a name set.
245    pub rebuild_server_from_image_request: models::RebuildServerFromImageRequest,
246}
247
248/// struct for passing parameters to the method [`remove_from_placement_group`]
249#[derive(Clone, Debug, Default)]
250pub struct RemoveFromPlacementGroupParams {
251    /// ID of the Server.
252    pub id: i64,
253}
254
255/// struct for passing parameters to the method [`replace_server`]
256#[derive(Clone, Debug, Default)]
257pub struct ReplaceServerParams {
258    /// ID of the Server.
259    pub id: i64,
260    pub replace_server_request: models::ReplaceServerRequest,
261}
262
263/// struct for passing parameters to the method [`request_console_for_server`]
264#[derive(Clone, Debug, Default)]
265pub struct RequestConsoleForServerParams {
266    /// ID of the Server.
267    pub id: i64,
268}
269
270/// struct for passing parameters to the method [`reset_root_password_of_server`]
271#[derive(Clone, Debug, Default)]
272pub struct ResetRootPasswordOfServerParams {
273    /// ID of the Server.
274    pub id: i64,
275}
276
277/// struct for passing parameters to the method [`reset_server`]
278#[derive(Clone, Debug, Default)]
279pub struct ResetServerParams {
280    /// ID of the Server.
281    pub id: i64,
282}
283
284/// struct for passing parameters to the method [`shutdown_server`]
285#[derive(Clone, Debug, Default)]
286pub struct ShutdownServerParams {
287    /// ID of the Server.
288    pub id: i64,
289}
290
291/// struct for passing parameters to the method [`soft_reboot_server`]
292#[derive(Clone, Debug, Default)]
293pub struct SoftRebootServerParams {
294    /// ID of the Server.
295    pub id: i64,
296}
297
298/// struct for typed errors of method [`add_server_to_placement_group`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum AddServerToPlacementGroupError {
302    UnknownValue(serde_json::Value),
303}
304
305/// struct for typed errors of method [`attach_iso_to_server`]
306#[derive(Debug, Clone, Serialize, Deserialize)]
307#[serde(untagged)]
308pub enum AttachIsoToServerError {
309    UnknownValue(serde_json::Value),
310}
311
312/// struct for typed errors of method [`attach_server_to_network`]
313#[derive(Debug, Clone, Serialize, Deserialize)]
314#[serde(untagged)]
315pub enum AttachServerToNetworkError {
316    UnknownValue(serde_json::Value),
317}
318
319/// struct for typed errors of method [`change_alias_ips_of_network`]
320#[derive(Debug, Clone, Serialize, Deserialize)]
321#[serde(untagged)]
322pub enum ChangeAliasIpsOfNetworkError {
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method [`change_reverse_dns_entry_for_this_server`]
327#[derive(Debug, Clone, Serialize, Deserialize)]
328#[serde(untagged)]
329pub enum ChangeReverseDnsEntryForThisServerError {
330    UnknownValue(serde_json::Value),
331}
332
333/// struct for typed errors of method [`change_server_protection`]
334#[derive(Debug, Clone, Serialize, Deserialize)]
335#[serde(untagged)]
336pub enum ChangeServerProtectionError {
337    UnknownValue(serde_json::Value),
338}
339
340/// struct for typed errors of method [`change_type_of_server`]
341#[derive(Debug, Clone, Serialize, Deserialize)]
342#[serde(untagged)]
343pub enum ChangeTypeOfServerError {
344    UnknownValue(serde_json::Value),
345}
346
347/// struct for typed errors of method [`create_image_from_server`]
348#[derive(Debug, Clone, Serialize, Deserialize)]
349#[serde(untagged)]
350pub enum CreateImageFromServerError {
351    UnknownValue(serde_json::Value),
352}
353
354/// struct for typed errors of method [`create_server`]
355#[derive(Debug, Clone, Serialize, Deserialize)]
356#[serde(untagged)]
357pub enum CreateServerError {
358    UnknownValue(serde_json::Value),
359}
360
361/// struct for typed errors of method [`delete_server`]
362#[derive(Debug, Clone, Serialize, Deserialize)]
363#[serde(untagged)]
364pub enum DeleteServerError {
365    UnknownValue(serde_json::Value),
366}
367
368/// struct for typed errors of method [`detach_iso_from_server`]
369#[derive(Debug, Clone, Serialize, Deserialize)]
370#[serde(untagged)]
371pub enum DetachIsoFromServerError {
372    UnknownValue(serde_json::Value),
373}
374
375/// struct for typed errors of method [`detach_server_from_network`]
376#[derive(Debug, Clone, Serialize, Deserialize)]
377#[serde(untagged)]
378pub enum DetachServerFromNetworkError {
379    UnknownValue(serde_json::Value),
380}
381
382/// struct for typed errors of method [`disable_backups_for_server`]
383#[derive(Debug, Clone, Serialize, Deserialize)]
384#[serde(untagged)]
385pub enum DisableBackupsForServerError {
386    UnknownValue(serde_json::Value),
387}
388
389/// struct for typed errors of method [`disable_rescue_mode_for_server`]
390#[derive(Debug, Clone, Serialize, Deserialize)]
391#[serde(untagged)]
392pub enum DisableRescueModeForServerError {
393    UnknownValue(serde_json::Value),
394}
395
396/// struct for typed errors of method [`enable_and_configure_backups_for_server`]
397#[derive(Debug, Clone, Serialize, Deserialize)]
398#[serde(untagged)]
399pub enum EnableAndConfigureBackupsForServerError {
400    UnknownValue(serde_json::Value),
401}
402
403/// struct for typed errors of method [`enable_rescue_mode_for_server`]
404#[derive(Debug, Clone, Serialize, Deserialize)]
405#[serde(untagged)]
406pub enum EnableRescueModeForServerError {
407    UnknownValue(serde_json::Value),
408}
409
410/// struct for typed errors of method [`get_action_for_server`]
411#[derive(Debug, Clone, Serialize, Deserialize)]
412#[serde(untagged)]
413pub enum GetActionForServerError {
414    UnknownValue(serde_json::Value),
415}
416
417/// struct for typed errors of method [`get_metrics_for_server`]
418#[derive(Debug, Clone, Serialize, Deserialize)]
419#[serde(untagged)]
420pub enum GetMetricsForServerError {
421    UnknownValue(serde_json::Value),
422}
423
424/// struct for typed errors of method [`get_server`]
425#[derive(Debug, Clone, Serialize, Deserialize)]
426#[serde(untagged)]
427pub enum GetServerError {
428    UnknownValue(serde_json::Value),
429}
430
431/// struct for typed errors of method [`get_server_action`]
432#[derive(Debug, Clone, Serialize, Deserialize)]
433#[serde(untagged)]
434pub enum GetServerActionError {
435    UnknownValue(serde_json::Value),
436}
437
438/// struct for typed errors of method [`list_actions_for_server`]
439#[derive(Debug, Clone, Serialize, Deserialize)]
440#[serde(untagged)]
441pub enum ListActionsForServerError {
442    UnknownValue(serde_json::Value),
443}
444
445/// struct for typed errors of method [`list_server_actions`]
446#[derive(Debug, Clone, Serialize, Deserialize)]
447#[serde(untagged)]
448pub enum ListServerActionsError {
449    UnknownValue(serde_json::Value),
450}
451
452/// struct for typed errors of method [`list_servers`]
453#[derive(Debug, Clone, Serialize, Deserialize)]
454#[serde(untagged)]
455pub enum ListServersError {
456    UnknownValue(serde_json::Value),
457}
458
459/// struct for typed errors of method [`power_off_server`]
460#[derive(Debug, Clone, Serialize, Deserialize)]
461#[serde(untagged)]
462pub enum PowerOffServerError {
463    UnknownValue(serde_json::Value),
464}
465
466/// struct for typed errors of method [`power_on_server`]
467#[derive(Debug, Clone, Serialize, Deserialize)]
468#[serde(untagged)]
469pub enum PowerOnServerError {
470    UnknownValue(serde_json::Value),
471}
472
473/// struct for typed errors of method [`rebuild_server_from_image`]
474#[derive(Debug, Clone, Serialize, Deserialize)]
475#[serde(untagged)]
476pub enum RebuildServerFromImageError {
477    UnknownValue(serde_json::Value),
478}
479
480/// struct for typed errors of method [`remove_from_placement_group`]
481#[derive(Debug, Clone, Serialize, Deserialize)]
482#[serde(untagged)]
483pub enum RemoveFromPlacementGroupError {
484    UnknownValue(serde_json::Value),
485}
486
487/// struct for typed errors of method [`replace_server`]
488#[derive(Debug, Clone, Serialize, Deserialize)]
489#[serde(untagged)]
490pub enum ReplaceServerError {
491    UnknownValue(serde_json::Value),
492}
493
494/// struct for typed errors of method [`request_console_for_server`]
495#[derive(Debug, Clone, Serialize, Deserialize)]
496#[serde(untagged)]
497pub enum RequestConsoleForServerError {
498    UnknownValue(serde_json::Value),
499}
500
501/// struct for typed errors of method [`reset_root_password_of_server`]
502#[derive(Debug, Clone, Serialize, Deserialize)]
503#[serde(untagged)]
504pub enum ResetRootPasswordOfServerError {
505    UnknownValue(serde_json::Value),
506}
507
508/// struct for typed errors of method [`reset_server`]
509#[derive(Debug, Clone, Serialize, Deserialize)]
510#[serde(untagged)]
511pub enum ResetServerError {
512    UnknownValue(serde_json::Value),
513}
514
515/// struct for typed errors of method [`shutdown_server`]
516#[derive(Debug, Clone, Serialize, Deserialize)]
517#[serde(untagged)]
518pub enum ShutdownServerError {
519    UnknownValue(serde_json::Value),
520}
521
522/// struct for typed errors of method [`soft_reboot_server`]
523#[derive(Debug, Clone, Serialize, Deserialize)]
524#[serde(untagged)]
525pub enum SoftRebootServerError {
526    UnknownValue(serde_json::Value),
527}
528
529/// Adds a Server to a Placement Group.  Server must be powered off for this command to succeed.  #### Call specific error codes  | Code                          | Description                                                          | |-------------------------------|----------------------------------------------------------------------| | `server_not_stopped`          | The action requires a stopped server                                 |
530pub async fn add_server_to_placement_group(
531    configuration: &configuration::Configuration,
532    params: AddServerToPlacementGroupParams,
533) -> Result<models::AddServerToPlacementGroupResponse, Error<AddServerToPlacementGroupError>> {
534    let local_var_configuration = configuration;
535
536    // unbox the parameters
537    let id = params.id;
538    let add_server_to_placement_group_request = params.add_server_to_placement_group_request;
539
540    let local_var_client = &local_var_configuration.client;
541
542    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
543    let local_var_uri_str = format!(
544        "{}/servers/{id}/actions/add_to_placement_group",
545        local_base_path,
546        id = id
547    );
548    let mut local_var_req_builder =
549        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
550
551    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
552        local_var_req_builder =
553            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
554    }
555    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
556        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
557    };
558    local_var_req_builder = local_var_req_builder.json(&add_server_to_placement_group_request);
559
560    let local_var_req = local_var_req_builder.build()?;
561    let local_var_resp = local_var_client.execute(local_var_req).await?;
562
563    let local_var_status = local_var_resp.status();
564    let local_var_content = local_var_resp.text().await?;
565
566    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
567        serde_json::from_str(&local_var_content).map_err(Error::from)
568    } else {
569        let local_var_entity: Option<AddServerToPlacementGroupError> =
570            serde_json::from_str(&local_var_content).ok();
571        let local_var_error = ResponseContent {
572            status: local_var_status,
573            content: local_var_content,
574            entity: local_var_entity,
575        };
576        Err(Error::ResponseError(local_var_error))
577    }
578}
579
580/// Attaches an ISO to a Server. The Server will immediately see it as a new disk. An already attached ISO will automatically be detached before the new ISO is attached.  Servers with attached ISOs have a modified boot order: They will try to boot from the ISO first before falling back to hard disk.
581pub async fn attach_iso_to_server(
582    configuration: &configuration::Configuration,
583    params: AttachIsoToServerParams,
584) -> Result<models::AttachIsoToServerResponse, Error<AttachIsoToServerError>> {
585    let local_var_configuration = configuration;
586
587    // unbox the parameters
588    let id = params.id;
589    let attach_iso_to_server_request = params.attach_iso_to_server_request;
590
591    let local_var_client = &local_var_configuration.client;
592
593    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
594    let local_var_uri_str = format!(
595        "{}/servers/{id}/actions/attach_iso",
596        local_base_path,
597        id = id
598    );
599    let mut local_var_req_builder =
600        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
601
602    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
603        local_var_req_builder =
604            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
605    }
606    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
607        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
608    };
609    local_var_req_builder = local_var_req_builder.json(&attach_iso_to_server_request);
610
611    let local_var_req = local_var_req_builder.build()?;
612    let local_var_resp = local_var_client.execute(local_var_req).await?;
613
614    let local_var_status = local_var_resp.status();
615    let local_var_content = local_var_resp.text().await?;
616
617    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
618        serde_json::from_str(&local_var_content).map_err(Error::from)
619    } else {
620        let local_var_entity: Option<AttachIsoToServerError> =
621            serde_json::from_str(&local_var_content).ok();
622        let local_var_error = ResponseContent {
623            status: local_var_status,
624            content: local_var_content,
625            entity: local_var_entity,
626        };
627        Err(Error::ResponseError(local_var_error))
628    }
629}
630
631/// Attaches a Server to a network. This will complement the fixed public Server interface by adding an additional ethernet interface to the Server which is connected to the specified network.  The Server will get an IP auto assigned from a subnet of type `server` in the same `network_zone`.  Using the `alias_ips` attribute you can also define one or more additional IPs to the Servers. Please note that you will have to configure these IPs by hand on your Server since only the primary IP will be given out by DHCP.  **Call specific error codes**  | Code                             | Description                                                           | |----------------------------------|-----------------------------------------------------------------------| | `server_already_attached`        | The server is already attached to the network                         | | `ip_not_available`               | The provided Network IP is not available                              | | `no_subnet_available`            | No Subnet or IP is available for the Server within the network        | | `networks_overlap`               | The network IP range overlaps with one of the server networks         |
632pub async fn attach_server_to_network(
633    configuration: &configuration::Configuration,
634    params: AttachServerToNetworkParams,
635) -> Result<models::AttachServerToNetworkResponse, Error<AttachServerToNetworkError>> {
636    let local_var_configuration = configuration;
637
638    // unbox the parameters
639    let id = params.id;
640    let attach_server_to_network_request = params.attach_server_to_network_request;
641
642    let local_var_client = &local_var_configuration.client;
643
644    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
645    let local_var_uri_str = format!(
646        "{}/servers/{id}/actions/attach_to_network",
647        local_base_path,
648        id = id
649    );
650    let mut local_var_req_builder =
651        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
652
653    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
654        local_var_req_builder =
655            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
656    }
657    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
658        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
659    };
660    local_var_req_builder = local_var_req_builder.json(&attach_server_to_network_request);
661
662    let local_var_req = local_var_req_builder.build()?;
663    let local_var_resp = local_var_client.execute(local_var_req).await?;
664
665    let local_var_status = local_var_resp.status();
666    let local_var_content = local_var_resp.text().await?;
667
668    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
669        serde_json::from_str(&local_var_content).map_err(Error::from)
670    } else {
671        let local_var_entity: Option<AttachServerToNetworkError> =
672            serde_json::from_str(&local_var_content).ok();
673        let local_var_error = ResponseContent {
674            status: local_var_status,
675            content: local_var_content,
676            entity: local_var_entity,
677        };
678        Err(Error::ResponseError(local_var_error))
679    }
680}
681
682/// Changes the alias IPs of an already attached Network. Note that the existing aliases for the specified Network will be replaced with these provided in the request body. So if you want to add an alias IP, you have to provide the existing ones from the Network plus the new alias IP in the request body.
683pub async fn change_alias_ips_of_network(
684    configuration: &configuration::Configuration,
685    params: ChangeAliasIpsOfNetworkParams,
686) -> Result<models::ChangeAliasIpsOfNetworkResponse, Error<ChangeAliasIpsOfNetworkError>> {
687    let local_var_configuration = configuration;
688
689    // unbox the parameters
690    let id = params.id;
691    let change_alias_ips_of_network_request = params.change_alias_ips_of_network_request;
692
693    let local_var_client = &local_var_configuration.client;
694
695    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
696    let local_var_uri_str = format!(
697        "{}/servers/{id}/actions/change_alias_ips",
698        local_base_path,
699        id = id
700    );
701    let mut local_var_req_builder =
702        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
703
704    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
705        local_var_req_builder =
706            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
707    }
708    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
709        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
710    };
711    local_var_req_builder = local_var_req_builder.json(&change_alias_ips_of_network_request);
712
713    let local_var_req = local_var_req_builder.build()?;
714    let local_var_resp = local_var_client.execute(local_var_req).await?;
715
716    let local_var_status = local_var_resp.status();
717    let local_var_content = local_var_resp.text().await?;
718
719    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
720        serde_json::from_str(&local_var_content).map_err(Error::from)
721    } else {
722        let local_var_entity: Option<ChangeAliasIpsOfNetworkError> =
723            serde_json::from_str(&local_var_content).ok();
724        let local_var_error = ResponseContent {
725            status: local_var_status,
726            content: local_var_content,
727            entity: local_var_entity,
728        };
729        Err(Error::ResponseError(local_var_error))
730    }
731}
732
733/// Changes the hostname that will appear when getting the hostname belonging to the primary IPs (IPv4 and IPv6) of this Server.  Floating IPs assigned to the Server are not affected by this.
734pub async fn change_reverse_dns_entry_for_this_server(
735    configuration: &configuration::Configuration,
736    params: ChangeReverseDnsEntryForThisServerParams,
737) -> Result<
738    models::ChangeReverseDnsEntryForThisServerResponse,
739    Error<ChangeReverseDnsEntryForThisServerError>,
740> {
741    let local_var_configuration = configuration;
742
743    // unbox the parameters
744    let id = params.id;
745    let change_reverse_dns_entry_for_this_server_request =
746        params.change_reverse_dns_entry_for_this_server_request;
747
748    let local_var_client = &local_var_configuration.client;
749
750    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
751    let local_var_uri_str = format!(
752        "{}/servers/{id}/actions/change_dns_ptr",
753        local_base_path,
754        id = id
755    );
756    let mut local_var_req_builder =
757        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
758
759    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
760        local_var_req_builder =
761            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
762    }
763    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
764        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
765    };
766    local_var_req_builder =
767        local_var_req_builder.json(&change_reverse_dns_entry_for_this_server_request);
768
769    let local_var_req = local_var_req_builder.build()?;
770    let local_var_resp = local_var_client.execute(local_var_req).await?;
771
772    let local_var_status = local_var_resp.status();
773    let local_var_content = local_var_resp.text().await?;
774
775    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
776        serde_json::from_str(&local_var_content).map_err(Error::from)
777    } else {
778        let local_var_entity: Option<ChangeReverseDnsEntryForThisServerError> =
779            serde_json::from_str(&local_var_content).ok();
780        let local_var_error = ResponseContent {
781            status: local_var_status,
782            content: local_var_content,
783            entity: local_var_entity,
784        };
785        Err(Error::ResponseError(local_var_error))
786    }
787}
788
789/// Changes the protection configuration of the Server.
790pub async fn change_server_protection(
791    configuration: &configuration::Configuration,
792    params: ChangeServerProtectionParams,
793) -> Result<models::ChangeServerProtectionResponse, Error<ChangeServerProtectionError>> {
794    let local_var_configuration = configuration;
795
796    // unbox the parameters
797    let id = params.id;
798    let change_server_protection_request = params.change_server_protection_request;
799
800    let local_var_client = &local_var_configuration.client;
801
802    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
803    let local_var_uri_str = format!(
804        "{}/servers/{id}/actions/change_protection",
805        local_base_path,
806        id = id
807    );
808    let mut local_var_req_builder =
809        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
810
811    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
812        local_var_req_builder =
813            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
814    }
815    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
816        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
817    };
818    local_var_req_builder = local_var_req_builder.json(&change_server_protection_request);
819
820    let local_var_req = local_var_req_builder.build()?;
821    let local_var_resp = local_var_client.execute(local_var_req).await?;
822
823    let local_var_status = local_var_resp.status();
824    let local_var_content = local_var_resp.text().await?;
825
826    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
827        serde_json::from_str(&local_var_content).map_err(Error::from)
828    } else {
829        let local_var_entity: Option<ChangeServerProtectionError> =
830            serde_json::from_str(&local_var_content).ok();
831        let local_var_error = ResponseContent {
832            status: local_var_status,
833            content: local_var_content,
834            entity: local_var_entity,
835        };
836        Err(Error::ResponseError(local_var_error))
837    }
838}
839
840/// Changes the type (Cores, RAM and disk sizes) of a Server.  Server must be powered off for this command to succeed.  This copies the content of its disk, and starts it again.  You can only migrate to Server types with the same `storage_type` and equal or bigger disks. Shrinking disks is not possible as it might destroy data.  If the disk gets upgraded, the Server type can not be downgraded any more. If you plan to downgrade the Server type, set `upgrade_disk` to `false`.  #### Call specific error codes  | Code                          | Description                                                          | |-------------------------------|----------------------------------------------------------------------| | `invalid_server_type`         | The server type does not fit for the given server or is deprecated   | | `server_not_stopped`          | The action requires a stopped server                                 |
841pub async fn change_type_of_server(
842    configuration: &configuration::Configuration,
843    params: ChangeTypeOfServerParams,
844) -> Result<models::ChangeTypeOfServerResponse, Error<ChangeTypeOfServerError>> {
845    let local_var_configuration = configuration;
846
847    // unbox the parameters
848    let id = params.id;
849    let change_type_of_server_request = params.change_type_of_server_request;
850
851    let local_var_client = &local_var_configuration.client;
852
853    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
854    let local_var_uri_str = format!(
855        "{}/servers/{id}/actions/change_type",
856        local_base_path,
857        id = id
858    );
859    let mut local_var_req_builder =
860        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
861
862    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
863        local_var_req_builder =
864            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
865    }
866    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
867        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
868    };
869    local_var_req_builder = local_var_req_builder.json(&change_type_of_server_request);
870
871    let local_var_req = local_var_req_builder.build()?;
872    let local_var_resp = local_var_client.execute(local_var_req).await?;
873
874    let local_var_status = local_var_resp.status();
875    let local_var_content = local_var_resp.text().await?;
876
877    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
878        serde_json::from_str(&local_var_content).map_err(Error::from)
879    } else {
880        let local_var_entity: Option<ChangeTypeOfServerError> =
881            serde_json::from_str(&local_var_content).ok();
882        let local_var_error = ResponseContent {
883            status: local_var_status,
884            content: local_var_content,
885            entity: local_var_entity,
886        };
887        Err(Error::ResponseError(local_var_error))
888    }
889}
890
891/// Creates an Image (snapshot) from a Server by copying the contents of its disks. This creates a snapshot of the current state of the disk and copies it into an Image. If the Server is currently running you must make sure that its disk content is consistent. Otherwise, the created Image may not be readable.  To make sure disk content is consistent, we recommend to shut down the Server prior to creating an Image.  You can either create a `backup` Image that is bound to the Server and therefore will be deleted when the Server is deleted, or you can create a `snapshot` Image which is completely independent of the Server it was created from and will survive Server deletion. Backup Images are only available when the backup option is enabled for the Server. Snapshot Images are billed on a per GB basis.
892pub async fn create_image_from_server(
893    configuration: &configuration::Configuration,
894    params: CreateImageFromServerParams,
895) -> Result<models::CreateImageFromServerResponse, Error<CreateImageFromServerError>> {
896    let local_var_configuration = configuration;
897
898    // unbox the parameters
899    let id = params.id;
900    let create_image_from_server_request = params.create_image_from_server_request;
901
902    let local_var_client = &local_var_configuration.client;
903
904    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
905    let local_var_uri_str = format!(
906        "{}/servers/{id}/actions/create_image",
907        local_base_path,
908        id = id
909    );
910    let mut local_var_req_builder =
911        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
912
913    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
914        local_var_req_builder =
915            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
916    }
917    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
918        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
919    };
920    local_var_req_builder = local_var_req_builder.json(&create_image_from_server_request);
921
922    let local_var_req = local_var_req_builder.build()?;
923    let local_var_resp = local_var_client.execute(local_var_req).await?;
924
925    let local_var_status = local_var_resp.status();
926    let local_var_content = local_var_resp.text().await?;
927
928    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
929        serde_json::from_str(&local_var_content).map_err(Error::from)
930    } else {
931        let local_var_entity: Option<CreateImageFromServerError> =
932            serde_json::from_str(&local_var_content).ok();
933        let local_var_error = ResponseContent {
934            status: local_var_status,
935            content: local_var_content,
936            entity: local_var_entity,
937        };
938        Err(Error::ResponseError(local_var_error))
939    }
940}
941
942/// Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.
943pub async fn create_server(
944    configuration: &configuration::Configuration,
945    params: CreateServerParams,
946) -> Result<models::CreateServerResponse, Error<CreateServerError>> {
947    let local_var_configuration = configuration;
948
949    // unbox the parameters
950    let create_server_request = params.create_server_request;
951
952    let local_var_client = &local_var_configuration.client;
953
954    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
955    let local_var_uri_str = format!("{}/servers", local_base_path);
956    let mut local_var_req_builder =
957        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
958
959    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
960        local_var_req_builder =
961            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
962    }
963    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
964        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
965    };
966    local_var_req_builder = local_var_req_builder.json(&create_server_request);
967
968    let local_var_req = local_var_req_builder.build()?;
969    let local_var_resp = local_var_client.execute(local_var_req).await?;
970
971    let local_var_status = local_var_resp.status();
972    let local_var_content = local_var_resp.text().await?;
973
974    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
975        serde_json::from_str(&local_var_content).map_err(Error::from)
976    } else {
977        let local_var_entity: Option<CreateServerError> =
978            serde_json::from_str(&local_var_content).ok();
979        let local_var_error = ResponseContent {
980            status: local_var_status,
981            content: local_var_content,
982            entity: local_var_entity,
983        };
984        Err(Error::ResponseError(local_var_error))
985    }
986}
987
988/// Deletes a Server.  This immediately removes the Server from your account, and it is no longer accessible. Any resources attached to the server (like Volumes, Primary IPs, Floating IPs, Firewalls, Placement Groups) are detached while the server is deleted.
989pub async fn delete_server(
990    configuration: &configuration::Configuration,
991    params: DeleteServerParams,
992) -> Result<models::DeleteServerResponse, Error<DeleteServerError>> {
993    let local_var_configuration = configuration;
994
995    // unbox the parameters
996    let id = params.id;
997
998    let local_var_client = &local_var_configuration.client;
999
1000    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1001    let local_var_uri_str = format!("{}/servers/{id}", local_base_path, id = id);
1002    let mut local_var_req_builder =
1003        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1004
1005    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1006        local_var_req_builder =
1007            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1008    }
1009    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1010        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1011    };
1012
1013    let local_var_req = local_var_req_builder.build()?;
1014    let local_var_resp = local_var_client.execute(local_var_req).await?;
1015
1016    let local_var_status = local_var_resp.status();
1017    let local_var_content = local_var_resp.text().await?;
1018
1019    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1020        serde_json::from_str(&local_var_content).map_err(Error::from)
1021    } else {
1022        let local_var_entity: Option<DeleteServerError> =
1023            serde_json::from_str(&local_var_content).ok();
1024        let local_var_error = ResponseContent {
1025            status: local_var_status,
1026            content: local_var_content,
1027            entity: local_var_entity,
1028        };
1029        Err(Error::ResponseError(local_var_error))
1030    }
1031}
1032
1033/// Detaches an ISO from a Server. In case no ISO Image is attached to the Server, the status of the returned Action is immediately set to `success`.
1034pub async fn detach_iso_from_server(
1035    configuration: &configuration::Configuration,
1036    params: DetachIsoFromServerParams,
1037) -> Result<models::DetachIsoFromServerResponse, Error<DetachIsoFromServerError>> {
1038    let local_var_configuration = configuration;
1039
1040    // unbox the parameters
1041    let id = params.id;
1042
1043    let local_var_client = &local_var_configuration.client;
1044
1045    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1046    let local_var_uri_str = format!(
1047        "{}/servers/{id}/actions/detach_iso",
1048        local_base_path,
1049        id = id
1050    );
1051    let mut local_var_req_builder =
1052        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1053
1054    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1055        local_var_req_builder =
1056            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1057    }
1058    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1059        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1060    };
1061
1062    let local_var_req = local_var_req_builder.build()?;
1063    let local_var_resp = local_var_client.execute(local_var_req).await?;
1064
1065    let local_var_status = local_var_resp.status();
1066    let local_var_content = local_var_resp.text().await?;
1067
1068    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1069        serde_json::from_str(&local_var_content).map_err(Error::from)
1070    } else {
1071        let local_var_entity: Option<DetachIsoFromServerError> =
1072            serde_json::from_str(&local_var_content).ok();
1073        let local_var_error = ResponseContent {
1074            status: local_var_status,
1075            content: local_var_content,
1076            entity: local_var_entity,
1077        };
1078        Err(Error::ResponseError(local_var_error))
1079    }
1080}
1081
1082/// Detaches a Server from a network. The interface for this network will vanish.
1083pub async fn detach_server_from_network(
1084    configuration: &configuration::Configuration,
1085    params: DetachServerFromNetworkParams,
1086) -> Result<models::DetachServerFromNetworkResponse, Error<DetachServerFromNetworkError>> {
1087    let local_var_configuration = configuration;
1088
1089    // unbox the parameters
1090    let id = params.id;
1091    let detach_server_from_network_request = params.detach_server_from_network_request;
1092
1093    let local_var_client = &local_var_configuration.client;
1094
1095    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1096    let local_var_uri_str = format!(
1097        "{}/servers/{id}/actions/detach_from_network",
1098        local_base_path,
1099        id = id
1100    );
1101    let mut local_var_req_builder =
1102        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1103
1104    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1105        local_var_req_builder =
1106            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1107    }
1108    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1109        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1110    };
1111    local_var_req_builder = local_var_req_builder.json(&detach_server_from_network_request);
1112
1113    let local_var_req = local_var_req_builder.build()?;
1114    let local_var_resp = local_var_client.execute(local_var_req).await?;
1115
1116    let local_var_status = local_var_resp.status();
1117    let local_var_content = local_var_resp.text().await?;
1118
1119    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1120        serde_json::from_str(&local_var_content).map_err(Error::from)
1121    } else {
1122        let local_var_entity: Option<DetachServerFromNetworkError> =
1123            serde_json::from_str(&local_var_content).ok();
1124        let local_var_error = ResponseContent {
1125            status: local_var_status,
1126            content: local_var_content,
1127            entity: local_var_entity,
1128        };
1129        Err(Error::ResponseError(local_var_error))
1130    }
1131}
1132
1133/// Disables the automatic backup option and deletes all existing Backups for a Server. No more additional charges for backups will be made.  Caution: This immediately removes all existing backups for the Server!
1134pub async fn disable_backups_for_server(
1135    configuration: &configuration::Configuration,
1136    params: DisableBackupsForServerParams,
1137) -> Result<models::DisableBackupsForServerResponse, Error<DisableBackupsForServerError>> {
1138    let local_var_configuration = configuration;
1139
1140    // unbox the parameters
1141    let id = params.id;
1142
1143    let local_var_client = &local_var_configuration.client;
1144
1145    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1146    let local_var_uri_str = format!(
1147        "{}/servers/{id}/actions/disable_backup",
1148        local_base_path,
1149        id = id
1150    );
1151    let mut local_var_req_builder =
1152        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1153
1154    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1155        local_var_req_builder =
1156            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1157    }
1158    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1159        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1160    };
1161
1162    let local_var_req = local_var_req_builder.build()?;
1163    let local_var_resp = local_var_client.execute(local_var_req).await?;
1164
1165    let local_var_status = local_var_resp.status();
1166    let local_var_content = local_var_resp.text().await?;
1167
1168    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1169        serde_json::from_str(&local_var_content).map_err(Error::from)
1170    } else {
1171        let local_var_entity: Option<DisableBackupsForServerError> =
1172            serde_json::from_str(&local_var_content).ok();
1173        let local_var_error = ResponseContent {
1174            status: local_var_status,
1175            content: local_var_content,
1176            entity: local_var_entity,
1177        };
1178        Err(Error::ResponseError(local_var_error))
1179    }
1180}
1181
1182/// Disables the Hetzner Rescue System for a Server. This makes a Server start from its disks on next reboot.  Rescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.  Disabling rescue mode will not reboot your Server — you will have to do this yourself.
1183pub async fn disable_rescue_mode_for_server(
1184    configuration: &configuration::Configuration,
1185    params: DisableRescueModeForServerParams,
1186) -> Result<models::DisableRescueModeForServerResponse, Error<DisableRescueModeForServerError>> {
1187    let local_var_configuration = configuration;
1188
1189    // unbox the parameters
1190    let id = params.id;
1191
1192    let local_var_client = &local_var_configuration.client;
1193
1194    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1195    let local_var_uri_str = format!(
1196        "{}/servers/{id}/actions/disable_rescue",
1197        local_base_path,
1198        id = id
1199    );
1200    let mut local_var_req_builder =
1201        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1202
1203    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1204        local_var_req_builder =
1205            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1206    }
1207    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1209    };
1210
1211    let local_var_req = local_var_req_builder.build()?;
1212    let local_var_resp = local_var_client.execute(local_var_req).await?;
1213
1214    let local_var_status = local_var_resp.status();
1215    let local_var_content = local_var_resp.text().await?;
1216
1217    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1218        serde_json::from_str(&local_var_content).map_err(Error::from)
1219    } else {
1220        let local_var_entity: Option<DisableRescueModeForServerError> =
1221            serde_json::from_str(&local_var_content).ok();
1222        let local_var_error = ResponseContent {
1223            status: local_var_status,
1224            content: local_var_content,
1225            entity: local_var_entity,
1226        };
1227        Err(Error::ResponseError(local_var_error))
1228    }
1229}
1230
1231/// Enables and configures the automatic daily backup option for the Server. Enabling automatic backups will increase the price of the Server by 20%. In return, you will get seven slots where Images of type backup can be stored.  Backups are automatically created daily.
1232pub async fn enable_and_configure_backups_for_server(
1233    configuration: &configuration::Configuration,
1234    params: EnableAndConfigureBackupsForServerParams,
1235) -> Result<
1236    models::EnableAndConfigureBackupsForServerResponse,
1237    Error<EnableAndConfigureBackupsForServerError>,
1238> {
1239    let local_var_configuration = configuration;
1240
1241    // unbox the parameters
1242    let id = params.id;
1243
1244    let local_var_client = &local_var_configuration.client;
1245
1246    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1247    let local_var_uri_str = format!(
1248        "{}/servers/{id}/actions/enable_backup",
1249        local_base_path,
1250        id = id
1251    );
1252    let mut local_var_req_builder =
1253        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1254
1255    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1256        local_var_req_builder =
1257            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1258    }
1259    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1260        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1261    };
1262
1263    let local_var_req = local_var_req_builder.build()?;
1264    let local_var_resp = local_var_client.execute(local_var_req).await?;
1265
1266    let local_var_status = local_var_resp.status();
1267    let local_var_content = local_var_resp.text().await?;
1268
1269    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1270        serde_json::from_str(&local_var_content).map_err(Error::from)
1271    } else {
1272        let local_var_entity: Option<EnableAndConfigureBackupsForServerError> =
1273            serde_json::from_str(&local_var_content).ok();
1274        let local_var_error = ResponseContent {
1275            status: local_var_status,
1276            content: local_var_content,
1277            entity: local_var_entity,
1278        };
1279        Err(Error::ResponseError(local_var_error))
1280    }
1281}
1282
1283/// Enable the Hetzner Rescue System for this Server. The next time a Server with enabled rescue mode boots it will start a special minimal Linux distribution designed for repair and reinstall.  In case a Server cannot boot on its own you can use this to access a Server’s disks.  Rescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.  Enabling rescue mode will not [reboot](https://docs.hetzner.cloud/#server-actions-soft-reboot-a-server) your Server — you will have to do this yourself.
1284pub async fn enable_rescue_mode_for_server(
1285    configuration: &configuration::Configuration,
1286    params: EnableRescueModeForServerParams,
1287) -> Result<models::EnableRescueModeForServerResponse, Error<EnableRescueModeForServerError>> {
1288    let local_var_configuration = configuration;
1289
1290    // unbox the parameters
1291    let id = params.id;
1292    let enable_rescue_mode_for_server_request = params.enable_rescue_mode_for_server_request;
1293
1294    let local_var_client = &local_var_configuration.client;
1295
1296    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1297    let local_var_uri_str = format!(
1298        "{}/servers/{id}/actions/enable_rescue",
1299        local_base_path,
1300        id = id
1301    );
1302    let mut local_var_req_builder =
1303        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1304
1305    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1306        local_var_req_builder =
1307            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1308    }
1309    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1310        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1311    };
1312    local_var_req_builder = local_var_req_builder.json(&enable_rescue_mode_for_server_request);
1313
1314    let local_var_req = local_var_req_builder.build()?;
1315    let local_var_resp = local_var_client.execute(local_var_req).await?;
1316
1317    let local_var_status = local_var_resp.status();
1318    let local_var_content = local_var_resp.text().await?;
1319
1320    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1321        serde_json::from_str(&local_var_content).map_err(Error::from)
1322    } else {
1323        let local_var_entity: Option<EnableRescueModeForServerError> =
1324            serde_json::from_str(&local_var_content).ok();
1325        let local_var_error = ResponseContent {
1326            status: local_var_status,
1327            content: local_var_content,
1328            entity: local_var_entity,
1329        };
1330        Err(Error::ResponseError(local_var_error))
1331    }
1332}
1333
1334/// Returns a specific Action object for a Server.
1335pub async fn get_action_for_server(
1336    configuration: &configuration::Configuration,
1337    params: GetActionForServerParams,
1338) -> Result<models::GetActionResponse, Error<GetActionForServerError>> {
1339    let local_var_configuration = configuration;
1340
1341    // unbox the parameters
1342    let id = params.id;
1343    let action_id = params.action_id;
1344
1345    let local_var_client = &local_var_configuration.client;
1346
1347    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1348    let local_var_uri_str = format!(
1349        "{}/servers/{id}/actions/{action_id}",
1350        local_base_path,
1351        id = id,
1352        action_id = action_id
1353    );
1354    let mut local_var_req_builder =
1355        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1356
1357    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1358        local_var_req_builder =
1359            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1360    }
1361    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1362        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1363    };
1364
1365    let local_var_req = local_var_req_builder.build()?;
1366    let local_var_resp = local_var_client.execute(local_var_req).await?;
1367
1368    let local_var_status = local_var_resp.status();
1369    let local_var_content = local_var_resp.text().await?;
1370
1371    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1372        serde_json::from_str(&local_var_content).map_err(Error::from)
1373    } else {
1374        let local_var_entity: Option<GetActionForServerError> =
1375            serde_json::from_str(&local_var_content).ok();
1376        let local_var_error = ResponseContent {
1377            status: local_var_status,
1378            content: local_var_content,
1379            entity: local_var_entity,
1380        };
1381        Err(Error::ResponseError(local_var_error))
1382    }
1383}
1384
1385/// Get Metrics for specified Server.  You must specify the type of metric to get: cpu, disk or network. You can also specify more than one type by comma separation, e.g. cpu,disk.  Depending on the type you will get different time series data  | Type    | Timeseries              | Unit      | Description                                          | |---------|-------------------------|-----------|------------------------------------------------------| | cpu     | cpu                     | percent   | Percent CPU usage                                    | | disk    | disk.0.iops.read        | iop/s     | Number of read IO operations per second              | |         | disk.0.iops.write       | iop/s     | Number of write IO operations per second             | |         | disk.0.bandwidth.read   | bytes/s   | Bytes read per second                                | |         | disk.0.bandwidth.write  | bytes/s   | Bytes written per second                             | | network | network.0.pps.in        | packets/s | Public Network interface packets per second received | |         | network.0.pps.out       | packets/s | Public Network interface packets per second sent     | |         | network.0.bandwidth.in  | bytes/s   | Public Network interface bytes/s received            | |         | network.0.bandwidth.out | bytes/s   | Public Network interface bytes/s sent                |  Metrics are available for the last 30 days only.  If you do not provide the step argument we will automatically adjust it so that a maximum of 200 samples are returned.  We limit the number of samples returned to a maximum of 500 and will adjust the step parameter accordingly.
1386pub async fn get_metrics_for_server(
1387    configuration: &configuration::Configuration,
1388    params: GetMetricsForServerParams,
1389) -> Result<models::GetMetricsForServerResponse, Error<GetMetricsForServerError>> {
1390    let local_var_configuration = configuration;
1391
1392    // unbox the parameters
1393    let id = params.id;
1394    let r#type = params.r#type;
1395    let start = params.start;
1396    let end = params.end;
1397    let step = params.step;
1398
1399    let local_var_client = &local_var_configuration.client;
1400
1401    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1402    let local_var_uri_str = format!("{}/servers/{id}/metrics", local_base_path, id = id);
1403    let mut local_var_req_builder =
1404        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1405
1406    local_var_req_builder = match "multi" {
1407        "multi" => local_var_req_builder.query(
1408            &r#type
1409                .iter()
1410                .map(|p| ("type".to_owned(), p.to_string()))
1411                .collect::<Vec<(std::string::String, std::string::String)>>(),
1412        ),
1413        _ => local_var_req_builder.query(&[(
1414            "type",
1415            &r#type
1416                .iter()
1417                .map(|p| p.to_string())
1418                .collect::<Vec<String>>()
1419                .join(",")
1420                .to_string(),
1421        )]),
1422    };
1423    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
1424    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
1425    if let Some(ref local_var_str) = step {
1426        local_var_req_builder =
1427            local_var_req_builder.query(&[("step", &local_var_str.to_string())]);
1428    }
1429    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1430        local_var_req_builder =
1431            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1432    }
1433    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1434        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1435    };
1436
1437    let local_var_req = local_var_req_builder.build()?;
1438    let local_var_resp = local_var_client.execute(local_var_req).await?;
1439
1440    let local_var_status = local_var_resp.status();
1441    let local_var_content = local_var_resp.text().await?;
1442
1443    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1444        serde_json::from_str(&local_var_content).map_err(Error::from)
1445    } else {
1446        let local_var_entity: Option<GetMetricsForServerError> =
1447            serde_json::from_str(&local_var_content).ok();
1448        let local_var_error = ResponseContent {
1449            status: local_var_status,
1450            content: local_var_content,
1451            entity: local_var_entity,
1452        };
1453        Err(Error::ResponseError(local_var_error))
1454    }
1455}
1456
1457/// Returns a specific Server object. The Server must exist inside the Project.
1458pub async fn get_server(
1459    configuration: &configuration::Configuration,
1460    params: GetServerParams,
1461) -> Result<models::GetServerResponse, Error<GetServerError>> {
1462    let local_var_configuration = configuration;
1463
1464    // unbox the parameters
1465    let id = params.id;
1466
1467    let local_var_client = &local_var_configuration.client;
1468
1469    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1470    let local_var_uri_str = format!("{}/servers/{id}", local_base_path, id = id);
1471    let mut local_var_req_builder =
1472        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1473
1474    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1475        local_var_req_builder =
1476            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1477    }
1478    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1479        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1480    };
1481
1482    let local_var_req = local_var_req_builder.build()?;
1483    let local_var_resp = local_var_client.execute(local_var_req).await?;
1484
1485    let local_var_status = local_var_resp.status();
1486    let local_var_content = local_var_resp.text().await?;
1487
1488    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1489        serde_json::from_str(&local_var_content).map_err(Error::from)
1490    } else {
1491        let local_var_entity: Option<GetServerError> =
1492            serde_json::from_str(&local_var_content).ok();
1493        let local_var_error = ResponseContent {
1494            status: local_var_status,
1495            content: local_var_content,
1496            entity: local_var_entity,
1497        };
1498        Err(Error::ResponseError(local_var_error))
1499    }
1500}
1501
1502/// Returns a specific Action object.
1503pub async fn get_server_action(
1504    configuration: &configuration::Configuration,
1505    params: GetServerActionParams,
1506) -> Result<models::GetActionResponse, Error<GetServerActionError>> {
1507    let local_var_configuration = configuration;
1508
1509    // unbox the parameters
1510    let id = params.id;
1511
1512    let local_var_client = &local_var_configuration.client;
1513
1514    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1515    let local_var_uri_str = format!("{}/servers/actions/{id}", local_base_path, id = id);
1516    let mut local_var_req_builder =
1517        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1518
1519    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1520        local_var_req_builder =
1521            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1522    }
1523    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1524        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1525    };
1526
1527    let local_var_req = local_var_req_builder.build()?;
1528    let local_var_resp = local_var_client.execute(local_var_req).await?;
1529
1530    let local_var_status = local_var_resp.status();
1531    let local_var_content = local_var_resp.text().await?;
1532
1533    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1534        serde_json::from_str(&local_var_content).map_err(Error::from)
1535    } else {
1536        let local_var_entity: Option<GetServerActionError> =
1537            serde_json::from_str(&local_var_content).ok();
1538        let local_var_error = ResponseContent {
1539            status: local_var_status,
1540            content: local_var_content,
1541            entity: local_var_entity,
1542        };
1543        Err(Error::ResponseError(local_var_error))
1544    }
1545}
1546
1547/// Returns all Action objects for a Server. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.
1548pub async fn list_actions_for_server(
1549    configuration: &configuration::Configuration,
1550    params: ListActionsForServerParams,
1551) -> Result<models::ListActionsResponse, Error<ListActionsForServerError>> {
1552    let local_var_configuration = configuration;
1553
1554    // unbox the parameters
1555    let id = params.id;
1556    let sort = params.sort;
1557    let status = params.status;
1558    let page = params.page;
1559    let per_page = params.per_page;
1560
1561    let local_var_client = &local_var_configuration.client;
1562
1563    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1564    let local_var_uri_str = format!("{}/servers/{id}/actions", local_base_path, id = id);
1565    let mut local_var_req_builder =
1566        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1567
1568    if let Some(ref local_var_str) = sort {
1569        local_var_req_builder = match "multi" {
1570            "multi" => local_var_req_builder.query(
1571                &local_var_str
1572                    .iter()
1573                    .map(|p| ("sort".to_owned(), p.to_string()))
1574                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1575            ),
1576            _ => local_var_req_builder.query(&[(
1577                "sort",
1578                &local_var_str
1579                    .iter()
1580                    .map(|p| p.to_string())
1581                    .collect::<Vec<String>>()
1582                    .join(",")
1583                    .to_string(),
1584            )]),
1585        };
1586    }
1587    if let Some(ref local_var_str) = status {
1588        local_var_req_builder = match "multi" {
1589            "multi" => local_var_req_builder.query(
1590                &local_var_str
1591                    .iter()
1592                    .map(|p| ("status".to_owned(), p.to_string()))
1593                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1594            ),
1595            _ => local_var_req_builder.query(&[(
1596                "status",
1597                &local_var_str
1598                    .iter()
1599                    .map(|p| p.to_string())
1600                    .collect::<Vec<String>>()
1601                    .join(",")
1602                    .to_string(),
1603            )]),
1604        };
1605    }
1606    if let Some(ref local_var_str) = page {
1607        local_var_req_builder =
1608            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1609    }
1610    if let Some(ref local_var_str) = per_page {
1611        local_var_req_builder =
1612            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1613    }
1614    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1615        local_var_req_builder =
1616            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1617    }
1618    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1619        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1620    };
1621
1622    let local_var_req = local_var_req_builder.build()?;
1623    let local_var_resp = local_var_client.execute(local_var_req).await?;
1624
1625    let local_var_status = local_var_resp.status();
1626    let local_var_content = local_var_resp.text().await?;
1627
1628    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1629        serde_json::from_str(&local_var_content).map_err(Error::from)
1630    } else {
1631        let local_var_entity: Option<ListActionsForServerError> =
1632            serde_json::from_str(&local_var_content).ok();
1633        let local_var_error = ResponseContent {
1634            status: local_var_status,
1635            content: local_var_content,
1636            entity: local_var_entity,
1637        };
1638        Err(Error::ResponseError(local_var_error))
1639    }
1640}
1641
1642/// Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.
1643pub async fn list_server_actions(
1644    configuration: &configuration::Configuration,
1645    params: ListServerActionsParams,
1646) -> Result<models::ListActionsResponse, Error<ListServerActionsError>> {
1647    let local_var_configuration = configuration;
1648
1649    // unbox the parameters
1650    let id = params.id;
1651    let sort = params.sort;
1652    let status = params.status;
1653    let page = params.page;
1654    let per_page = params.per_page;
1655
1656    let local_var_client = &local_var_configuration.client;
1657
1658    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1659    let local_var_uri_str = format!("{}/servers/actions", local_base_path);
1660    let mut local_var_req_builder =
1661        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1662
1663    if let Some(ref local_var_str) = id {
1664        local_var_req_builder = match "multi" {
1665            "multi" => local_var_req_builder.query(
1666                &local_var_str
1667                    .iter()
1668                    .map(|p| ("id".to_owned(), p.to_string()))
1669                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1670            ),
1671            _ => local_var_req_builder.query(&[(
1672                "id",
1673                &local_var_str
1674                    .iter()
1675                    .map(|p| p.to_string())
1676                    .collect::<Vec<String>>()
1677                    .join(",")
1678                    .to_string(),
1679            )]),
1680        };
1681    }
1682    if let Some(ref local_var_str) = sort {
1683        local_var_req_builder = match "multi" {
1684            "multi" => local_var_req_builder.query(
1685                &local_var_str
1686                    .iter()
1687                    .map(|p| ("sort".to_owned(), p.to_string()))
1688                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1689            ),
1690            _ => local_var_req_builder.query(&[(
1691                "sort",
1692                &local_var_str
1693                    .iter()
1694                    .map(|p| p.to_string())
1695                    .collect::<Vec<String>>()
1696                    .join(",")
1697                    .to_string(),
1698            )]),
1699        };
1700    }
1701    if let Some(ref local_var_str) = status {
1702        local_var_req_builder = match "multi" {
1703            "multi" => local_var_req_builder.query(
1704                &local_var_str
1705                    .iter()
1706                    .map(|p| ("status".to_owned(), p.to_string()))
1707                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1708            ),
1709            _ => local_var_req_builder.query(&[(
1710                "status",
1711                &local_var_str
1712                    .iter()
1713                    .map(|p| p.to_string())
1714                    .collect::<Vec<String>>()
1715                    .join(",")
1716                    .to_string(),
1717            )]),
1718        };
1719    }
1720    if let Some(ref local_var_str) = page {
1721        local_var_req_builder =
1722            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1723    }
1724    if let Some(ref local_var_str) = per_page {
1725        local_var_req_builder =
1726            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1727    }
1728    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1729        local_var_req_builder =
1730            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1731    }
1732    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1733        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1734    };
1735
1736    let local_var_req = local_var_req_builder.build()?;
1737    let local_var_resp = local_var_client.execute(local_var_req).await?;
1738
1739    let local_var_status = local_var_resp.status();
1740    let local_var_content = local_var_resp.text().await?;
1741
1742    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1743        serde_json::from_str(&local_var_content).map_err(Error::from)
1744    } else {
1745        let local_var_entity: Option<ListServerActionsError> =
1746            serde_json::from_str(&local_var_content).ok();
1747        let local_var_error = ResponseContent {
1748            status: local_var_status,
1749            content: local_var_content,
1750            entity: local_var_entity,
1751        };
1752        Err(Error::ResponseError(local_var_error))
1753    }
1754}
1755
1756/// Returns all existing Server objects.
1757pub async fn list_servers(
1758    configuration: &configuration::Configuration,
1759    params: ListServersParams,
1760) -> Result<models::ListServersResponse, Error<ListServersError>> {
1761    let local_var_configuration = configuration;
1762
1763    // unbox the parameters
1764    let name = params.name;
1765    let label_selector = params.label_selector;
1766    let sort = params.sort;
1767    let status = params.status;
1768    let page = params.page;
1769    let per_page = params.per_page;
1770
1771    let local_var_client = &local_var_configuration.client;
1772
1773    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1774    let local_var_uri_str = format!("{}/servers", local_base_path);
1775    let mut local_var_req_builder =
1776        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1777
1778    if let Some(ref local_var_str) = name {
1779        local_var_req_builder =
1780            local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
1781    }
1782    if let Some(ref local_var_str) = label_selector {
1783        local_var_req_builder =
1784            local_var_req_builder.query(&[("label_selector", &local_var_str.to_string())]);
1785    }
1786    if let Some(ref local_var_str) = sort {
1787        local_var_req_builder = match "multi" {
1788            "multi" => local_var_req_builder.query(
1789                &local_var_str
1790                    .iter()
1791                    .map(|p| ("sort".to_owned(), p.to_string()))
1792                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1793            ),
1794            _ => local_var_req_builder.query(&[(
1795                "sort",
1796                &local_var_str
1797                    .iter()
1798                    .map(|p| p.to_string())
1799                    .collect::<Vec<String>>()
1800                    .join(",")
1801                    .to_string(),
1802            )]),
1803        };
1804    }
1805    if let Some(ref local_var_str) = status {
1806        local_var_req_builder = match "multi" {
1807            "multi" => local_var_req_builder.query(
1808                &local_var_str
1809                    .iter()
1810                    .map(|p| ("status".to_owned(), p.to_string()))
1811                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1812            ),
1813            _ => local_var_req_builder.query(&[(
1814                "status",
1815                &local_var_str
1816                    .iter()
1817                    .map(|p| p.to_string())
1818                    .collect::<Vec<String>>()
1819                    .join(",")
1820                    .to_string(),
1821            )]),
1822        };
1823    }
1824    if let Some(ref local_var_str) = page {
1825        local_var_req_builder =
1826            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1827    }
1828    if let Some(ref local_var_str) = per_page {
1829        local_var_req_builder =
1830            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1831    }
1832    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1833        local_var_req_builder =
1834            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1835    }
1836    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1837        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1838    };
1839
1840    let local_var_req = local_var_req_builder.build()?;
1841    let local_var_resp = local_var_client.execute(local_var_req).await?;
1842
1843    let local_var_status = local_var_resp.status();
1844    let local_var_content = local_var_resp.text().await?;
1845
1846    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1847        serde_json::from_str(&local_var_content).map_err(Error::from)
1848    } else {
1849        let local_var_entity: Option<ListServersError> =
1850            serde_json::from_str(&local_var_content).ok();
1851        let local_var_error = ResponseContent {
1852            status: local_var_status,
1853            content: local_var_content,
1854            entity: local_var_entity,
1855        };
1856        Err(Error::ResponseError(local_var_error))
1857    }
1858}
1859
1860/// Cuts power to the Server. This forcefully stops it without giving the Server operating system time to gracefully stop. May lead to data loss, equivalent to pulling the power cord. Power off should only be used when shutdown does not work.
1861pub async fn power_off_server(
1862    configuration: &configuration::Configuration,
1863    params: PowerOffServerParams,
1864) -> Result<models::PowerOffServerResponse, Error<PowerOffServerError>> {
1865    let local_var_configuration = configuration;
1866
1867    // unbox the parameters
1868    let id = params.id;
1869
1870    let local_var_client = &local_var_configuration.client;
1871
1872    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1873    let local_var_uri_str = format!("{}/servers/{id}/actions/poweroff", local_base_path, id = id);
1874    let mut local_var_req_builder =
1875        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1876
1877    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1878        local_var_req_builder =
1879            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1880    }
1881    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1882        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1883    };
1884
1885    let local_var_req = local_var_req_builder.build()?;
1886    let local_var_resp = local_var_client.execute(local_var_req).await?;
1887
1888    let local_var_status = local_var_resp.status();
1889    let local_var_content = local_var_resp.text().await?;
1890
1891    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1892        serde_json::from_str(&local_var_content).map_err(Error::from)
1893    } else {
1894        let local_var_entity: Option<PowerOffServerError> =
1895            serde_json::from_str(&local_var_content).ok();
1896        let local_var_error = ResponseContent {
1897            status: local_var_status,
1898            content: local_var_content,
1899            entity: local_var_entity,
1900        };
1901        Err(Error::ResponseError(local_var_error))
1902    }
1903}
1904
1905/// Starts a Server by turning its power on.
1906pub async fn power_on_server(
1907    configuration: &configuration::Configuration,
1908    params: PowerOnServerParams,
1909) -> Result<models::PowerOnServerResponse, Error<PowerOnServerError>> {
1910    let local_var_configuration = configuration;
1911
1912    // unbox the parameters
1913    let id = params.id;
1914
1915    let local_var_client = &local_var_configuration.client;
1916
1917    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1918    let local_var_uri_str = format!("{}/servers/{id}/actions/poweron", local_base_path, id = id);
1919    let mut local_var_req_builder =
1920        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1921
1922    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1923        local_var_req_builder =
1924            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1925    }
1926    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1927        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1928    };
1929
1930    let local_var_req = local_var_req_builder.build()?;
1931    let local_var_resp = local_var_client.execute(local_var_req).await?;
1932
1933    let local_var_status = local_var_resp.status();
1934    let local_var_content = local_var_resp.text().await?;
1935
1936    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1937        serde_json::from_str(&local_var_content).map_err(Error::from)
1938    } else {
1939        let local_var_entity: Option<PowerOnServerError> =
1940            serde_json::from_str(&local_var_content).ok();
1941        let local_var_error = ResponseContent {
1942            status: local_var_status,
1943            content: local_var_content,
1944            entity: local_var_entity,
1945        };
1946        Err(Error::ResponseError(local_var_error))
1947    }
1948}
1949
1950/// Rebuilds a Server overwriting its disk with the content of an Image, thereby **destroying all data** on the target Server  The Image can either be one you have created earlier (`backup` or `snapshot` Image) or it can be a completely fresh `system` Image provided by us. You can get a list of all available Images with `GET /images`.  Your Server will automatically be powered off before the rebuild command executes.
1951pub async fn rebuild_server_from_image(
1952    configuration: &configuration::Configuration,
1953    params: RebuildServerFromImageParams,
1954) -> Result<models::RebuildServerFromImageResponse, Error<RebuildServerFromImageError>> {
1955    let local_var_configuration = configuration;
1956
1957    // unbox the parameters
1958    let id = params.id;
1959    let rebuild_server_from_image_request = params.rebuild_server_from_image_request;
1960
1961    let local_var_client = &local_var_configuration.client;
1962
1963    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1964    let local_var_uri_str = format!("{}/servers/{id}/actions/rebuild", local_base_path, id = id);
1965    let mut local_var_req_builder =
1966        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1967
1968    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1969        local_var_req_builder =
1970            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1971    }
1972    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1973        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1974    };
1975    local_var_req_builder = local_var_req_builder.json(&rebuild_server_from_image_request);
1976
1977    let local_var_req = local_var_req_builder.build()?;
1978    let local_var_resp = local_var_client.execute(local_var_req).await?;
1979
1980    let local_var_status = local_var_resp.status();
1981    let local_var_content = local_var_resp.text().await?;
1982
1983    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1984        serde_json::from_str(&local_var_content).map_err(Error::from)
1985    } else {
1986        let local_var_entity: Option<RebuildServerFromImageError> =
1987            serde_json::from_str(&local_var_content).ok();
1988        let local_var_error = ResponseContent {
1989            status: local_var_status,
1990            content: local_var_content,
1991            entity: local_var_entity,
1992        };
1993        Err(Error::ResponseError(local_var_error))
1994    }
1995}
1996
1997/// Removes a Server from a Placement Group.
1998pub async fn remove_from_placement_group(
1999    configuration: &configuration::Configuration,
2000    params: RemoveFromPlacementGroupParams,
2001) -> Result<models::RemoveFromPlacementGroupResponse, Error<RemoveFromPlacementGroupError>> {
2002    let local_var_configuration = configuration;
2003
2004    // unbox the parameters
2005    let id = params.id;
2006
2007    let local_var_client = &local_var_configuration.client;
2008
2009    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2010    let local_var_uri_str = format!(
2011        "{}/servers/{id}/actions/remove_from_placement_group",
2012        local_base_path,
2013        id = id
2014    );
2015    let mut local_var_req_builder =
2016        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2017
2018    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2019        local_var_req_builder =
2020            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2021    }
2022    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2023        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2024    };
2025
2026    let local_var_req = local_var_req_builder.build()?;
2027    let local_var_resp = local_var_client.execute(local_var_req).await?;
2028
2029    let local_var_status = local_var_resp.status();
2030    let local_var_content = local_var_resp.text().await?;
2031
2032    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2033        serde_json::from_str(&local_var_content).map_err(Error::from)
2034    } else {
2035        let local_var_entity: Option<RemoveFromPlacementGroupError> =
2036            serde_json::from_str(&local_var_content).ok();
2037        let local_var_error = ResponseContent {
2038            status: local_var_status,
2039            content: local_var_content,
2040            entity: local_var_entity,
2041        };
2042        Err(Error::ResponseError(local_var_error))
2043    }
2044}
2045
2046/// Updates a Server. You can update a Server’s name and a Server’s labels.  Please note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).
2047pub async fn replace_server(
2048    configuration: &configuration::Configuration,
2049    params: ReplaceServerParams,
2050) -> Result<models::ReplaceServerResponse, Error<ReplaceServerError>> {
2051    let local_var_configuration = configuration;
2052
2053    // unbox the parameters
2054    let id = params.id;
2055    let replace_server_request = params.replace_server_request;
2056
2057    let local_var_client = &local_var_configuration.client;
2058
2059    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2060    let local_var_uri_str = format!("{}/servers/{id}", local_base_path, id = id);
2061    let mut local_var_req_builder =
2062        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
2063
2064    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2065        local_var_req_builder =
2066            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2067    }
2068    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2069        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2070    };
2071    local_var_req_builder = local_var_req_builder.json(&replace_server_request);
2072
2073    let local_var_req = local_var_req_builder.build()?;
2074    let local_var_resp = local_var_client.execute(local_var_req).await?;
2075
2076    let local_var_status = local_var_resp.status();
2077    let local_var_content = local_var_resp.text().await?;
2078
2079    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2080        serde_json::from_str(&local_var_content).map_err(Error::from)
2081    } else {
2082        let local_var_entity: Option<ReplaceServerError> =
2083            serde_json::from_str(&local_var_content).ok();
2084        let local_var_error = ResponseContent {
2085            status: local_var_status,
2086            content: local_var_content,
2087            entity: local_var_entity,
2088        };
2089        Err(Error::ResponseError(local_var_error))
2090    }
2091}
2092
2093/// Requests credentials for remote access via VNC over websocket to keyboard, monitor, and mouse for a Server. The provided URL is valid for 1 minute, after this period a new url needs to be created to connect to the Server. How long the connection is open after the initial connect is not subject to this timeout.
2094pub async fn request_console_for_server(
2095    configuration: &configuration::Configuration,
2096    params: RequestConsoleForServerParams,
2097) -> Result<models::RequestConsoleForServerResponse, Error<RequestConsoleForServerError>> {
2098    let local_var_configuration = configuration;
2099
2100    // unbox the parameters
2101    let id = params.id;
2102
2103    let local_var_client = &local_var_configuration.client;
2104
2105    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2106    let local_var_uri_str = format!(
2107        "{}/servers/{id}/actions/request_console",
2108        local_base_path,
2109        id = id
2110    );
2111    let mut local_var_req_builder =
2112        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2113
2114    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2115        local_var_req_builder =
2116            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2117    }
2118    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2119        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2120    };
2121
2122    let local_var_req = local_var_req_builder.build()?;
2123    let local_var_resp = local_var_client.execute(local_var_req).await?;
2124
2125    let local_var_status = local_var_resp.status();
2126    let local_var_content = local_var_resp.text().await?;
2127
2128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2129        serde_json::from_str(&local_var_content).map_err(Error::from)
2130    } else {
2131        let local_var_entity: Option<RequestConsoleForServerError> =
2132            serde_json::from_str(&local_var_content).ok();
2133        let local_var_error = ResponseContent {
2134            status: local_var_status,
2135            content: local_var_content,
2136            entity: local_var_entity,
2137        };
2138        Err(Error::ResponseError(local_var_error))
2139    }
2140}
2141
2142/// Resets the root password. Only works for Linux systems that are running the qemu guest agent. Server must be powered on (status `running`) in order for this operation to succeed.  This will generate a new password for this Server and return it.  If this does not succeed you can use the rescue system to netboot the Server and manually change your Server password by hand.
2143pub async fn reset_root_password_of_server(
2144    configuration: &configuration::Configuration,
2145    params: ResetRootPasswordOfServerParams,
2146) -> Result<models::ResetRootPasswordOfServerResponse, Error<ResetRootPasswordOfServerError>> {
2147    let local_var_configuration = configuration;
2148
2149    // unbox the parameters
2150    let id = params.id;
2151
2152    let local_var_client = &local_var_configuration.client;
2153
2154    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2155    let local_var_uri_str = format!(
2156        "{}/servers/{id}/actions/reset_password",
2157        local_base_path,
2158        id = id
2159    );
2160    let mut local_var_req_builder =
2161        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2162
2163    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2164        local_var_req_builder =
2165            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2166    }
2167    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2168        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2169    };
2170
2171    let local_var_req = local_var_req_builder.build()?;
2172    let local_var_resp = local_var_client.execute(local_var_req).await?;
2173
2174    let local_var_status = local_var_resp.status();
2175    let local_var_content = local_var_resp.text().await?;
2176
2177    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2178        serde_json::from_str(&local_var_content).map_err(Error::from)
2179    } else {
2180        let local_var_entity: Option<ResetRootPasswordOfServerError> =
2181            serde_json::from_str(&local_var_content).ok();
2182        let local_var_error = ResponseContent {
2183            status: local_var_status,
2184            content: local_var_content,
2185            entity: local_var_entity,
2186        };
2187        Err(Error::ResponseError(local_var_error))
2188    }
2189}
2190
2191/// Cuts power to a Server and starts it again. This forcefully stops it without giving the Server operating system time to gracefully stop. This may lead to data loss, it’s equivalent to pulling the power cord and plugging it in again. Reset should only be used when reboot does not work.
2192pub async fn reset_server(
2193    configuration: &configuration::Configuration,
2194    params: ResetServerParams,
2195) -> Result<models::ResetServerResponse, Error<ResetServerError>> {
2196    let local_var_configuration = configuration;
2197
2198    // unbox the parameters
2199    let id = params.id;
2200
2201    let local_var_client = &local_var_configuration.client;
2202
2203    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2204    let local_var_uri_str = format!("{}/servers/{id}/actions/reset", local_base_path, id = id);
2205    let mut local_var_req_builder =
2206        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2207
2208    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2209        local_var_req_builder =
2210            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2211    }
2212    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2213        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2214    };
2215
2216    let local_var_req = local_var_req_builder.build()?;
2217    let local_var_resp = local_var_client.execute(local_var_req).await?;
2218
2219    let local_var_status = local_var_resp.status();
2220    let local_var_content = local_var_resp.text().await?;
2221
2222    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2223        serde_json::from_str(&local_var_content).map_err(Error::from)
2224    } else {
2225        let local_var_entity: Option<ResetServerError> =
2226            serde_json::from_str(&local_var_content).ok();
2227        let local_var_error = ResponseContent {
2228            status: local_var_status,
2229            content: local_var_content,
2230            entity: local_var_entity,
2231        };
2232        Err(Error::ResponseError(local_var_error))
2233    }
2234}
2235
2236/// Shuts down a Server gracefully by sending an ACPI shutdown request. The Server operating system must support ACPI and react to the request, otherwise the Server will not shut down. Please note that the `action` status in this case only reflects whether the action was sent to the server. It does not mean that the server actually shut down successfully. If you need to ensure that the server is off, use the `poweroff` action.
2237pub async fn shutdown_server(
2238    configuration: &configuration::Configuration,
2239    params: ShutdownServerParams,
2240) -> Result<models::ShutdownServerResponse, Error<ShutdownServerError>> {
2241    let local_var_configuration = configuration;
2242
2243    // unbox the parameters
2244    let id = params.id;
2245
2246    let local_var_client = &local_var_configuration.client;
2247
2248    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2249    let local_var_uri_str = format!("{}/servers/{id}/actions/shutdown", local_base_path, id = id);
2250    let mut local_var_req_builder =
2251        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2252
2253    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2254        local_var_req_builder =
2255            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2256    }
2257    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2258        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2259    };
2260
2261    let local_var_req = local_var_req_builder.build()?;
2262    let local_var_resp = local_var_client.execute(local_var_req).await?;
2263
2264    let local_var_status = local_var_resp.status();
2265    let local_var_content = local_var_resp.text().await?;
2266
2267    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2268        serde_json::from_str(&local_var_content).map_err(Error::from)
2269    } else {
2270        let local_var_entity: Option<ShutdownServerError> =
2271            serde_json::from_str(&local_var_content).ok();
2272        let local_var_error = ResponseContent {
2273            status: local_var_status,
2274            content: local_var_content,
2275            entity: local_var_entity,
2276        };
2277        Err(Error::ResponseError(local_var_error))
2278    }
2279}
2280
2281/// Reboots a Server gracefully by sending an ACPI request. The Server operating system must support ACPI and react to the request, otherwise the Server will not reboot.
2282pub async fn soft_reboot_server(
2283    configuration: &configuration::Configuration,
2284    params: SoftRebootServerParams,
2285) -> Result<models::SoftRebootServerResponse, Error<SoftRebootServerError>> {
2286    let local_var_configuration = configuration;
2287
2288    // unbox the parameters
2289    let id = params.id;
2290
2291    let local_var_client = &local_var_configuration.client;
2292
2293    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2294    let local_var_uri_str = format!("{}/servers/{id}/actions/reboot", local_base_path, id = id);
2295    let mut local_var_req_builder =
2296        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2297
2298    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2299        local_var_req_builder =
2300            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2301    }
2302    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2303        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2304    };
2305
2306    let local_var_req = local_var_req_builder.build()?;
2307    let local_var_resp = local_var_client.execute(local_var_req).await?;
2308
2309    let local_var_status = local_var_resp.status();
2310    let local_var_content = local_var_resp.text().await?;
2311
2312    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2313        serde_json::from_str(&local_var_content).map_err(Error::from)
2314    } else {
2315        let local_var_entity: Option<SoftRebootServerError> =
2316            serde_json::from_str(&local_var_content).ok();
2317        let local_var_error = ResponseContent {
2318            status: local_var_status,
2319            content: local_var_content,
2320            entity: local_var_entity,
2321        };
2322        Err(Error::ResponseError(local_var_error))
2323    }
2324}