# coding: utf-8

"""
    Agilicus API

    Agilicus is API-first. Modern software is controlled by other software, is open, is available for you to use the way you want, securely, simply.  A rendered, online viewable and usable version of this specification is available at [api](https://www.agilicus.com/api). You may try the API inline directly in the web page. To do so, first obtain an Authentication Token (the simplest way is to install the Python SDK, and then run `agilicus-cli --issuer https://MYISSUER get-token`). You will need an org-id for most calls (and can obtain from `agilicus-cli --issuer https://MYISSUER list-orgs`). The `MYISSUER` will typically be `auth.MYDOMAIN`, and you will see it as you sign-in to the administrative UI.  This API releases on Bearer-Token authentication. To obtain a valid bearer token you will need to Authenticate to an Issuer with OpenID Connect (a superset of OAUTH2).  Your \"issuer\" will look like https://auth.MYDOMAIN. For example, when you signed-up, if you said \"use my own domain name\" and assigned a CNAME of cloud.example.com, then your issuer would be https://auth.cloud.example.com.  If you selected \"use an Agilicus supplied domain name\", your issuer would look like https://auth.myorg.agilicus.cloud.  For test purposes you can use our [Python SDK](https://pypi.org/project/agilicus/) and run `agilicus-cli --issuer https://auth.MYDOMAIN get-token`.  This API may be used in any language runtime that supports OpenAPI 3.0, or, you may use our [Python SDK](https://pypi.org/project/agilicus/), our [Typescript SDK](https://www.npmjs.com/package/@agilicus/angular), or our [Golang SDK](https://git.agilicus.com/pub/sdk-go).  100% of the activities in our system our API-driven, from our web-admin, through our progressive web applications, to all internals: there is nothing that is not accessible.  For more information, see [developer resources](https://www.agilicus.com/developer).   # noqa: E501

    The version of the OpenAPI document: 2021.05.06
    Contact: dev@agilicus.com
    Generated by: https://openapi-generator.tech
"""


import pprint
import re  # noqa: F401

import six

from agilicus_api.configuration import Configuration


