# 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.microseg.v4.config.CategoryAssociatedEntityType import CategoryAssociatedEntityType  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.IcmpTypeCodeSpec import IcmpTypeCodeSpec  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.IcmpV6TypeCodeSpec import IcmpV6TypeCodeSpec  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.IntraEntityGroupRuleAction import IntraEntityGroupRuleAction  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.TcpPortRangeSpec import TcpPortRangeSpec  # noqa: F401,E501
from ntnx_microseg_py_client.models.microseg.v4.config.UdpPortRangeSpec import UdpPortRangeSpec  # noqa: F401,E501

class IntraEntityGroupRuleSpec(object):

    """A rule for specifying allowed traffic inside a secured entity group.

    :param secured_group_category_associated_entity_type: (:attr:`secured_group_category_associated_entity_type`) 
    :type secured_group_category_associated_entity_type: 
    
    
    :param secured_group_category_references: (:attr:`secured_group_category_references`) A set of network endpoints which is protected by a Network Security Policy and defined as a list of categories.
    :type secured_group_category_references: 
    
    
    :param secured_group_entity_group_reference: (:attr:`secured_group_entity_group_reference`) External identifier of the entity group belonging to the secured group.
    :type secured_group_entity_group_reference: 
    
    
    :param secured_group_action: (:attr:`secured_group_action`) 
    :type secured_group_action: required
    
    
    :param secured_group_service_references: (:attr:`secured_group_service_references`) A list of service group references.
    :type secured_group_service_references: 
    
    
    :param tcp_services: (:attr:`tcp_services`) 
    :type tcp_services: 
    
    
    :param udp_services: (:attr:`udp_services`) 
    :type udp_services: 
    
    
    :param icmp_services: (:attr:`icmp_services`) ICMP Type Code List.
    :type icmp_services: 
    
    
    :param icmp_v6_services: (:attr:`icmp_v6_services`) ICMPv6 Type Code List.
    :type icmp_v6_services: 
    
    

    """
    """
    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 = {
        'secured_group_category_associated_entity_type': 'microseg.v4.config.CategoryAssociatedEntityType',
        'secured_group_category_references': 'list[str]',
        'secured_group_entity_group_reference': 'str',
        'secured_group_action': 'microseg.v4.config.IntraEntityGroupRuleAction',
        'secured_group_service_references': 'list[str]',
        'tcp_services': 'list[microseg.v4.config.TcpPortRangeSpec]',
        'udp_services': 'list[microseg.v4.config.UdpPortRangeSpec]',
        'icmp_services': 'list[microseg.v4.config.IcmpTypeCodeSpec]',
        'icmp_v6_services': 'list[microseg.v4.config.IcmpV6TypeCodeSpec]',
        '_reserved': 'dict(str, object)',
        '_object_type': 'str',
        '_unknown_fields': 'dict(str, object)',
    }

    attribute_map = {
        'secured_group_category_associated_entity_type': 'securedGroupCategoryAssociatedEntityType',
        'secured_group_category_references': 'securedGroupCategoryReferences',
        'secured_group_entity_group_reference': 'securedGroupEntityGroupReference',
        'secured_group_action': 'securedGroupAction',
        'secured_group_service_references': 'securedGroupServiceReferences',
        'tcp_services': 'tcpServices',
        'udp_services': 'udpServices',
        'icmp_services': 'icmpServices',
        'icmp_v6_services': 'icmpV6Services',
        '_reserved': '$reserved',
        '_object_type': '$objectType',
        '_unknown_fields': '$unknownFields',
    }



    def __init__(self, secured_group_category_associated_entity_type=None, secured_group_category_references=None, secured_group_entity_group_reference=None, secured_group_action=None, secured_group_service_references=None, tcp_services=None, udp_services=None, icmp_services=None, icmp_v6_services=None, *args, **kwargs):  # noqa: E501
        self.__secured_group_category_associated_entity_type = None
        self.__secured_group_category_references = None
        self.__secured_group_entity_group_reference = None
        self.__secured_group_action = None
        self.__secured_group_service_references = None
        self.__tcp_services = None
        self.__udp_services = None
        self.__icmp_services = None
        self.__icmp_v6_services = None
        self.discriminator = None
        if secured_group_category_associated_entity_type is not None:
            self.__secured_group_category_associated_entity_type = secured_group_category_associated_entity_type
        if secured_group_category_references is not None:
            self.__secured_group_category_references = secured_group_category_references
        if secured_group_entity_group_reference is not None:
            self.__secured_group_entity_group_reference = secured_group_entity_group_reference
        self.__secured_group_action = secured_group_action
        if secured_group_service_references is not None:
            self.__secured_group_service_references = secured_group_service_references
        if tcp_services is not None:
            self.__tcp_services = tcp_services
        if udp_services is not None:
            self.__udp_services = udp_services
        if icmp_services is not None:
            self.__icmp_services = icmp_services
        if icmp_v6_services is not None:
            self.__icmp_v6_services = icmp_v6_services
        # populate hidden vars if not empty
        self._populate_hidden_vars(kwargs)

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

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

    def _populate_hidden_vars(self, kwargs):
        if "_reserved" in kwargs and kwargs["_reserved"] is not None:
            self.__dollar_reserved = kwargs["_reserved"]
        elif hasattr(self, "attribute_map") and "_reserved" in self.attribute_map and self.attribute_map["_reserved"] in kwargs and kwargs[self.attribute_map["_reserved"]] is not None:
            self.__dollar_reserved = kwargs[self.attribute_map["_reserved"]]
        else :
            self.__dollar_reserved = {"$fv": self._initialize_object_version()}
        if "_unknown_fields" in kwargs and kwargs["_unknown_fields"] is not None:
            self.__dollar_unknown_fields = kwargs["_unknown_fields"]
        elif hasattr(self, "attribute_map") and "_unknown_fields" in self.attribute_map and self.attribute_map["_unknown_fields"] in kwargs and kwargs[self.attribute_map["_unknown_fields"]] is not None:
            self.__dollar_unknown_fields = kwargs[self.attribute_map["_unknown_fields"]]
        else :
            self.__dollar_unknown_fields = {}
        if "_object_type" in kwargs and kwargs["_object_type"] is not None:
            self.__dollar_object_type = kwargs["_object_type"]
        elif hasattr(self, "attribute_map") and "_object_type" in self.attribute_map and self.attribute_map["_object_type"] in kwargs and kwargs[self.attribute_map["_object_type"]] is not None:
            self.__dollar_object_type = kwargs[self.attribute_map["_object_type"]]
        else:
            self.__dollar_object_type = self._initialize_object_type()

    def get_object_type(self):
        return self.__dollar_object_type

    def get_reserved(self):
        return self.__dollar_reserved

    def get_unknown_fields(self):
        return self.__dollar_unknown_fields

    @property
    def secured_group_category_associated_entity_type(self):
        """
        

        :type:
            :class:`~ntnx_microseg_py_client.models.microseg.v4.config.CategoryAssociatedEntityType`
        """  # noqa: E501
        return self.__secured_group_category_associated_entity_type

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

        self.__secured_group_category_associated_entity_type = secured_group_category_associated_entity_type

    @property
    def secured_group_category_references(self):
        """
        A set of network endpoints which is protected by a Network Security Policy and defined as a list of categories.

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

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

        self.__secured_group_category_references = secured_group_category_references

    @property
    def secured_group_entity_group_reference(self):
        """
        External identifier of the entity group belonging to the secured group.

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

    @secured_group_entity_group_reference.setter
    def secured_group_entity_group_reference(self, secured_group_entity_group_reference):
        if secured_group_entity_group_reference 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}$', secured_group_entity_group_reference):  # noqa: E501
            raise ValueError(r"Invalid value for `secured_group_entity_group_reference`, 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.__secured_group_entity_group_reference = secured_group_entity_group_reference

    @property
    def secured_group_action(self):
        """
        

        :type:
            :class:`~ntnx_microseg_py_client.models.microseg.v4.config.IntraEntityGroupRuleAction`
        """  # noqa: E501
        return self.__secured_group_action

    @secured_group_action.setter
    def secured_group_action(self, secured_group_action):
        if secured_group_action is None:
            raise ValueError("Invalid value for `secured_group_action`, must not be `None`")  # noqa: E501

        self.__secured_group_action = secured_group_action

    @property
    def secured_group_service_references(self):
        """
        A list of service group references.

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

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

        self.__secured_group_service_references = secured_group_service_references

    @property
    def tcp_services(self):
        """
        

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

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

        self.__tcp_services = tcp_services

    @property
    def udp_services(self):
        """
        

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

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

        self.__udp_services = udp_services

    @property
    def icmp_services(self):
        """
        ICMP Type Code List.

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

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

        self.__icmp_services = icmp_services

    @property
    def icmp_v6_services(self):
        """
        ICMPv6 Type Code List.

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

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

        self.__icmp_v6_services = icmp_v6_services

    @property
    def _reserved(self):
        """
        

        :type:
            dict(str, :class:`~object`)
        """  # noqa: E501
        return self.__dollar_reserved

    @property
    def _object_type(self):
        """
        

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

    @property
    def _unknown_fields(self):
        """
        

        :type:
            dict(str, :class:`~object`)
        """  # noqa: E501
        return self.__dollar_unknown_fields

    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(IntraEntityGroupRuleSpec, 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 _sanitize_for_serialization(self, value):
        """Recursively sanitize the value for serialization.

        :param value: The value to sanitize
        :type value: any
        :return: Sanitized value
        :rtype: any
        """
        if isinstance(value, (list, tuple)):
            return list(map(self._sanitize_for_serialization, [v for v in value if v is not None]))
        elif isinstance(value, dict):
            return {k: self._sanitize_for_serialization(v) for k, v in six.iteritems(value) if v is not None}
        elif isinstance(value, (str, int, float, bool)):
            return value
        elif isinstance(value, Path):
            return str(value)
        else:
            return value.to_dict() if hasattr(value, 'to_dict') else str(value)

    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, IntraEntityGroupRuleSpec):
            return False

        return self.__dict__ == other.__dict__

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

