/*
 * 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 PrimaryIp {
    /// ID of resource the Primary IP is assigned to.  `null` if the Primary IP is not assigned.
    #[serde(rename = "assignee_id", deserialize_with = "Option::deserialize")]
    pub assignee_id: Option<i64>,
    /// Type of resource the Primary IP can get assigned to.
    #[serde(rename = "assignee_type")]
    pub assignee_type: AssigneeType,
    /// Auto deletion state.  If enabled the Primary IP will be deleted once the assigned resource gets deleted.
    #[serde(rename = "auto_delete")]
    pub auto_delete: bool,
    /// Blocked state of the Primary IP.
    #[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,
    /// List of reverse DNS records.
    #[serde(rename = "dns_ptr")]
    pub dns_ptr: Vec<models::DnsPtr>,
    /// ID of the Primary 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>,
    #[serde(rename = "location")]
    pub location: Box<models::Location>,
    /// Name of the Resource. Must be unique per Project.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "protection")]
    pub protection: Box<models::Protection>,
    #[serde(rename = "type")]
    pub r#type: models::IpType,
}

impl PrimaryIp {
    pub fn new(
        assignee_id: Option<i64>,
        assignee_type: AssigneeType,
        auto_delete: bool,
        blocked: bool,
        created: String,
        dns_ptr: Vec<models::DnsPtr>,
        id: i64,
        ip: String,
        labels: std::collections::HashMap<String, String>,
        location: models::Location,
        name: String,
        protection: models::Protection,
        r#type: models::IpType,
    ) -> PrimaryIp {
        PrimaryIp {
            assignee_id,
            assignee_type,
            auto_delete,
            blocked,
            created,
            dns_ptr,
            id,
            ip,
            labels,
            location: Box::new(location),
            name,
            protection: Box::new(protection),
            r#type,
        }
    }
}
/// Type of resource the Primary IP can get assigned to.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum AssigneeType {
    #[serde(rename = "server")]
    Server,
}

impl Default for AssigneeType {
    fn default() -> AssigneeType {
        Self::Server
    }
}
