use serde::{Deserialize, Serialize}; /*
                                      * Compute Engine API
                                      *
                                      * Creates and runs virtual machines on Google Cloud Platform.
                                      *
                                      * The version of the OpenAPI document: v1
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::compute_v1::models;

/// Subnetwork : Represents a Subnetwork resource. A subnetwork (also known as a subnet) is a logical partition of a Virtual Private Cloud network with one primary IP range and zero or more secondary IP ranges. For more information, read Virtual Private Cloud (VPC) Network.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Subnetwork {
    /// [Output Only] Creation timestamp in RFC3339 text format.
    #[serde(rename = "creationTimestamp", skip_serializing_if = "Option::is_none")]
    pub creation_timestamp: Option<String>,
    /// An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Whether to enable flow logging for this subnetwork. If this field is not explicitly set, it will not appear in get listings. If not set the default behavior is determined by the org policy, if there is no org policy specified, then it will default to disabled. This field isn't supported if the subnet purpose field is set to REGIONAL_MANAGED_PROXY.
    #[serde(rename = "enableFlowLogs", skip_serializing_if = "Option::is_none")]
    pub enable_flow_logs: Option<bool>,
    /// The external IPv6 address range that is owned by this subnetwork.
    #[serde(rename = "externalIpv6Prefix", skip_serializing_if = "Option::is_none")]
    pub external_ipv6_prefix: Option<String>,
    /// Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a Subnetwork. An up-to-date fingerprint must be provided in order to update the Subnetwork, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a Subnetwork.
    #[serde(rename = "fingerprint", skip_serializing_if = "Option::is_none")]
    pub fingerprint: Option<String>,
    /// [Output Only] The gateway address for default routes to reach destination addresses outside this subnetwork.
    #[serde(rename = "gatewayAddress", skip_serializing_if = "Option::is_none")]
    pub gateway_address: Option<String>,
    /// [Output Only] The unique identifier for the resource. This identifier is defined by the server.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// [Output Only] The internal IPv6 address range that is assigned to this subnetwork.
    #[serde(rename = "internalIpv6Prefix", skip_serializing_if = "Option::is_none")]
    pub internal_ipv6_prefix: Option<String>,
    /// The range of internal addresses that are owned by this subnetwork. Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or 100.64.0.0/10. Ranges must be unique and non-overlapping within a network. Only IPv4 is supported. This field is set at resource creation time. The range can be any range listed in the Valid ranges list. The range can be expanded after creation using expandIpCidrRange.
    #[serde(rename = "ipCidrRange", skip_serializing_if = "Option::is_none")]
    pub ip_cidr_range: Option<String>,
    /// The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack.
    #[serde(rename = "ipv6AccessType", skip_serializing_if = "Option::is_none")]
    pub ipv6_access_type: Option<Ipv6AccessType>,
    /// [Output Only] This field is for internal use.
    #[serde(rename = "ipv6CidrRange", skip_serializing_if = "Option::is_none")]
    pub ipv6_cidr_range: Option<String>,
    /// [Output Only] Type of the resource. Always compute#subnetwork for Subnetwork resources.
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    #[serde(rename = "logConfig", skip_serializing_if = "Option::is_none")]
    pub log_config: Option<Box<models::SubnetworkLogConfig>>,
    /// The name of the resource, provided by the client when initially creating the resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// The URL of the network to which this subnetwork belongs, provided by the client when initially creating the subnetwork. This field can be set only at resource creation time.
    #[serde(rename = "network", skip_serializing_if = "Option::is_none")]
    pub network: Option<String>,
    /// Whether the VMs in this subnet can access Google services without assigned external IP addresses. This field can be both set at resource creation time and updated using setPrivateIpGoogleAccess.
    #[serde(
        rename = "privateIpGoogleAccess",
        skip_serializing_if = "Option::is_none"
    )]
    pub private_ip_google_access: Option<bool>,
    /// This field is for internal use. This field can be both set at resource creation time and updated using patch.
    #[serde(
        rename = "privateIpv6GoogleAccess",
        skip_serializing_if = "Option::is_none"
    )]
    pub private_ipv6_google_access: Option<PrivateIpv6GoogleAccess>,
    /// The purpose of the resource. This field can be either PRIVATE, GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose for user-created subnets or subnets that are automatically created in auto mode networks. Subnets with purpose set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are user-created subnetworks that are reserved for Envoy-based load balancers. A subnet with purpose set to PRIVATE_SERVICE_CONNECT is used to publish services using Private Service Connect. If unspecified, the subnet purpose defaults to PRIVATE. The enableFlowLogs field isn't supported if the subnet purpose field is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY.
    #[serde(rename = "purpose", skip_serializing_if = "Option::is_none")]
    pub purpose: Option<Purpose>,
    /// URL of the region where the Subnetwork resides. This field can be set only at resource creation time.
    #[serde(rename = "region", skip_serializing_if = "Option::is_none")]
    pub region: Option<String>,
    /// The URL of the reserved internal range.
    #[serde(
        rename = "reservedInternalRange",
        skip_serializing_if = "Option::is_none"
    )]
    pub reserved_internal_range: Option<String>,
    /// The role of subnetwork. Currently, this field is only used when purpose is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Envoy-based load balancers in a region. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request.
    #[serde(rename = "role", skip_serializing_if = "Option::is_none")]
    pub role: Option<Role>,
    /// An array of configurations for secondary IP ranges for VM instances contained in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange of the subnetwork. The alias IPs may belong to either primary or secondary ranges. This field can be updated with a patch request.
    #[serde(rename = "secondaryIpRanges", skip_serializing_if = "Option::is_none")]
    pub secondary_ip_ranges: Option<Vec<models::SubnetworkSecondaryRange>>,
    /// [Output Only] Server-defined URL for the resource.
    #[serde(rename = "selfLink", skip_serializing_if = "Option::is_none")]
    pub self_link: Option<String>,
    /// The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch.
    #[serde(rename = "stackType", skip_serializing_if = "Option::is_none")]
    pub stack_type: Option<StackType>,
    /// [Output Only] The state of the subnetwork, which can be one of the following values: READY: Subnetwork is created and ready to use DRAINING: only applicable to subnetworks that have the purpose set to INTERNAL_HTTPS_LOAD_BALANCER and indicates that connections to the load balancer are being drained. A subnetwork that is draining cannot be used or modified until it reaches a status of READY
    #[serde(rename = "state", skip_serializing_if = "Option::is_none")]
    pub state: Option<State>,
}

impl Subnetwork {
    /// Represents a Subnetwork resource. A subnetwork (also known as a subnet) is a logical partition of a Virtual Private Cloud network with one primary IP range and zero or more secondary IP ranges. For more information, read Virtual Private Cloud (VPC) Network.
    pub fn new() -> Subnetwork {
        Subnetwork {
            creation_timestamp: None,
            description: None,
            enable_flow_logs: None,
            external_ipv6_prefix: None,
            fingerprint: None,
            gateway_address: None,
            id: None,
            internal_ipv6_prefix: None,
            ip_cidr_range: None,
            ipv6_access_type: None,
            ipv6_cidr_range: None,
            kind: None,
            log_config: None,
            name: None,
            network: None,
            private_ip_google_access: None,
            private_ipv6_google_access: None,
            purpose: None,
            region: None,
            reserved_internal_range: None,
            role: None,
            secondary_ip_ranges: None,
            self_link: None,
            stack_type: None,
            state: None,
        }
    }
}
/// The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation or the first time the subnet is updated into IPV4_IPV6 dual stack.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Ipv6AccessType {
    #[serde(rename = "EXTERNAL")]
    External,
    #[serde(rename = "INTERNAL")]
    Internal,
}

impl Default for Ipv6AccessType {
    fn default() -> Ipv6AccessType {
        Self::External
    }
}
/// This field is for internal use. This field can be both set at resource creation time and updated using patch.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum PrivateIpv6GoogleAccess {
    #[serde(rename = "DISABLE_GOOGLE_ACCESS")]
    DisableGoogleAccess,
    #[serde(rename = "ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE")]
    EnableBidirectionalAccessToGoogle,
    #[serde(rename = "ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE")]
    EnableOutboundVmAccessToGoogle,
}

impl Default for PrivateIpv6GoogleAccess {
    fn default() -> PrivateIpv6GoogleAccess {
        Self::DisableGoogleAccess
    }
}
/// The purpose of the resource. This field can be either PRIVATE, GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose for user-created subnets or subnets that are automatically created in auto mode networks. Subnets with purpose set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are user-created subnetworks that are reserved for Envoy-based load balancers. A subnet with purpose set to PRIVATE_SERVICE_CONNECT is used to publish services using Private Service Connect. If unspecified, the subnet purpose defaults to PRIVATE. The enableFlowLogs field isn't supported if the subnet purpose field is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Purpose {
    #[serde(rename = "GLOBAL_MANAGED_PROXY")]
    GlobalManagedProxy,
    #[serde(rename = "INTERNAL_HTTPS_LOAD_BALANCER")]
    InternalHttpsLoadBalancer,
    #[serde(rename = "PRIVATE")]
    Private,
    #[serde(rename = "PRIVATE_NAT")]
    PrivateNat,
    #[serde(rename = "PRIVATE_RFC_1918")]
    PrivateRfc1918,
    #[serde(rename = "PRIVATE_SERVICE_CONNECT")]
    PrivateServiceConnect,
    #[serde(rename = "REGIONAL_MANAGED_PROXY")]
    RegionalManagedProxy,
}

impl Default for Purpose {
    fn default() -> Purpose {
        Self::GlobalManagedProxy
    }
}
/// The role of subnetwork. Currently, this field is only used when purpose is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. The value can be set to ACTIVE or BACKUP. An ACTIVE subnetwork is one that is currently being used for Envoy-based load balancers in a region. A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining. This field can be updated with a patch request.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "ACTIVE")]
    Active,
    #[serde(rename = "BACKUP")]
    Backup,
}

impl Default for Role {
    fn default() -> Role {
        Self::Active
    }
}
/// The stack type for the subnet. If set to IPV4_ONLY, new VMs in the subnet are assigned IPv4 addresses only. If set to IPV4_IPV6, new VMs in the subnet can be assigned both IPv4 and IPv6 addresses. If not specified, IPV4_ONLY is used. This field can be both set at resource creation time and updated using patch.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum StackType {
    #[serde(rename = "IPV4_IPV6")]
    Ipv6,
    #[serde(rename = "IPV4_ONLY")]
    Only,
}

impl Default for StackType {
    fn default() -> StackType {
        Self::Ipv6
    }
}
/// [Output Only] The state of the subnetwork, which can be one of the following values: READY: Subnetwork is created and ready to use DRAINING: only applicable to subnetworks that have the purpose set to INTERNAL_HTTPS_LOAD_BALANCER and indicates that connections to the load balancer are being drained. A subnetwork that is draining cannot be used or modified until it reaches a status of READY
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum State {
    #[serde(rename = "DRAINING")]
    Draining,
    #[serde(rename = "READY")]
    Ready,
}

impl Default for State {
    fn default() -> State {
        Self::Draining
    }
}
