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 StorageBox {
    #[serde(rename = "access_settings")]
    pub access_settings: Box<models::StorageBoxAccessSetting>,
    /// Point in time when the Resource was created (in ISO-8601 format).
    #[serde(rename = "created")]
    pub created: String,
    /// ID of the Storage Box.
    #[serde(rename = "id")]
    pub id: i64,
    /// 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>,
    #[serde(rename = "location")]
    pub location: Box<models::Location>,
    /// Name of the Storage Box.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "protection")]
    pub protection: Box<models::Protection>,
    /// FQDN of the Storage Box.  Not available if the `status` is `initializing`.
    #[serde(rename = "server", deserialize_with = "Option::deserialize")]
    pub server: Option<String>,
    /// Details of the active snapshot plan.  Not available if the `status` is `initializing`.
    #[serde(rename = "snapshot_plan", deserialize_with = "Option::deserialize")]
    pub snapshot_plan: Option<Box<models::SnapshotPlan>>,
    #[serde(rename = "stats")]
    pub stats: Box<models::StorageBoxStats>,
    /// Status of the Storage Box.
    #[serde(rename = "status")]
    pub status: Status,
    #[serde(rename = "storage_box_type")]
    pub storage_box_type: Box<models::StorageBoxType>,
    /// Host system of the Storage Box.  Not available if the `status` is `initializing`.
    #[serde(rename = "system", deserialize_with = "Option::deserialize")]
    pub system: Option<String>,
    /// Primary username of the Storage Box.  Not available if the `status` is `initializing`.
    #[serde(rename = "username", deserialize_with = "Option::deserialize")]
    pub username: Option<String>,
}

impl StorageBox {
    pub fn new(
        access_settings: models::StorageBoxAccessSetting,
        created: String,
        id: i64,
        labels: std::collections::HashMap<String, String>,
        location: models::Location,
        name: String,
        protection: models::Protection,
        server: Option<String>,
        snapshot_plan: Option<models::SnapshotPlan>,
        stats: models::StorageBoxStats,
        status: Status,
        storage_box_type: models::StorageBoxType,
        system: Option<String>,
        username: Option<String>,
    ) -> StorageBox {
        StorageBox {
            access_settings: Box::new(access_settings),
            created,
            id,
            labels,
            location: Box::new(location),
            name,
            protection: Box::new(protection),
            server,
            snapshot_plan: snapshot_plan.map(Box::new),
            stats: Box::new(stats),
            status,
            storage_box_type: Box::new(storage_box_type),
            system,
            username,
        }
    }
}
/// Status of the Storage Box.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "active")]
    Active,
    #[serde(rename = "initializing")]
    Initializing,
    #[serde(rename = "locked")]
    Locked,
}

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