# coding: utf-8


"""
IGNORE:
    Nutanix Flow Management APIs

    Manage Network Security Policy configuration of Nutanix clusters.  # noqa: E501

    OpenAPI spec version: 4.2.1
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
IGNORE
"""
import pprint
import json
import ast
import re  # noqa: F401

import six
from pathlib import Path
from ntnx_microseg_py_client.models.common.v1.config.IPv4Address import IPv4Address  # noqa: F401,E501
from ntnx_microseg_py_client.models.common.v1.config.IPv6Address import IPv6Address  # noqa: F401,E501
from ntnx_microseg_py_client.models.common.v1.response.ApiLink import ApiLink  # noqa: F401,E501
from ntnx_microseg_py_client.models.common.v1.response.ExternalizableAbstractModel import ExternalizableAbstractModel  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.IPv4Range import IPv4Range  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.IPv6Range import IPv6Range  # noqa: F401,E501

class AddressGroup(ExternalizableAbstractModel):

    """

    :param name: (:attr:`name`) A short identifier for an Address Group.
    :type name: required
     max=64 chars
    
    :param description: (:attr:`description`) A user defined annotation for an Address Group.
    :type description: 
     max=1000 chars
    
    :param ipv4_addresses: (:attr:`ipv4_addresses`) List of CIDR blocks in the Address Group.
    :type ipv4_addresses: 
    
    
    :param ip_ranges: (:attr:`ip_ranges`) List of IP range containing start and end IP.
    :type ip_ranges: 
    
    
    :param ipv6_addresses: (:attr:`ipv6_addresses`) List of Ipv6 CIDR blocks in the Address Group.
    :type ipv6_addresses: 
    
    
    :param ipv6_ranges: (:attr:`ipv6_ranges`) List of IPv6 range containing start and end IP.
    :type ipv6_ranges: 
    
    
    :param policy_references: (:attr:`policy_references`) Reference to policy associated with Address Group.
    :type policy_references: 
    
    
    :param created_by: (:attr:`created_by`) The external identifier of the user who created the Address Group.
    :type created_by: 
    
    
    :param creation_time: (:attr:`creation_time`) The timestamp when the Address Group was created.
    :type creation_time: 
    
    
    :param last_update_time: (:attr:`last_update_time`) The timestamp when the Address Group was last updated.
    :type last_update_time: 
    
    

    """
    """
    IGNORE:
    Attributes:
      swagger_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    IGNORE
    """  # noqa: E501
    swagger_types = {
        'name': 'str',
        'description': 'str',
        'ipv4_addresses': 'list[common.v1.config.IPv4Address]',
        'ip_ranges': 'list[microseg.v4.config.IPv4Range]',
        'ipv6_addresses': 'list[common.v1.config.IPv6Address]',
        'ipv6_ranges': 'list[microseg.v4.config.IPv6Range]',
        'policy_references': 'list[str]',
        'created_by': 'str',
        'creation_time': 'datetime',
        'last_update_time': 'datetime',
        'ext_id': 'str',
        'links': 'list[common.v1.response.ApiLink]',
        'tenant_id': 'str',
        '_reserved': 'dict(str, object)',
        '_object_type': 'str',
        '_unknown_fields': 'dict(str, object)',
    }

    attribute_map = {
        'name': 'name',
        'description': 'description',
        'ipv4_addresses': 'ipv4Addresses',
        'ip_ranges': 'ipRanges',
        'ipv6_addresses': 'ipv6Addresses',
        'ipv6_ranges': 'ipv6Ranges',
        'policy_references': 'policyReferences',
        'created_by': 'createdBy',
        'creation_time': 'creationTime',
        'last_update_time': 'lastUpdateTime',
        'ext_id': 'extId',
        'links': 'links',
        'tenant_id': 'tenantId',
        '_reserved': '$reserved',
        '_object_type': '$objectType',
        '_unknown_fields': '$unknownFields',
    }



    def __init__(self, name=None, description=None, ipv4_addresses=None, ip_ranges=None, ipv6_addresses=None, ipv6_ranges=None, policy_references=None, created_by=None, creation_time=None, last_update_time=None, ext_id=None, links=None, tenant_id=None, *args, **kwargs):  # noqa: E501
        ExternalizableAbstractModel.__init__(self, ext_id, links, tenant_id, *args, **kwargs)
        self.__name = None
        self.__description = None
        self.__ipv4_addresses = None
        self.__ip_ranges = None
        self.__ipv6_addresses = None
        self.__ipv6_ranges = None
        self.__policy_references = None
        self.__created_by = None
        self.__creation_time = None
        self.__last_update_time = None
        self.discriminator = None
        self.__name = name
        if description is not None:
            self.__description = description
        if ipv4_addresses is not None:
            self.__ipv4_addresses = ipv4_addresses
        if ip_ranges is not None:
            self.__ip_ranges = ip_ranges
        if ipv6_addresses is not None:
            self.__ipv6_addresses = ipv6_addresses
        if ipv6_ranges is not None:
            self.__ipv6_ranges = ipv6_ranges
        if policy_references is not None:
            self.__policy_references = policy_references
        if created_by is not None:
            self.__created_by = created_by
        if creation_time is not None:
            self.__creation_time = creation_time
        if last_update_time is not None:
            self.__last_update_time = last_update_time

    def _initialize_object_type(self):
        return 'microseg.v4.config.AddressGroup'

    def _initialize_object_version(self):
        return 'v4.r2'


    @property
    def name(self):
        """
        A short identifier for an Address Group.

        :type:
                :class:`~str`
        """  # noqa: E501
        return self.__name

    @name.setter
    def name(self, name):
        if name is None:
            raise ValueError("Invalid value for `name`, must not be `None`")  # noqa: E501
        if name is not None and len(name) > 64:
            raise ValueError("Invalid value for `name`, length must be less than or equal to `64`")  # noqa: E501
        if name is not None and not re.search('^\\s*[a-zA-Z0-9]([a-zA-Z0-9-_ \\\\.]*[a-zA-Z0-9])?\\s*$', name):  # noqa: E501
            raise ValueError(r"Invalid value for `name`, must be a follow pattern or equal to `/^\\s*[a-zA-Z0-9]([a-zA-Z0-9-_ \\\\.]*[a-zA-Z0-9])?\\s*$/`")  # noqa: E501

        self.__name = name

    @property
    def description(self):
        """
        A user defined annotation for an Address Group.

        :type:
                :class:`~str`
        """  # noqa: E501
        return self.__description

    @description.setter
    def description(self, description):
        if description is not None and len(description) > 1000:
            raise ValueError("Invalid value for `description`, length must be less than or equal to `1000`")  # noqa: E501
        if description is not None and not re.search('^\\s*([a-zA-Z0-9 _:.()-]*)\\s*$', description):  # noqa: E501
            raise ValueError(r"Invalid value for `description`, must be a follow pattern or equal to `/^\\s*([a-zA-Z0-9 _:.()-]*)\\s*$/`")  # noqa: E501

        self.__description = description

    @property
    def ipv4_addresses(self):
        """
        List of CIDR blocks in the Address Group.

        :type:
             list[ :class:`~ntnx_microseg_py_client.models.common.v1.config.IPv4Address` ]
        """  # noqa: E501
        return self.__ipv4_addresses

    @ipv4_addresses.setter
    def ipv4_addresses(self, ipv4_addresses):

        self.__ipv4_addresses = ipv4_addresses

    @property
    def ip_ranges(self):
        """
        List of IP range containing start and end IP.

        :type:
             list[ :class:`~ntnx_microseg_py_client.models.microseg.v4.config.IPv4Range` ]
        """  # noqa: E501
        return self.__ip_ranges

    @ip_ranges.setter
    def ip_ranges(self, ip_ranges):

        self.__ip_ranges = ip_ranges

    @property
    def ipv6_addresses(self):
        """
        List of Ipv6 CIDR blocks in the Address Group.

        :type:
             list[ :class:`~ntnx_microseg_py_client.models.common.v1.config.IPv6Address` ]
        """  # noqa: E501
        return self.__ipv6_addresses

    @ipv6_addresses.setter
    def ipv6_addresses(self, ipv6_addresses):

        self.__ipv6_addresses = ipv6_addresses

    @property
    def ipv6_ranges(self):
        """
        List of IPv6 range containing start and end IP.

        :type:
             list[ :class:`~ntnx_microseg_py_client.models.microseg.v4.config.IPv6Range` ]
        """  # noqa: E501
        return self.__ipv6_ranges

    @ipv6_ranges.setter
    def ipv6_ranges(self, ipv6_ranges):

        self.__ipv6_ranges = ipv6_ranges

    @property
    def policy_references(self):
        """
        Reference to policy associated with Address Group.

        :type:
            list[ :class:`~str` ]
        """  # noqa: E501
        return self.__policy_references

    @policy_references.setter
    def policy_references(self, policy_references):

        self.__policy_references = policy_references

    @property
    def created_by(self):
        """
        The external identifier of the user who created the Address Group.

        :type:
                :class:`~str`
        """  # noqa: E501
        return self.__created_by

    @created_by.setter
    def created_by(self, created_by):
        if created_by is not None and not re.search('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$', created_by):  # noqa: E501
            raise ValueError(r"Invalid value for `created_by`, must be a follow pattern or equal to `/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/`")  # noqa: E501

        self.__created_by = created_by

    @property
    def creation_time(self):
        """
        The timestamp when the Address Group was created.

        :type:
                :class:`~datetime`
        """  # noqa: E501
        return self.__creation_time

    @creation_time.setter
    def creation_time(self, creation_time):

        self.__creation_time = creation_time

    @property
    def last_update_time(self):
        """
        The timestamp when the Address Group was last updated.

        :type:
                :class:`~datetime`
        """  # noqa: E501
        return self.__last_update_time

    @last_update_time.setter
    def last_update_time(self, last_update_time):

        self.__last_update_time = last_update_time

    def _to_dict(self, sanitize):
        """Returns the model properties as a dict. Omits None properties based on the provided "sanitize" parameter.

        :param sanitize: A flag to omit None properties if set to True
        :type sanitize: bool
        """

        result = {}
        for attr, attr_type in six.iteritems(self.swagger_types):

            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x._to_dict(sanitize) if hasattr(x, "_to_dict") else x,
                    value
                ))
            elif hasattr(value, "_to_dict"):
                result[attr] = value._to_dict(sanitize)
            elif isinstance(value, Path):
                result[attr] = str(value)
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1]._to_dict(sanitize)) if hasattr(item[1], "_to_dict")
                    else (
                        (item[0], str(item[1])) if item[0] == 'path' and '$objectType' in value and value['$objectType'] == 'pathlib.Path'
                        else item
                    ),
                    six.iteritems(value)
                ))
            else:
                if sanitize:
                    if value is not None:
                        result[attr] = value
                else:
                    result[attr] = value
        if issubclass(AddressGroup, dict):
            for key, value in six.iteritems(self):
                result[key] = value

        # handle unknown fields
        result['_unknown_fields'] = {}
        unknown = self.get_unknown_fields()
        if sanitize:
            unknown = self._sanitize_for_serialization(unknown)

        return {**result, **unknown}


    def to_dict(self):
        """Returns the model properties as a dictionary"""
        return self._to_dict(False)

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self._to_dict(True))

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, AddressGroup):
            return False

        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        return not self == other

