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

/// CreateZoneRequest : Request for POST https://api.hetzner.cloud/v1/zones
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateZoneRequest {
    /// 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", skip_serializing_if = "Option::is_none")]
    pub labels: Option<std::collections::HashMap<String, String>>,
    /// Mode of the Zone.  For more information, see Zone Modes.
    #[serde(rename = "mode")]
    pub mode: Mode,
    /// Name of the Zone.  All names with [well-known public suffixes](https://publicsuffix.org/) (e.g. `.de`, `.com`, `.co.uk`) are supported. Subdomains are not supported.  The name must be in lower case and must not end with a dot. [Internationalized domain names](https://en.wikipedia.org/wiki/Internationalized_domain_name) must be transcribed to [Punycode](https://wikipedia.org/wiki/Punycode) representation with ACE prefix, e.g. `xn--mnchen-3ya.de` (`münchen.de`).
    #[serde(rename = "name")]
    pub name: String,
    /// Primary nameservers of the Zone.  Only applicable for Zones in secondary mode. Ignored for Zones in primary mode.
    #[serde(
        rename = "primary_nameservers",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_nameservers: Option<Vec<models::Nameserver>>,
    /// RRSets to be added to the Zone.  Only applicable for Zones in primary mode. Ignored for Zones in secondary mode.
    #[serde(rename = "rrsets", skip_serializing_if = "Option::is_none")]
    pub rrsets: Option<Vec<models::ResourceRecordSetToCreate>>,
    /// Default Time To Live (TTL) of the Zone.  Must be in between 60s and 2147483647s.  This TTL is used for RRSets that do not explicitly define a TTL.
    #[serde(rename = "ttl", skip_serializing_if = "Option::is_none")]
    pub ttl: Option<i32>,
    /// Zone file to import.  Only applicable for Zones in primary mode. Ignored for Zones in secondary mode.  If provided, `rrsets` must be empty.  See Zone file import for more details.
    #[serde(rename = "zonefile", skip_serializing_if = "Option::is_none")]
    pub zonefile: Option<String>,
}

impl CreateZoneRequest {
    /// Request for POST https://api.hetzner.cloud/v1/zones
    pub fn new(mode: Mode, name: String) -> CreateZoneRequest {
        CreateZoneRequest {
            labels: None,
            mode,
            name,
            primary_nameservers: None,
            rrsets: None,
            ttl: None,
            zonefile: None,
        }
    }
}
/// Mode of the Zone.  For more information, see Zone Modes.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Mode {
    #[serde(rename = "primary")]
    Primary,
    #[serde(rename = "secondary")]
    Secondary,
}

impl Default for Mode {
    fn default() -> Mode {
        Self::Primary
    }
}
