/*
 * Hetzner Cloud API
 *
 * Copied from the official API documentation for the Public Hetzner Cloud.
 *
 * The version of the OpenAPI document: 4b3f595
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FloatingIp {
    /// Indicates whether the Floating IP is blocked.
    #[serde(rename = "blocked")]
    pub blocked: bool,
    /// Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format).
    #[serde(rename = "created")]
    pub created: String,
    /// Description of the Resource.
    #[serde(rename = "description", deserialize_with = "Option::deserialize")]
    pub description: Option<String>,
    /// List of reverse DNS entries for the Floating IP.
    #[serde(rename = "dns_ptr")]
    pub dns_ptr: Vec<models::DnsPtr>,
    #[serde(rename = "home_location")]
    pub home_location: Box<models::Location>,
    /// ID of the Floating IP.
    #[serde(rename = "id")]
    pub id: i64,
    /// IP address.
    #[serde(rename = "ip")]
    pub ip: String,
    /// 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>,
    /// Name of the Resource. Must be unique per Project.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "protection")]
    pub protection: Box<models::Protection>,
    /// Server the Floating IP is assigned to.  `null` if not assigned.
    #[serde(rename = "server", deserialize_with = "Option::deserialize")]
    pub server: Option<i64>,
    #[serde(rename = "type")]
    pub r#type: models::IpType,
}

impl FloatingIp {
    pub fn new(
        blocked: bool,
        created: String,
        description: Option<String>,
        dns_ptr: Vec<models::DnsPtr>,
        home_location: models::Location,
        id: i64,
        ip: String,
        labels: std::collections::HashMap<String, String>,
        name: String,
        protection: models::Protection,
        server: Option<i64>,
        r#type: models::IpType,
    ) -> FloatingIp {
        FloatingIp {
            blocked,
            created,
            description,
            dns_ptr,
            home_location: Box::new(home_location),
            id,
            ip,
            labels,
            name,
            protection: Box::new(protection),
            server,
            r#type,
        }
    }
}
