hcloud 0.25.0

Unofficial Rust crate for accessing the Hetzner Cloud API
Documentation
/*
 * Hetzner Cloud API
 *
 * Copied from the official API documentation for the Public Hetzner Cloud.
 *
 * The version of the OpenAPI document: 0.28.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// Server : Servers are virtual machines that can be provisioned.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Server {
    /// Time window (UTC) in which the backup will run, or null if the backups are not enabled.
    #[serde(rename = "backup_window", deserialize_with = "Option::deserialize")]
    pub backup_window: Option<String>,
    /// Point in time when the Resource was created (in ISO-8601 format).
    #[serde(rename = "created")]
    pub created: String,
    #[serde(rename = "datacenter")]
    pub datacenter: Box<models::DataCenter>,
    /// ID of the Server.
    #[serde(rename = "id")]
    pub id: i64,
    /// Image the server is based on.
    #[serde(rename = "image", deserialize_with = "Option::deserialize")]
    pub image: Option<Box<models::Image>>,
    /// Free Traffic for the current billing period in bytes.
    #[serde(rename = "included_traffic", deserialize_with = "Option::deserialize")]
    pub included_traffic: Option<i64>,
    /// Inbound Traffic for the current billing period in bytes.
    #[serde(rename = "ingoing_traffic", deserialize_with = "Option::deserialize")]
    pub ingoing_traffic: Option<i64>,
    /// ISO Image that is attached to this Server. Null if no ISO is attached.
    #[serde(rename = "iso", deserialize_with = "Option::deserialize")]
    pub iso: Option<Box<models::Iso>>,
    /// User-defined labels (`key/value` pairs) for the Resource. For more information, see \"Labels\".  | User-defined labels (`key/value` pairs) for the Resource.  Note that the set of Labels provided in the request will overwrite the existing one.  For more information, see \"Labels\".
    #[serde(rename = "labels")]
    pub labels: std::collections::HashMap<String, String>,
    /// Load Balancer IDs assigned to the server.
    #[serde(rename = "load_balancers", skip_serializing_if = "Option::is_none")]
    pub load_balancers: Option<Vec<i64>>,
    /// True if Server has been locked and is not available to user.
    #[serde(rename = "locked")]
    pub locked: bool,
    /// Name of the Server (must be unique per Project and a valid hostname as per RFC 1123).
    #[serde(rename = "name")]
    pub name: String,
    /// Outbound Traffic for the current billing period in bytes.
    #[serde(rename = "outgoing_traffic", deserialize_with = "Option::deserialize")]
    pub outgoing_traffic: Option<i64>,
    #[serde(
        rename = "placement_group",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub placement_group: Option<Option<Box<models::PlacementGroup>>>,
    /// Size of the primary Disk.
    #[serde(rename = "primary_disk_size")]
    pub primary_disk_size: i32,
    /// Private networks information.
    #[serde(rename = "private_net")]
    pub private_net: Vec<models::ServerPrivateNet>,
    #[serde(rename = "protection")]
    pub protection: Box<models::ServerProtection>,
    #[serde(rename = "public_net")]
    pub public_net: Box<models::ServerPublicNet>,
    /// True if rescue mode is enabled. Server will then boot into rescue system on next reboot.
    #[serde(rename = "rescue_enabled")]
    pub rescue_enabled: bool,
    #[serde(rename = "server_type")]
    pub server_type: Box<models::ServerType>,
    /// Status of the Server.
    #[serde(rename = "status")]
    pub status: Status,
    /// IDs of Volumes assigned to this Server.
    #[serde(rename = "volumes", skip_serializing_if = "Option::is_none")]
    pub volumes: Option<Vec<i64>>,
}

impl Server {
    /// Servers are virtual machines that can be provisioned.
    pub fn new(
        backup_window: Option<String>,
        created: String,
        datacenter: models::DataCenter,
        id: i64,
        image: Option<models::Image>,
        included_traffic: Option<i64>,
        ingoing_traffic: Option<i64>,
        iso: Option<models::Iso>,
        labels: std::collections::HashMap<String, String>,
        locked: bool,
        name: String,
        outgoing_traffic: Option<i64>,
        primary_disk_size: i32,
        private_net: Vec<models::ServerPrivateNet>,
        protection: models::ServerProtection,
        public_net: models::ServerPublicNet,
        rescue_enabled: bool,
        server_type: models::ServerType,
        status: Status,
    ) -> Server {
        Server {
            backup_window,
            created,
            datacenter: Box::new(datacenter),
            id,
            image: image.map(Box::new),
            included_traffic,
            ingoing_traffic,
            iso: iso.map(Box::new),
            labels,
            load_balancers: None,
            locked,
            name,
            outgoing_traffic,
            placement_group: None,
            primary_disk_size,
            private_net,
            protection: Box::new(protection),
            public_net: Box::new(public_net),
            rescue_enabled,
            server_type: Box::new(server_type),
            status,
            volumes: None,
        }
    }
}
/// Status of the Server.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "deleting")]
    Deleting,
    #[serde(rename = "initializing")]
    Initializing,
    #[serde(rename = "migrating")]
    Migrating,
    #[serde(rename = "off")]
    Off,
    #[serde(rename = "rebuilding")]
    Rebuilding,
    #[serde(rename = "running")]
    Running,
    #[serde(rename = "starting")]
    Starting,
    #[serde(rename = "stopping")]
    Stopping,
    #[serde(rename = "unknown")]
    Unknown,
}

impl Default for Status {
    fn default() -> Status {
        Self::Deleting
    }
}