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

/// Firewall : Firewalls can limit the network access to or from your resources.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Firewall {
    #[serde(rename = "applied_to")]
    pub applied_to: Vec<models::FirewallResourceId>,
    /// 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,
    /// ID of the Firewall.
    #[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", skip_serializing_if = "Option::is_none")]
    pub labels: Option<std::collections::HashMap<String, String>>,
    /// Name of the Firewall.  Limited to a maximum of 128 characters.  Must be unique per Project.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "rules")]
    pub rules: Vec<models::RuleResponse>,
}

impl Firewall {
    /// Firewalls can limit the network access to or from your resources.
    pub fn new(
        applied_to: Vec<models::FirewallResourceId>,
        created: String,
        id: i64,
        name: String,
        rules: Vec<models::RuleResponse>,
    ) -> Firewall {
        Firewall {
            applied_to,
            created,
            id,
            labels: None,
            name,
            rules,
        }
    }
}
