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.26.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: Option<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: Option<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: Option<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: Option<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`.
54    pub change_reverse_dns_entry_for_this_server_request:
55        Option<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: Option<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: Option<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: Option<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 Datacenter.  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: Option<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: Option<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: Option<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: 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](#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](#pagination)\".
188    pub page: Option<i64>,
189    /// Maximum number of entries returned per page. For more information, see \"[Pagination](#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](#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](#pagination)\".
203    pub page: Option<i64>,
204    /// Maximum number of entries returned per page. For more information, see \"[Pagination](#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](#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](#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](#pagination)\".
220    pub page: Option<i64>,
221    /// Maximum number of entries returned per page. For more information, see \"[Pagination](#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: Option<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: Option<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 = local_var_req_builder.query(&[("type", &r#type.to_string())]);
1407    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
1408    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
1409    if let Some(ref local_var_str) = step {
1410        local_var_req_builder =
1411            local_var_req_builder.query(&[("step", &local_var_str.to_string())]);
1412    }
1413    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1414        local_var_req_builder =
1415            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1416    }
1417    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1418        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1419    };
1420
1421    let local_var_req = local_var_req_builder.build()?;
1422    let local_var_resp = local_var_client.execute(local_var_req).await?;
1423
1424    let local_var_status = local_var_resp.status();
1425    let local_var_content = local_var_resp.text().await?;
1426
1427    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1428        serde_json::from_str(&local_var_content).map_err(Error::from)
1429    } else {
1430        let local_var_entity: Option<GetMetricsForServerError> =
1431            serde_json::from_str(&local_var_content).ok();
1432        let local_var_error = ResponseContent {
1433            status: local_var_status,
1434            content: local_var_content,
1435            entity: local_var_entity,
1436        };
1437        Err(Error::ResponseError(local_var_error))
1438    }
1439}
1440
1441/// Returns a specific Server object. The Server must exist inside the Project.
1442pub async fn get_server(
1443    configuration: &configuration::Configuration,
1444    params: GetServerParams,
1445) -> Result<models::GetServerResponse, Error<GetServerError>> {
1446    let local_var_configuration = configuration;
1447
1448    // unbox the parameters
1449    let id = params.id;
1450
1451    let local_var_client = &local_var_configuration.client;
1452
1453    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1454    let local_var_uri_str = format!("{}/servers/{id}", local_base_path, id = id);
1455    let mut local_var_req_builder =
1456        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1457
1458    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1459        local_var_req_builder =
1460            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1461    }
1462    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1463        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1464    };
1465
1466    let local_var_req = local_var_req_builder.build()?;
1467    let local_var_resp = local_var_client.execute(local_var_req).await?;
1468
1469    let local_var_status = local_var_resp.status();
1470    let local_var_content = local_var_resp.text().await?;
1471
1472    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1473        serde_json::from_str(&local_var_content).map_err(Error::from)
1474    } else {
1475        let local_var_entity: Option<GetServerError> =
1476            serde_json::from_str(&local_var_content).ok();
1477        let local_var_error = ResponseContent {
1478            status: local_var_status,
1479            content: local_var_content,
1480            entity: local_var_entity,
1481        };
1482        Err(Error::ResponseError(local_var_error))
1483    }
1484}
1485
1486/// Returns a specific Action object.
1487pub async fn get_server_action(
1488    configuration: &configuration::Configuration,
1489    params: GetServerActionParams,
1490) -> Result<models::GetActionResponse, Error<GetServerActionError>> {
1491    let local_var_configuration = configuration;
1492
1493    // unbox the parameters
1494    let id = params.id;
1495
1496    let local_var_client = &local_var_configuration.client;
1497
1498    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1499    let local_var_uri_str = format!("{}/servers/actions/{id}", local_base_path, id = id);
1500    let mut local_var_req_builder =
1501        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1502
1503    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1504        local_var_req_builder =
1505            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1506    }
1507    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1508        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1509    };
1510
1511    let local_var_req = local_var_req_builder.build()?;
1512    let local_var_resp = local_var_client.execute(local_var_req).await?;
1513
1514    let local_var_status = local_var_resp.status();
1515    let local_var_content = local_var_resp.text().await?;
1516
1517    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1518        serde_json::from_str(&local_var_content).map_err(Error::from)
1519    } else {
1520        let local_var_entity: Option<GetServerActionError> =
1521            serde_json::from_str(&local_var_content).ok();
1522        let local_var_error = ResponseContent {
1523            status: local_var_status,
1524            content: local_var_content,
1525            entity: local_var_entity,
1526        };
1527        Err(Error::ResponseError(local_var_error))
1528    }
1529}
1530
1531/// 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.
1532pub async fn list_actions_for_server(
1533    configuration: &configuration::Configuration,
1534    params: ListActionsForServerParams,
1535) -> Result<models::ListActionsResponse, Error<ListActionsForServerError>> {
1536    let local_var_configuration = configuration;
1537
1538    // unbox the parameters
1539    let id = params.id;
1540    let sort = params.sort;
1541    let status = params.status;
1542    let page = params.page;
1543    let per_page = params.per_page;
1544
1545    let local_var_client = &local_var_configuration.client;
1546
1547    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1548    let local_var_uri_str = format!("{}/servers/{id}/actions", local_base_path, id = id);
1549    let mut local_var_req_builder =
1550        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1551
1552    if let Some(ref local_var_str) = sort {
1553        local_var_req_builder = match "multi" {
1554            "multi" => local_var_req_builder.query(
1555                &local_var_str
1556                    .iter()
1557                    .map(|p| ("sort".to_owned(), p.to_string()))
1558                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1559            ),
1560            _ => local_var_req_builder.query(&[(
1561                "sort",
1562                &local_var_str
1563                    .iter()
1564                    .map(|p| p.to_string())
1565                    .collect::<Vec<String>>()
1566                    .join(",")
1567                    .to_string(),
1568            )]),
1569        };
1570    }
1571    if let Some(ref local_var_str) = status {
1572        local_var_req_builder = match "multi" {
1573            "multi" => local_var_req_builder.query(
1574                &local_var_str
1575                    .iter()
1576                    .map(|p| ("status".to_owned(), p.to_string()))
1577                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1578            ),
1579            _ => local_var_req_builder.query(&[(
1580                "status",
1581                &local_var_str
1582                    .iter()
1583                    .map(|p| p.to_string())
1584                    .collect::<Vec<String>>()
1585                    .join(",")
1586                    .to_string(),
1587            )]),
1588        };
1589    }
1590    if let Some(ref local_var_str) = page {
1591        local_var_req_builder =
1592            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1593    }
1594    if let Some(ref local_var_str) = per_page {
1595        local_var_req_builder =
1596            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1597    }
1598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1599        local_var_req_builder =
1600            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1601    }
1602    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1603        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1604    };
1605
1606    let local_var_req = local_var_req_builder.build()?;
1607    let local_var_resp = local_var_client.execute(local_var_req).await?;
1608
1609    let local_var_status = local_var_resp.status();
1610    let local_var_content = local_var_resp.text().await?;
1611
1612    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1613        serde_json::from_str(&local_var_content).map_err(Error::from)
1614    } else {
1615        let local_var_entity: Option<ListActionsForServerError> =
1616            serde_json::from_str(&local_var_content).ok();
1617        let local_var_error = ResponseContent {
1618            status: local_var_status,
1619            content: local_var_content,
1620            entity: local_var_entity,
1621        };
1622        Err(Error::ResponseError(local_var_error))
1623    }
1624}
1625
1626/// Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.
1627pub async fn list_server_actions(
1628    configuration: &configuration::Configuration,
1629    params: ListServerActionsParams,
1630) -> Result<models::ListActionsResponse, Error<ListServerActionsError>> {
1631    let local_var_configuration = configuration;
1632
1633    // unbox the parameters
1634    let id = params.id;
1635    let sort = params.sort;
1636    let status = params.status;
1637    let page = params.page;
1638    let per_page = params.per_page;
1639
1640    let local_var_client = &local_var_configuration.client;
1641
1642    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1643    let local_var_uri_str = format!("{}/servers/actions", local_base_path);
1644    let mut local_var_req_builder =
1645        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1646
1647    if let Some(ref local_var_str) = id {
1648        local_var_req_builder = match "multi" {
1649            "multi" => local_var_req_builder.query(
1650                &local_var_str
1651                    .iter()
1652                    .map(|p| ("id".to_owned(), p.to_string()))
1653                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1654            ),
1655            _ => local_var_req_builder.query(&[(
1656                "id",
1657                &local_var_str
1658                    .iter()
1659                    .map(|p| p.to_string())
1660                    .collect::<Vec<String>>()
1661                    .join(",")
1662                    .to_string(),
1663            )]),
1664        };
1665    }
1666    if let Some(ref local_var_str) = sort {
1667        local_var_req_builder = match "multi" {
1668            "multi" => local_var_req_builder.query(
1669                &local_var_str
1670                    .iter()
1671                    .map(|p| ("sort".to_owned(), p.to_string()))
1672                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1673            ),
1674            _ => local_var_req_builder.query(&[(
1675                "sort",
1676                &local_var_str
1677                    .iter()
1678                    .map(|p| p.to_string())
1679                    .collect::<Vec<String>>()
1680                    .join(",")
1681                    .to_string(),
1682            )]),
1683        };
1684    }
1685    if let Some(ref local_var_str) = status {
1686        local_var_req_builder = match "multi" {
1687            "multi" => local_var_req_builder.query(
1688                &local_var_str
1689                    .iter()
1690                    .map(|p| ("status".to_owned(), p.to_string()))
1691                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1692            ),
1693            _ => local_var_req_builder.query(&[(
1694                "status",
1695                &local_var_str
1696                    .iter()
1697                    .map(|p| p.to_string())
1698                    .collect::<Vec<String>>()
1699                    .join(",")
1700                    .to_string(),
1701            )]),
1702        };
1703    }
1704    if let Some(ref local_var_str) = page {
1705        local_var_req_builder =
1706            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1707    }
1708    if let Some(ref local_var_str) = per_page {
1709        local_var_req_builder =
1710            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1711    }
1712    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1713        local_var_req_builder =
1714            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1715    }
1716    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1717        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1718    };
1719
1720    let local_var_req = local_var_req_builder.build()?;
1721    let local_var_resp = local_var_client.execute(local_var_req).await?;
1722
1723    let local_var_status = local_var_resp.status();
1724    let local_var_content = local_var_resp.text().await?;
1725
1726    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1727        serde_json::from_str(&local_var_content).map_err(Error::from)
1728    } else {
1729        let local_var_entity: Option<ListServerActionsError> =
1730            serde_json::from_str(&local_var_content).ok();
1731        let local_var_error = ResponseContent {
1732            status: local_var_status,
1733            content: local_var_content,
1734            entity: local_var_entity,
1735        };
1736        Err(Error::ResponseError(local_var_error))
1737    }
1738}
1739
1740/// Returns all existing Server objects.
1741pub async fn list_servers(
1742    configuration: &configuration::Configuration,
1743    params: ListServersParams,
1744) -> Result<models::ListServersResponse, Error<ListServersError>> {
1745    let local_var_configuration = configuration;
1746
1747    // unbox the parameters
1748    let name = params.name;
1749    let label_selector = params.label_selector;
1750    let sort = params.sort;
1751    let status = params.status;
1752    let page = params.page;
1753    let per_page = params.per_page;
1754
1755    let local_var_client = &local_var_configuration.client;
1756
1757    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1758    let local_var_uri_str = format!("{}/servers", local_base_path);
1759    let mut local_var_req_builder =
1760        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1761
1762    if let Some(ref local_var_str) = name {
1763        local_var_req_builder =
1764            local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
1765    }
1766    if let Some(ref local_var_str) = label_selector {
1767        local_var_req_builder =
1768            local_var_req_builder.query(&[("label_selector", &local_var_str.to_string())]);
1769    }
1770    if let Some(ref local_var_str) = sort {
1771        local_var_req_builder = match "multi" {
1772            "multi" => local_var_req_builder.query(
1773                &local_var_str
1774                    .iter()
1775                    .map(|p| ("sort".to_owned(), p.to_string()))
1776                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1777            ),
1778            _ => local_var_req_builder.query(&[(
1779                "sort",
1780                &local_var_str
1781                    .iter()
1782                    .map(|p| p.to_string())
1783                    .collect::<Vec<String>>()
1784                    .join(",")
1785                    .to_string(),
1786            )]),
1787        };
1788    }
1789    if let Some(ref local_var_str) = status {
1790        local_var_req_builder = match "multi" {
1791            "multi" => local_var_req_builder.query(
1792                &local_var_str
1793                    .iter()
1794                    .map(|p| ("status".to_owned(), p.to_string()))
1795                    .collect::<Vec<(std::string::String, std::string::String)>>(),
1796            ),
1797            _ => local_var_req_builder.query(&[(
1798                "status",
1799                &local_var_str
1800                    .iter()
1801                    .map(|p| p.to_string())
1802                    .collect::<Vec<String>>()
1803                    .join(",")
1804                    .to_string(),
1805            )]),
1806        };
1807    }
1808    if let Some(ref local_var_str) = page {
1809        local_var_req_builder =
1810            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1811    }
1812    if let Some(ref local_var_str) = per_page {
1813        local_var_req_builder =
1814            local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
1815    }
1816    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1817        local_var_req_builder =
1818            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1819    }
1820    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1821        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1822    };
1823
1824    let local_var_req = local_var_req_builder.build()?;
1825    let local_var_resp = local_var_client.execute(local_var_req).await?;
1826
1827    let local_var_status = local_var_resp.status();
1828    let local_var_content = local_var_resp.text().await?;
1829
1830    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1831        serde_json::from_str(&local_var_content).map_err(Error::from)
1832    } else {
1833        let local_var_entity: Option<ListServersError> =
1834            serde_json::from_str(&local_var_content).ok();
1835        let local_var_error = ResponseContent {
1836            status: local_var_status,
1837            content: local_var_content,
1838            entity: local_var_entity,
1839        };
1840        Err(Error::ResponseError(local_var_error))
1841    }
1842}
1843
1844/// 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.
1845pub async fn power_off_server(
1846    configuration: &configuration::Configuration,
1847    params: PowerOffServerParams,
1848) -> Result<models::PowerOffServerResponse, Error<PowerOffServerError>> {
1849    let local_var_configuration = configuration;
1850
1851    // unbox the parameters
1852    let id = params.id;
1853
1854    let local_var_client = &local_var_configuration.client;
1855
1856    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1857    let local_var_uri_str = format!("{}/servers/{id}/actions/poweroff", local_base_path, id = id);
1858    let mut local_var_req_builder =
1859        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1860
1861    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1862        local_var_req_builder =
1863            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1864    }
1865    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1866        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1867    };
1868
1869    let local_var_req = local_var_req_builder.build()?;
1870    let local_var_resp = local_var_client.execute(local_var_req).await?;
1871
1872    let local_var_status = local_var_resp.status();
1873    let local_var_content = local_var_resp.text().await?;
1874
1875    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1876        serde_json::from_str(&local_var_content).map_err(Error::from)
1877    } else {
1878        let local_var_entity: Option<PowerOffServerError> =
1879            serde_json::from_str(&local_var_content).ok();
1880        let local_var_error = ResponseContent {
1881            status: local_var_status,
1882            content: local_var_content,
1883            entity: local_var_entity,
1884        };
1885        Err(Error::ResponseError(local_var_error))
1886    }
1887}
1888
1889/// Starts a Server by turning its power on.
1890pub async fn power_on_server(
1891    configuration: &configuration::Configuration,
1892    params: PowerOnServerParams,
1893) -> Result<models::PowerOnServerResponse, Error<PowerOnServerError>> {
1894    let local_var_configuration = configuration;
1895
1896    // unbox the parameters
1897    let id = params.id;
1898
1899    let local_var_client = &local_var_configuration.client;
1900
1901    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1902    let local_var_uri_str = format!("{}/servers/{id}/actions/poweron", local_base_path, id = id);
1903    let mut local_var_req_builder =
1904        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1905
1906    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1907        local_var_req_builder =
1908            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1909    }
1910    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1911        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1912    };
1913
1914    let local_var_req = local_var_req_builder.build()?;
1915    let local_var_resp = local_var_client.execute(local_var_req).await?;
1916
1917    let local_var_status = local_var_resp.status();
1918    let local_var_content = local_var_resp.text().await?;
1919
1920    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1921        serde_json::from_str(&local_var_content).map_err(Error::from)
1922    } else {
1923        let local_var_entity: Option<PowerOnServerError> =
1924            serde_json::from_str(&local_var_content).ok();
1925        let local_var_error = ResponseContent {
1926            status: local_var_status,
1927            content: local_var_content,
1928            entity: local_var_entity,
1929        };
1930        Err(Error::ResponseError(local_var_error))
1931    }
1932}
1933
1934/// 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.
1935pub async fn rebuild_server_from_image(
1936    configuration: &configuration::Configuration,
1937    params: RebuildServerFromImageParams,
1938) -> Result<models::RebuildServerFromImageResponse, Error<RebuildServerFromImageError>> {
1939    let local_var_configuration = configuration;
1940
1941    // unbox the parameters
1942    let id = params.id;
1943    let rebuild_server_from_image_request = params.rebuild_server_from_image_request;
1944
1945    let local_var_client = &local_var_configuration.client;
1946
1947    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1948    let local_var_uri_str = format!("{}/servers/{id}/actions/rebuild", local_base_path, id = id);
1949    let mut local_var_req_builder =
1950        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1951
1952    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1953        local_var_req_builder =
1954            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1955    }
1956    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
1957        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1958    };
1959    local_var_req_builder = local_var_req_builder.json(&rebuild_server_from_image_request);
1960
1961    let local_var_req = local_var_req_builder.build()?;
1962    let local_var_resp = local_var_client.execute(local_var_req).await?;
1963
1964    let local_var_status = local_var_resp.status();
1965    let local_var_content = local_var_resp.text().await?;
1966
1967    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1968        serde_json::from_str(&local_var_content).map_err(Error::from)
1969    } else {
1970        let local_var_entity: Option<RebuildServerFromImageError> =
1971            serde_json::from_str(&local_var_content).ok();
1972        let local_var_error = ResponseContent {
1973            status: local_var_status,
1974            content: local_var_content,
1975            entity: local_var_entity,
1976        };
1977        Err(Error::ResponseError(local_var_error))
1978    }
1979}
1980
1981/// Removes a Server from a Placement Group.
1982pub async fn remove_from_placement_group(
1983    configuration: &configuration::Configuration,
1984    params: RemoveFromPlacementGroupParams,
1985) -> Result<models::RemoveFromPlacementGroupResponse, Error<RemoveFromPlacementGroupError>> {
1986    let local_var_configuration = configuration;
1987
1988    // unbox the parameters
1989    let id = params.id;
1990
1991    let local_var_client = &local_var_configuration.client;
1992
1993    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
1994    let local_var_uri_str = format!(
1995        "{}/servers/{id}/actions/remove_from_placement_group",
1996        local_base_path,
1997        id = id
1998    );
1999    let mut local_var_req_builder =
2000        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2001
2002    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2003        local_var_req_builder =
2004            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2005    }
2006    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2007        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2008    };
2009
2010    let local_var_req = local_var_req_builder.build()?;
2011    let local_var_resp = local_var_client.execute(local_var_req).await?;
2012
2013    let local_var_status = local_var_resp.status();
2014    let local_var_content = local_var_resp.text().await?;
2015
2016    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2017        serde_json::from_str(&local_var_content).map_err(Error::from)
2018    } else {
2019        let local_var_entity: Option<RemoveFromPlacementGroupError> =
2020            serde_json::from_str(&local_var_content).ok();
2021        let local_var_error = ResponseContent {
2022            status: local_var_status,
2023            content: local_var_content,
2024            entity: local_var_entity,
2025        };
2026        Err(Error::ResponseError(local_var_error))
2027    }
2028}
2029
2030/// 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).
2031pub async fn replace_server(
2032    configuration: &configuration::Configuration,
2033    params: ReplaceServerParams,
2034) -> Result<models::ReplaceServerResponse, Error<ReplaceServerError>> {
2035    let local_var_configuration = configuration;
2036
2037    // unbox the parameters
2038    let id = params.id;
2039    let replace_server_request = params.replace_server_request;
2040
2041    let local_var_client = &local_var_configuration.client;
2042
2043    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2044    let local_var_uri_str = format!("{}/servers/{id}", local_base_path, id = id);
2045    let mut local_var_req_builder =
2046        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
2047
2048    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2049        local_var_req_builder =
2050            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2051    }
2052    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2053        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2054    };
2055    local_var_req_builder = local_var_req_builder.json(&replace_server_request);
2056
2057    let local_var_req = local_var_req_builder.build()?;
2058    let local_var_resp = local_var_client.execute(local_var_req).await?;
2059
2060    let local_var_status = local_var_resp.status();
2061    let local_var_content = local_var_resp.text().await?;
2062
2063    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2064        serde_json::from_str(&local_var_content).map_err(Error::from)
2065    } else {
2066        let local_var_entity: Option<ReplaceServerError> =
2067            serde_json::from_str(&local_var_content).ok();
2068        let local_var_error = ResponseContent {
2069            status: local_var_status,
2070            content: local_var_content,
2071            entity: local_var_entity,
2072        };
2073        Err(Error::ResponseError(local_var_error))
2074    }
2075}
2076
2077/// 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.
2078pub async fn request_console_for_server(
2079    configuration: &configuration::Configuration,
2080    params: RequestConsoleForServerParams,
2081) -> Result<models::RequestConsoleForServerResponse, Error<RequestConsoleForServerError>> {
2082    let local_var_configuration = configuration;
2083
2084    // unbox the parameters
2085    let id = params.id;
2086
2087    let local_var_client = &local_var_configuration.client;
2088
2089    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2090    let local_var_uri_str = format!(
2091        "{}/servers/{id}/actions/request_console",
2092        local_base_path,
2093        id = id
2094    );
2095    let mut local_var_req_builder =
2096        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2097
2098    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2099        local_var_req_builder =
2100            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2101    }
2102    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2103        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2104    };
2105
2106    let local_var_req = local_var_req_builder.build()?;
2107    let local_var_resp = local_var_client.execute(local_var_req).await?;
2108
2109    let local_var_status = local_var_resp.status();
2110    let local_var_content = local_var_resp.text().await?;
2111
2112    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2113        serde_json::from_str(&local_var_content).map_err(Error::from)
2114    } else {
2115        let local_var_entity: Option<RequestConsoleForServerError> =
2116            serde_json::from_str(&local_var_content).ok();
2117        let local_var_error = ResponseContent {
2118            status: local_var_status,
2119            content: local_var_content,
2120            entity: local_var_entity,
2121        };
2122        Err(Error::ResponseError(local_var_error))
2123    }
2124}
2125
2126/// 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.
2127pub async fn reset_root_password_of_server(
2128    configuration: &configuration::Configuration,
2129    params: ResetRootPasswordOfServerParams,
2130) -> Result<models::ResetRootPasswordOfServerResponse, Error<ResetRootPasswordOfServerError>> {
2131    let local_var_configuration = configuration;
2132
2133    // unbox the parameters
2134    let id = params.id;
2135
2136    let local_var_client = &local_var_configuration.client;
2137
2138    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2139    let local_var_uri_str = format!(
2140        "{}/servers/{id}/actions/reset_password",
2141        local_base_path,
2142        id = id
2143    );
2144    let mut local_var_req_builder =
2145        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2146
2147    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2148        local_var_req_builder =
2149            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2150    }
2151    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2152        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2153    };
2154
2155    let local_var_req = local_var_req_builder.build()?;
2156    let local_var_resp = local_var_client.execute(local_var_req).await?;
2157
2158    let local_var_status = local_var_resp.status();
2159    let local_var_content = local_var_resp.text().await?;
2160
2161    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2162        serde_json::from_str(&local_var_content).map_err(Error::from)
2163    } else {
2164        let local_var_entity: Option<ResetRootPasswordOfServerError> =
2165            serde_json::from_str(&local_var_content).ok();
2166        let local_var_error = ResponseContent {
2167            status: local_var_status,
2168            content: local_var_content,
2169            entity: local_var_entity,
2170        };
2171        Err(Error::ResponseError(local_var_error))
2172    }
2173}
2174
2175/// 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.
2176pub async fn reset_server(
2177    configuration: &configuration::Configuration,
2178    params: ResetServerParams,
2179) -> Result<models::ResetServerResponse, Error<ResetServerError>> {
2180    let local_var_configuration = configuration;
2181
2182    // unbox the parameters
2183    let id = params.id;
2184
2185    let local_var_client = &local_var_configuration.client;
2186
2187    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2188    let local_var_uri_str = format!("{}/servers/{id}/actions/reset", local_base_path, id = id);
2189    let mut local_var_req_builder =
2190        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2191
2192    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2193        local_var_req_builder =
2194            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2195    }
2196    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2197        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2198    };
2199
2200    let local_var_req = local_var_req_builder.build()?;
2201    let local_var_resp = local_var_client.execute(local_var_req).await?;
2202
2203    let local_var_status = local_var_resp.status();
2204    let local_var_content = local_var_resp.text().await?;
2205
2206    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2207        serde_json::from_str(&local_var_content).map_err(Error::from)
2208    } else {
2209        let local_var_entity: Option<ResetServerError> =
2210            serde_json::from_str(&local_var_content).ok();
2211        let local_var_error = ResponseContent {
2212            status: local_var_status,
2213            content: local_var_content,
2214            entity: local_var_entity,
2215        };
2216        Err(Error::ResponseError(local_var_error))
2217    }
2218}
2219
2220/// 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.
2221pub async fn shutdown_server(
2222    configuration: &configuration::Configuration,
2223    params: ShutdownServerParams,
2224) -> Result<models::ShutdownServerResponse, Error<ShutdownServerError>> {
2225    let local_var_configuration = configuration;
2226
2227    // unbox the parameters
2228    let id = params.id;
2229
2230    let local_var_client = &local_var_configuration.client;
2231
2232    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2233    let local_var_uri_str = format!("{}/servers/{id}/actions/shutdown", local_base_path, id = id);
2234    let mut local_var_req_builder =
2235        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2236
2237    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2238        local_var_req_builder =
2239            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2240    }
2241    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2242        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2243    };
2244
2245    let local_var_req = local_var_req_builder.build()?;
2246    let local_var_resp = local_var_client.execute(local_var_req).await?;
2247
2248    let local_var_status = local_var_resp.status();
2249    let local_var_content = local_var_resp.text().await?;
2250
2251    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2252        serde_json::from_str(&local_var_content).map_err(Error::from)
2253    } else {
2254        let local_var_entity: Option<ShutdownServerError> =
2255            serde_json::from_str(&local_var_content).ok();
2256        let local_var_error = ResponseContent {
2257            status: local_var_status,
2258            content: local_var_content,
2259            entity: local_var_entity,
2260        };
2261        Err(Error::ResponseError(local_var_error))
2262    }
2263}
2264
2265/// 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.
2266pub async fn soft_reboot_server(
2267    configuration: &configuration::Configuration,
2268    params: SoftRebootServerParams,
2269) -> Result<models::SoftRebootServerResponse, Error<SoftRebootServerError>> {
2270    let local_var_configuration = configuration;
2271
2272    // unbox the parameters
2273    let id = params.id;
2274
2275    let local_var_client = &local_var_configuration.client;
2276
2277    let local_base_path = local_var_configuration.get_base_path("https://api.hetzner.cloud/v1");
2278    let local_var_uri_str = format!("{}/servers/{id}/actions/reboot", local_base_path, id = id);
2279    let mut local_var_req_builder =
2280        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2281
2282    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
2283        local_var_req_builder =
2284            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
2285    }
2286    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
2287        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
2288    };
2289
2290    let local_var_req = local_var_req_builder.build()?;
2291    let local_var_resp = local_var_client.execute(local_var_req).await?;
2292
2293    let local_var_status = local_var_resp.status();
2294    let local_var_content = local_var_resp.text().await?;
2295
2296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2297        serde_json::from_str(&local_var_content).map_err(Error::from)
2298    } else {
2299        let local_var_entity: Option<SoftRebootServerError> =
2300            serde_json::from_str(&local_var_content).ok();
2301        let local_var_error = ResponseContent {
2302            status: local_var_status,
2303            content: local_var_content,
2304            entity: local_var_entity,
2305        };
2306        Err(Error::ResponseError(local_var_error))
2307    }
2308}