/*
* Hetzner Cloud API
*
* Copied from the official API documentation for the Public Hetzner Cloud.
*
* The version of the OpenAPI document: 0.12.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use super::{configuration, Error};
use crate::apis::ResponseContent;
/// struct for passing parameters to the method [`add_server_to_placement_group`]
#[derive(Clone, Debug, Default)]
pub struct AddServerToPlacementGroupParams {
/// ID of the Server
pub id: i32,
pub add_server_to_placement_group_request:
Option<crate::models::AddServerToPlacementGroupRequest>,
}
/// struct for passing parameters to the method [`attach_iso_to_server`]
#[derive(Clone, Debug, Default)]
pub struct AttachIsoToServerParams {
/// ID of the Server
pub id: i32,
pub attach_iso_to_server_request: Option<crate::models::AttachIsoToServerRequest>,
}
/// struct for passing parameters to the method [`attach_server_to_network`]
#[derive(Clone, Debug, Default)]
pub struct AttachServerToNetworkParams {
/// ID of the Server
pub id: i32,
pub attach_server_to_network_request: Option<crate::models::AttachServerToNetworkRequest>,
}
/// struct for passing parameters to the method [`change_alias_ips_of_network`]
#[derive(Clone, Debug, Default)]
pub struct ChangeAliasIpsOfNetworkParams {
/// ID of the Server
pub id: i32,
pub change_alias_ips_of_network_request: Option<crate::models::ChangeAliasIpsOfNetworkRequest>,
}
/// struct for passing parameters to the method [`change_reverse_dns_entry_for_this_server`]
#[derive(Clone, Debug, Default)]
pub struct ChangeReverseDnsEntryForThisServerParams {
/// ID of the Server
pub id: i32,
/// 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`.
pub change_reverse_dns_entry_for_this_server_request:
Option<crate::models::ChangeReverseDnsEntryForThisServerRequest>,
}
/// struct for passing parameters to the method [`change_server_protection`]
#[derive(Clone, Debug, Default)]
pub struct ChangeServerProtectionParams {
/// ID of the Server
pub id: i32,
pub change_server_protection_request: Option<crate::models::ChangeServerProtectionRequest>,
}
/// struct for passing parameters to the method [`change_type_of_server`]
#[derive(Clone, Debug, Default)]
pub struct ChangeTypeOfServerParams {
/// ID of the Server
pub id: i32,
pub change_type_of_server_request: Option<crate::models::ChangeTypeOfServerRequest>,
}
/// struct for passing parameters to the method [`create_image_from_server`]
#[derive(Clone, Debug, Default)]
pub struct CreateImageFromServerParams {
/// ID of the Server
pub id: i32,
pub create_image_from_server_request: Option<crate::models::CreateImageFromServerRequest>,
}
/// struct for passing parameters to the method [`create_server`]
#[derive(Clone, Debug, Default)]
pub struct CreateServerParams {
/// 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 directly specifying the Datacenter is discouraged since supply availability in Datacenters varies greatly and Datacenters may be out of stock for extended periods of time or not serve certain Server types at all. 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 |
pub create_server_request: Option<crate::models::CreateServerRequest>,
}
/// struct for passing parameters to the method [`delete_server`]
#[derive(Clone, Debug, Default)]
pub struct DeleteServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`detach_iso_from_server`]
#[derive(Clone, Debug, Default)]
pub struct DetachIsoFromServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`detach_server_from_network`]
#[derive(Clone, Debug, Default)]
pub struct DetachServerFromNetworkParams {
/// ID of the Server
pub id: i32,
pub detach_server_from_network_request: Option<crate::models::DetachServerFromNetworkRequest>,
}
/// struct for passing parameters to the method [`disable_backups_for_server`]
#[derive(Clone, Debug, Default)]
pub struct DisableBackupsForServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`disable_rescue_mode_for_server`]
#[derive(Clone, Debug, Default)]
pub struct DisableRescueModeForServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`enable_and_configure_backups_for_server`]
#[derive(Clone, Debug, Default)]
pub struct EnableAndConfigureBackupsForServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`enable_rescue_mode_for_server`]
#[derive(Clone, Debug, Default)]
pub struct EnableRescueModeForServerParams {
/// ID of the Server
pub id: i32,
pub enable_rescue_mode_for_server_request:
Option<crate::models::EnableRescueModeForServerRequest>,
}
/// struct for passing parameters to the method [`get_action_for_server`]
#[derive(Clone, Debug, Default)]
pub struct GetActionForServerParams {
/// ID of the Server
pub id: i32,
/// ID of the Action
pub action_id: i32,
}
/// struct for passing parameters to the method [`get_metrics_for_server`]
#[derive(Clone, Debug, Default)]
pub struct GetMetricsForServerParams {
/// ID of the Server
pub id: i32,
/// Type of metrics to get
pub r#type: String,
/// Start of period to get Metrics for (in ISO-8601 format)
pub start: String,
/// End of period to get Metrics for (in ISO-8601 format)
pub end: String,
/// Resolution of results in seconds
pub step: Option<String>,
}
/// struct for passing parameters to the method [`get_server`]
#[derive(Clone, Debug, Default)]
pub struct GetServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`list_actions_for_server`]
#[derive(Clone, Debug, Default)]
pub struct ListActionsForServerParams {
/// ID of the Resource
pub id: i32,
/// Can be used multiple times.
pub sort: Option<String>,
/// Can be used multiple times, the response will contain only Actions with specified statuses
pub status: Option<String>,
/// Specifies the page to fetch. The number of the first page is 1
pub page: Option<i32>,
/// Specifies the number of items returned per page. The default value is 25, the maximum value is 50 except otherwise specified in the documentation.
pub per_page: Option<i32>,
}
/// struct for passing parameters to the method [`list_servers`]
#[derive(Clone, Debug, Default)]
pub struct ListServersParams {
/// Can be used to filter resources by their name. The response will only contain the resources matching the specified name
pub name: Option<String>,
/// Can be used to filter resources by labels. The response will only contain resources matching the label selector.
pub label_selector: Option<String>,
/// Can be used multiple times.
pub sort: Option<String>,
/// Can be used multiple times. The response will only contain Server matching the status
pub status: Option<String>,
/// Specifies the page to fetch. The number of the first page is 1
pub page: Option<i32>,
/// Specifies the number of items returned per page. The default value is 25, the maximum value is 50 except otherwise specified in the documentation.
pub per_page: Option<i32>,
}
/// struct for passing parameters to the method [`power_off_server`]
#[derive(Clone, Debug, Default)]
pub struct PowerOffServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`power_on_server`]
#[derive(Clone, Debug, Default)]
pub struct PowerOnServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`rebuild_server_from_image`]
#[derive(Clone, Debug, Default)]
pub struct RebuildServerFromImageParams {
/// ID of the Server
pub id: i32,
/// 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.
pub rebuild_server_from_image_request: Option<crate::models::RebuildServerFromImageRequest>,
}
/// struct for passing parameters to the method [`remove_from_placement_group`]
#[derive(Clone, Debug, Default)]
pub struct RemoveFromPlacementGroupParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`replace_server`]
#[derive(Clone, Debug, Default)]
pub struct ReplaceServerParams {
/// ID of the Server
pub id: i32,
pub replace_server_request: Option<crate::models::ReplaceServerRequest>,
}
/// struct for passing parameters to the method [`request_console_for_server`]
#[derive(Clone, Debug, Default)]
pub struct RequestConsoleForServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`reset_root_password_of_server`]
#[derive(Clone, Debug, Default)]
pub struct ResetRootPasswordOfServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`reset_server`]
#[derive(Clone, Debug, Default)]
pub struct ResetServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`shutdown_server`]
#[derive(Clone, Debug, Default)]
pub struct ShutdownServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for passing parameters to the method [`soft_reboot_server`]
#[derive(Clone, Debug, Default)]
pub struct SoftRebootServerParams {
/// ID of the Server
pub id: i32,
}
/// struct for typed errors of method [`add_server_to_placement_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddServerToPlacementGroupError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`attach_iso_to_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachIsoToServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`attach_server_to_network`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachServerToNetworkError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_alias_ips_of_network`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeAliasIpsOfNetworkError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_reverse_dns_entry_for_this_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeReverseDnsEntryForThisServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_server_protection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeServerProtectionError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_type_of_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeTypeOfServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_image_from_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateImageFromServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`detach_iso_from_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DetachIsoFromServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`detach_server_from_network`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DetachServerFromNetworkError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`disable_backups_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DisableBackupsForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`disable_rescue_mode_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DisableRescueModeForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`enable_and_configure_backups_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EnableAndConfigureBackupsForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`enable_rescue_mode_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EnableRescueModeForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_action_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetActionForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_metrics_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMetricsForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_actions_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListActionsForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_servers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListServersError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`power_off_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PowerOffServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`power_on_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PowerOnServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`rebuild_server_from_image`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RebuildServerFromImageError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_from_placement_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveFromPlacementGroupError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`request_console_for_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RequestConsoleForServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reset_root_password_of_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResetRootPasswordOfServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reset_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResetServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`shutdown_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ShutdownServerError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`soft_reboot_server`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SoftRebootServerError {
UnknownValue(serde_json::Value),
}
/// 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 |
pub async fn add_server_to_placement_group(
configuration: &configuration::Configuration,
params: AddServerToPlacementGroupParams,
) -> Result<crate::models::AddServerToPlacementGroupResponse, Error<AddServerToPlacementGroupError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let add_server_to_placement_group_request = params.add_server_to_placement_group_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/add_to_placement_group",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&add_server_to_placement_group_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AddServerToPlacementGroupError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn attach_iso_to_server(
configuration: &configuration::Configuration,
params: AttachIsoToServerParams,
) -> Result<crate::models::AttachIsoToServerResponse, Error<AttachIsoToServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let attach_iso_to_server_request = params.attach_iso_to_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/attach_iso",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&attach_iso_to_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AttachIsoToServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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 |
pub async fn attach_server_to_network(
configuration: &configuration::Configuration,
params: AttachServerToNetworkParams,
) -> Result<crate::models::AttachServerToNetworkResponse, Error<AttachServerToNetworkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let attach_server_to_network_request = params.attach_server_to_network_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/attach_to_network",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&attach_server_to_network_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AttachServerToNetworkError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn change_alias_ips_of_network(
configuration: &configuration::Configuration,
params: ChangeAliasIpsOfNetworkParams,
) -> Result<crate::models::ChangeAliasIpsOfNetworkResponse, Error<ChangeAliasIpsOfNetworkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let change_alias_ips_of_network_request = params.change_alias_ips_of_network_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/change_alias_ips",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&change_alias_ips_of_network_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ChangeAliasIpsOfNetworkError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn change_reverse_dns_entry_for_this_server(
configuration: &configuration::Configuration,
params: ChangeReverseDnsEntryForThisServerParams,
) -> Result<
crate::models::ChangeReverseDnsEntryForThisServerResponse,
Error<ChangeReverseDnsEntryForThisServerError>,
> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let change_reverse_dns_entry_for_this_server_request =
params.change_reverse_dns_entry_for_this_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/change_dns_ptr",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder =
local_var_req_builder.json(&change_reverse_dns_entry_for_this_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ChangeReverseDnsEntryForThisServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Changes the protection configuration of the Server.
pub async fn change_server_protection(
configuration: &configuration::Configuration,
params: ChangeServerProtectionParams,
) -> Result<crate::models::ChangeServerProtectionResponse, Error<ChangeServerProtectionError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let change_server_protection_request = params.change_server_protection_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/change_protection",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&change_server_protection_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ChangeServerProtectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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 |
pub async fn change_type_of_server(
configuration: &configuration::Configuration,
params: ChangeTypeOfServerParams,
) -> Result<crate::models::ChangeTypeOfServerResponse, Error<ChangeTypeOfServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let change_type_of_server_request = params.change_type_of_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/change_type",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&change_type_of_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ChangeTypeOfServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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 an `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.
pub async fn create_image_from_server(
configuration: &configuration::Configuration,
params: CreateImageFromServerParams,
) -> Result<crate::models::CreateImageFromServerResponse, Error<CreateImageFromServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let create_image_from_server_request = params.create_image_from_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/create_image",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&create_image_from_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateImageFromServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.
pub async fn create_server(
configuration: &configuration::Configuration,
params: CreateServerParams,
) -> Result<crate::models::CreateServerResponse, Error<CreateServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let create_server_request = params.create_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/servers", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&create_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Deletes a Server. This immediately removes the Server from your account, and it is no longer accessible.
pub async fn delete_server(
configuration: &configuration::Configuration,
params: DeleteServerParams,
) -> Result<crate::models::DeleteServerResponse, Error<DeleteServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DeleteServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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`
pub async fn detach_iso_from_server(
configuration: &configuration::Configuration,
params: DetachIsoFromServerParams,
) -> Result<crate::models::DetachIsoFromServerResponse, Error<DetachIsoFromServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/detach_iso",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DetachIsoFromServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Detaches a Server from a network. The interface for this network will vanish.
pub async fn detach_server_from_network(
configuration: &configuration::Configuration,
params: DetachServerFromNetworkParams,
) -> Result<crate::models::DetachServerFromNetworkResponse, Error<DetachServerFromNetworkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let detach_server_from_network_request = params.detach_server_from_network_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/detach_from_network",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&detach_server_from_network_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DetachServerFromNetworkError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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!
pub async fn disable_backups_for_server(
configuration: &configuration::Configuration,
params: DisableBackupsForServerParams,
) -> Result<crate::models::DisableBackupsForServerResponse, Error<DisableBackupsForServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/disable_backup",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DisableBackupsForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn disable_rescue_mode_for_server(
configuration: &configuration::Configuration,
params: DisableRescueModeForServerParams,
) -> Result<crate::models::DisableRescueModeForServerResponse, Error<DisableRescueModeForServerError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/disable_rescue",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DisableRescueModeForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn enable_and_configure_backups_for_server(
configuration: &configuration::Configuration,
params: EnableAndConfigureBackupsForServerParams,
) -> Result<
crate::models::EnableAndConfigureBackupsForServerResponse,
Error<EnableAndConfigureBackupsForServerError>,
> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/enable_backup",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<EnableAndConfigureBackupsForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn enable_rescue_mode_for_server(
configuration: &configuration::Configuration,
params: EnableRescueModeForServerParams,
) -> Result<crate::models::EnableRescueModeForServerResponse, Error<EnableRescueModeForServerError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let enable_rescue_mode_for_server_request = params.enable_rescue_mode_for_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/enable_rescue",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&enable_rescue_mode_for_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<EnableRescueModeForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a specific Action object for a Server.
pub async fn get_action_for_server(
configuration: &configuration::Configuration,
params: GetActionForServerParams,
) -> Result<crate::models::GetActionForServerResponse, Error<GetActionForServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let action_id = params.action_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/{action_id}",
local_var_configuration.base_path,
id = id,
action_id = action_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetActionForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_metrics_for_server(
configuration: &configuration::Configuration,
params: GetMetricsForServerParams,
) -> Result<crate::models::GetMetricsForServerResponse, Error<GetMetricsForServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let r#type = params.r#type;
let start = params.start;
let end = params.end;
let step = params.step;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/metrics",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("type", &r#type.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = step {
local_var_req_builder =
local_var_req_builder.query(&[("step", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetMetricsForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a specific Server object. The Server must exist inside the Project
pub async fn get_server(
configuration: &configuration::Configuration,
params: GetServerParams,
) -> Result<crate::models::GetServerResponse, Error<GetServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn list_actions_for_server(
configuration: &configuration::Configuration,
params: ListActionsForServerParams,
) -> Result<crate::models::ListActionsForServerResponse, Error<ListActionsForServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let sort = params.sort;
let status = params.status;
let page = params.page;
let per_page = params.per_page;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = sort {
local_var_req_builder =
local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = status {
local_var_req_builder =
local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder =
local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListActionsForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Returns all existing Server objects
pub async fn list_servers(
configuration: &configuration::Configuration,
params: ListServersParams,
) -> Result<crate::models::ListServersResponse, Error<ListServersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let name = params.name;
let label_selector = params.label_selector;
let sort = params.sort;
let status = params.status;
let page = params.page;
let per_page = params.per_page;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/servers", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = name {
local_var_req_builder =
local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = label_selector {
local_var_req_builder =
local_var_req_builder.query(&[("label_selector", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder =
local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = status {
local_var_req_builder =
local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder =
local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListServersError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn power_off_server(
configuration: &configuration::Configuration,
params: PowerOffServerParams,
) -> Result<crate::models::PowerOffServerResponse, Error<PowerOffServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/poweroff",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<PowerOffServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Starts a Server by turning its power on.
pub async fn power_on_server(
configuration: &configuration::Configuration,
params: PowerOnServerParams,
) -> Result<crate::models::PowerOnServerResponse, Error<PowerOnServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/poweron",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<PowerOnServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn rebuild_server_from_image(
configuration: &configuration::Configuration,
params: RebuildServerFromImageParams,
) -> Result<crate::models::RebuildServerFromImageResponse, Error<RebuildServerFromImageError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let rebuild_server_from_image_request = params.rebuild_server_from_image_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/rebuild",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&rebuild_server_from_image_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RebuildServerFromImageError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// Removes a Server from a Placement Group.
pub async fn remove_from_placement_group(
configuration: &configuration::Configuration,
params: RemoveFromPlacementGroupParams,
) -> Result<crate::models::RemoveFromPlacementGroupResponse, Error<RemoveFromPlacementGroupError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/remove_from_placement_group",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RemoveFromPlacementGroupError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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). Also note that when updating labels, the Server’s current set of labels will be replaced with the labels provided in the request body. So, for example, if you want to add a new label, you have to provide all existing labels plus the new label in the request body.
pub async fn replace_server(
configuration: &configuration::Configuration,
params: ReplaceServerParams,
) -> Result<crate::models::ReplaceServerResponse, Error<ReplaceServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let replace_server_request = params.replace_server_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&replace_server_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ReplaceServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn request_console_for_server(
configuration: &configuration::Configuration,
params: RequestConsoleForServerParams,
) -> Result<crate::models::RequestConsoleForServerResponse, Error<RequestConsoleForServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/request_console",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RequestConsoleForServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn reset_root_password_of_server(
configuration: &configuration::Configuration,
params: ResetRootPasswordOfServerParams,
) -> Result<crate::models::ResetRootPasswordOfServerResponse, Error<ResetRootPasswordOfServerError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/reset_password",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ResetRootPasswordOfServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn reset_server(
configuration: &configuration::Configuration,
params: ResetServerParams,
) -> Result<crate::models::ResetServerResponse, Error<ResetServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/reset",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ResetServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn shutdown_server(
configuration: &configuration::Configuration,
params: ShutdownServerParams,
) -> Result<crate::models::ShutdownServerResponse, Error<ShutdownServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/shutdown",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ShutdownServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn soft_reboot_server(
configuration: &configuration::Configuration,
params: SoftRebootServerParams,
) -> Result<crate::models::SoftRebootServerResponse, Error<SoftRebootServerError>> {
let local_var_configuration = configuration;
// unbox the parameters
let id = params.id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/servers/{id}/actions/reboot",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SoftRebootServerError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}