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};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ServerType {
    #[serde(rename = "architecture")]
    pub architecture: models::Architecture,
    /// Category of Server Type.
    #[serde(rename = "category", skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Number of cpu cores a Server of this type will have.
    #[serde(rename = "cores")]
    pub cores: i32,
    /// Type of cpu.
    #[serde(rename = "cpu_type")]
    pub cpu_type: CpuType,
    /// This field is deprecated. Use the deprecation object instead.
    #[serde(rename = "deprecated", deserialize_with = "Option::deserialize")]
    pub deprecated: Option<bool>,
    /// This field is deprecated.  Use the `deprecation` object in the `locations` field instead (`.locations[].deprecation`).
    #[serde(
        rename = "deprecation",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub deprecation: Option<Option<Box<models::DeprecationInfo>>>,
    /// Description of the Server type.
    #[serde(rename = "description")]
    pub description: String,
    /// Disk size a Server of this type will have in GB.
    #[serde(rename = "disk")]
    pub disk: f64,
    /// ID of the Server type.
    #[serde(rename = "id")]
    pub id: i64,
    /// Supported Location and per Location details for the Server Type.  A Server Type is:  - only supported in the Location that are listed.  - deprecated in the Location when the `deprecation` property is set.  - unavailable in the Location when the `deprecation.unavailable_after` date is in the past.
    #[serde(rename = "locations")]
    pub locations: Vec<models::ServerTypeLocation>,
    /// Memory a Server of this type will have in GB.
    #[serde(rename = "memory")]
    pub memory: f64,
    /// Unique identifier of the Server type.
    #[serde(rename = "name")]
    pub name: String,
    /// Price per Location.
    #[serde(rename = "prices")]
    pub prices: Vec<models::PricePerTime>,
    /// Type of Server boot drive. Local has higher speed. Network has better availability.
    #[serde(rename = "storage_type")]
    pub storage_type: StorageType,
}

impl ServerType {
    pub fn new(
        architecture: models::Architecture,
        cores: i32,
        cpu_type: CpuType,
        deprecated: Option<bool>,
        description: String,
        disk: f64,
        id: i64,
        locations: Vec<models::ServerTypeLocation>,
        memory: f64,
        name: String,
        prices: Vec<models::PricePerTime>,
        storage_type: StorageType,
    ) -> ServerType {
        ServerType {
            architecture,
            category: None,
            cores,
            cpu_type,
            deprecated,
            deprecation: None,
            description,
            disk,
            id,
            locations,
            memory,
            name,
            prices,
            storage_type,
        }
    }
}
/// Type of cpu.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CpuType {
    #[serde(rename = "dedicated")]
    Dedicated,
    #[serde(rename = "shared")]
    Shared,
}

impl Default for CpuType {
    fn default() -> CpuType {
        Self::Dedicated
    }
}
/// Type of Server boot drive. Local has higher speed. Network has better availability.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum StorageType {
    #[serde(rename = "local")]
    Local,
    #[serde(rename = "network")]
    Network,
}

impl Default for StorageType {
    fn default() -> StorageType {
        Self::Local
    }
}