class PolicyCondition(object):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    """
    Attributes:
      openapi_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.
    """
    openapi_types = {
        'condition_type': 'str',
        'inverted': 'bool',
        'input_is_list': 'bool',
        'value': 'str',
        'operator': 'str',
        'field': 'str',
        'created': 'datetime',
        'updated': 'datetime'
    }

    attribute_map = {
        'condition_type': 'condition_type',
        'inverted': 'inverted',
        'input_is_list': 'input_is_list',
        'value': 'value',
        'operator': 'operator',
        'field': 'field',
        'created': 'created',
        'updated': 'updated'
    }

    def __init__(self, condition_type=None, inverted=False, input_is_list=False, value=None, operator=None, field=None, created=None, updated=None, local_vars_configuration=None):  # noqa: E501
        """PolicyCondition - a model defined in OpenAPI"""  # noqa: E501
        if local_vars_configuration is None:
            local_vars_configuration = Configuration()
        self.local_vars_configuration = local_vars_configuration

        self._condition_type = None
        self._inverted = None
        self._input_is_list = None
        self._value = None
        self._operator = None
        self._field = None
        self._created = None
        self._updated = None
        self.discriminator = None

        self.condition_type = condition_type
        if inverted is not None:
            self.inverted = inverted
        if input_is_list is not None:
            self.input_is_list = input_is_list
        self.value = value
        self.operator = operator
        if field is not None:
            self.field = field
        if created is not None:
            self.created = created
        if updated is not None:
            self.updated = updated

    @property
    def condition_type(self):
        """Gets the condition_type of this PolicyCondition.  # noqa: E501

        The type of this condition. The type determines how the value will be evaluated. This parameter is case sensitive.  # noqa: E501

        :return: The condition_type of this PolicyCondition.  # noqa: E501
        :rtype: str
        """
        return self._condition_type

    @condition_type.setter
    def condition_type(self, condition_type):
        """Sets the condition_type of this PolicyCondition.

        The type of this condition. The type determines how the value will be evaluated. This parameter is case sensitive.  # noqa: E501

        :param condition_type: The condition_type of this PolicyCondition.  # noqa: E501
        :type: str
        """
        if self.local_vars_configuration.client_side_validation and condition_type is None:  # noqa: E501
            raise ValueError("Invalid value for `condition_type`, must not be `None`")  # noqa: E501
        allowed_values = ["type_client_id_list", "type_org_id_list", "type_user_id_list", "type_upstream_idp_list", "type_ip_in_cidr_list", "type_last_successful_mfa", "type_object_attribute"]  # noqa: E501
        if self.local_vars_configuration.client_side_validation and condition_type not in allowed_values:  # noqa: E501
            raise ValueError(
                "Invalid value for `condition_type` ({0}), must be one of {1}"  # noqa: E501
                .format(condition_type, allowed_values)
            )

        self._condition_type = condition_type

    @property
    def inverted(self):
        """Gets the inverted of this PolicyCondition.  # noqa: E501

        This field is deprecated. Whether to invert the condition (ie the not operator). If the condition is `a == b` inverting the condition results in `not (a == b)`  # noqa: E501

        :return: The inverted of this PolicyCondition.  # noqa: E501
        :rtype: bool
        """
        return self._inverted

    @inverted.setter
    def inverted(self, inverted):
        """Sets the inverted of this PolicyCondition.

        This field is deprecated. Whether to invert the condition (ie the not operator). If the condition is `a == b` inverting the condition results in `not (a == b)`  # noqa: E501

        :param inverted: The inverted of this PolicyCondition.  # noqa: E501
        :type: bool
        """

        self._inverted = inverted

    @property
    def input_is_list(self):
        """Gets the input_is_list of this PolicyCondition.  # noqa: E501

        Whether the input to the condition is in a list. The semantics of the condition when this flag is set is to compare every item in the list to the `value` using the `operator`. The condition is satisfied if any item in the list evaluates to true   # noqa: E501

        :return: The input_is_list of this PolicyCondition.  # noqa: E501
        :rtype: bool
        """
        return self._input_is_list

    @input_is_list.setter
    def input_is_list(self, input_is_list):
        """Sets the input_is_list of this PolicyCondition.

        Whether the input to the condition is in a list. The semantics of the condition when this flag is set is to compare every item in the list to the `value` using the `operator`. The condition is satisfied if any item in the list evaluates to true   # noqa: E501

        :param input_is_list: The input_is_list of this PolicyCondition.  # noqa: E501
        :type: bool
        """

        self._input_is_list = input_is_list

    @property
    def value(self):
        """Gets the value of this PolicyCondition.  # noqa: E501

        A JSON string representing the value to compare against. The structure of the comparision and type of the value depends on the condition type. A comparision is done to determine the result of the condition (either `true` or `false`)  # noqa: E501

        :return: The value of this PolicyCondition.  # noqa: E501
        :rtype: str
        """
        return self._value

    @value.setter
    def value(self, value):
        """Sets the value of this PolicyCondition.

        A JSON string representing the value to compare against. The structure of the comparision and type of the value depends on the condition type. A comparision is done to determine the result of the condition (either `true` or `false`)  # noqa: E501

        :param value: The value of this PolicyCondition.  # noqa: E501
        :type: str
        """
        if self.local_vars_configuration.client_side_validation and value is None:  # noqa: E501
            raise ValueError("Invalid value for `value`, must not be `None`")  # noqa: E501

        self._value = value

    @property
    def operator(self):
        """Gets the operator of this PolicyCondition.  # noqa: E501

        The operator used to evaluate this condition. The operator field only applies when the condition type is type_object_attribute. The other types have implied operators.  # noqa: E501

        :return: The operator of this PolicyCondition.  # noqa: E501
        :rtype: str
        """
        return self._operator

    @operator.setter
    def operator(self, operator):
        """Sets the operator of this PolicyCondition.

        The operator used to evaluate this condition. The operator field only applies when the condition type is type_object_attribute. The other types have implied operators.  # noqa: E501

        :param operator: The operator of this PolicyCondition.  # noqa: E501
        :type: str
        """
        if self.local_vars_configuration.client_side_validation and operator is None:  # noqa: E501
            raise ValueError("Invalid value for `operator`, must not be `None`")  # noqa: E501
        allowed_values = ["equals", "not_equals", "greater_than", "less_than", "in", "not_in"]  # noqa: E501
        if self.local_vars_configuration.client_side_validation and operator not in allowed_values:  # noqa: E501
            raise ValueError(
                "Invalid value for `operator` ({0}), must be one of {1}"  # noqa: E501
                .format(operator, allowed_values)
            )

        self._operator = operator

    @property
    def field(self):
        """Gets the field of this PolicyCondition.  # noqa: E501

        The object path to a field to use as input to the policy condition. This field only applies when the condition type is type_object_attribute. The supported objects are currently `users`, and `clients`.   # noqa: E501

        :return: The field of this PolicyCondition.  # noqa: E501
        :rtype: str
        """
        return self._field

    @field.setter
    def field(self, field):
        """Sets the field of this PolicyCondition.

        The object path to a field to use as input to the policy condition. This field only applies when the condition type is type_object_attribute. The supported objects are currently `users`, and `clients`.   # noqa: E501

        :param field: The field of this PolicyCondition.  # noqa: E501
        :type: str
        """
        if (self.local_vars_configuration.client_side_validation and
                field is not None and len(field) > 511):
            raise ValueError("Invalid value for `field`, length must be less than or equal to `511`")  # noqa: E501
        if (self.local_vars_configuration.client_side_validation and
                field is not None and not re.search(r'^([^\.]+\.?)*[^\.]+$', field)):  # noqa: E501
            raise ValueError(r"Invalid value for `field`, must be a follow pattern or equal to `/^([^\.]+\.?)*[^\.]+$/`")  # noqa: E501

        self._field = field

    @property
    def created(self):
        """Gets the created of this PolicyCondition.  # noqa: E501

        Creation time  # noqa: E501

        :return: The created of this PolicyCondition.  # noqa: E501
        :rtype: datetime
        """
        return self._created

    @created.setter
    def created(self, created):
        """Sets the created of this PolicyCondition.

        Creation time  # noqa: E501

        :param created: The created of this PolicyCondition.  # noqa: E501
        :type: datetime
        """

        self._created = created

    @property
    def updated(self):
        """Gets the updated of this PolicyCondition.  # noqa: E501

        Update time  # noqa: E501

        :return: The updated of this PolicyCondition.  # noqa: E501
        :rtype: datetime
        """
        return self._updated

    @updated.setter
    def updated(self, updated):
        """Sets the updated of this PolicyCondition.

        Update time  # noqa: E501

        :param updated: The updated of this PolicyCondition.  # noqa: E501
        :type: datetime
        """

        self._updated = updated

    def to_dict(self):
        """Returns the model properties as a dict"""
        result = {}

        for attr, _ in six.iteritems(self.openapi_types):
            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
                    value
                ))
            elif hasattr(value, "to_dict"):
                result[attr] = value.to_dict()
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1].to_dict())
                    if hasattr(item[1], "to_dict") else item,
                    value.items()
                ))
            else:
                result[attr] = value

        return result

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

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

        return self.to_dict() == other.to_dict()

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

        return self.to_dict() != other.to_dict()
