#
# Copyright 2019 by Delphix
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# This class has been automatically generated from:
#     /delphix-change-current-password-policy-parameters.json
#
# Do not edit this file manually!
#

from __future__ import unicode_literals

from delphixpy.v1_9_0.web.objects.TypedObject import TypedObject
from delphixpy.v1_9_0 import common

class __Undef(object):
    def __repr__(self):
        return "undef"

_UNDEFINED = __Undef()

try:
    TEXT_TYPE = unicode
except NameError:
    TEXT_TYPE = str

class ChangeCurrentPasswordPolicyParameters(TypedObject):
    """
    *(extends* :py:class:`v1_9_0.web.vo.TypedObject` *)* The parameters to use
    as input when changing the currently active password policy.
    """
    def __init__(self, undef_enabled=True):
        super(ChangeCurrentPasswordPolicyParameters, self).__init__()
        self._type = ("ChangeCurrentPasswordPolicyParameters", True)
        self._user_type = (self.__undef__, True)
        self._current_password_policy = (self.__undef__, True)

    API_VERSION = "1.9.0"

    @classmethod
    def from_dict(cls, data, dirty=False, undef_enabled=True):
        obj = super(ChangeCurrentPasswordPolicyParameters, cls).from_dict(data, dirty, undef_enabled)
        if "userType" not in data:
            raise ValueError("Missing required property \"userType\".")
        obj._user_type = (data.get("userType", obj.__undef__), dirty)
        if obj._user_type[0] is not None and obj._user_type[0] is not obj.__undef__:
            assert isinstance(obj._user_type[0], TEXT_TYPE), ("Expected one of [u'string'], but got %s of type %s" % (obj._user_type[0], type(obj._user_type[0])))
            assert obj._user_type[0] in [u'SYSTEM', u'DOMAIN'], "Expected enum [u'SYSTEM', u'DOMAIN'] but got %s" % obj._user_type[0]
            common.validate_format(obj._user_type[0], "None", None, None)
        if "currentPasswordPolicy" not in data:
            raise ValueError("Missing required property \"currentPasswordPolicy\".")
        obj._current_password_policy = (data.get("currentPasswordPolicy", obj.__undef__), dirty)
        if obj._current_password_policy[0] is not None and obj._current_password_policy[0] is not obj.__undef__:
            assert isinstance(obj._current_password_policy[0], TEXT_TYPE), ("Expected one of [u'string'], but got %s of type %s" % (obj._current_password_policy[0], type(obj._current_password_policy[0])))
            common.validate_format(obj._current_password_policy[0], "objectReference", None, None)
        return obj

    def to_dict(self, dirty=False, belongs_to_parent=False):
        dct = super(ChangeCurrentPasswordPolicyParameters, self).to_dict(dirty, belongs_to_parent)

        def dictify(obj, prop_is_list_or_vo=False):
            if isinstance(obj, list):
                return [dictify(o, prop_is_list_or_vo) for o in obj]
            elif hasattr(obj, "to_dict"):
                return obj.to_dict(dirty=dirty, belongs_to_parent=prop_is_list_or_vo)
            else:
                return obj
        if "user_type" == "type" or (self.user_type is not self.__undef__ and (not (dirty and not self._user_type[1]) or isinstance(self.user_type, list) or belongs_to_parent)):
            dct["userType"] = dictify(self.user_type)
        if "current_password_policy" == "type" or (self.current_password_policy is not self.__undef__ and (not (dirty and not self._current_password_policy[1]) or isinstance(self.current_password_policy, list) or belongs_to_parent)):
            dct["currentPasswordPolicy"] = dictify(self.current_password_policy)
        return dct

    def dirty(self):
        return self.from_dict(self.to_dict(dirty=False), dirty=True)

    def force_dirty(self):
        self._user_type = (self._user_type[0], True)
        self._current_password_policy = (self._current_password_policy[0], True)

    def is_dirty(self):
        return any([self._user_type[1], self._current_password_policy[1]])

    def __eq__(self, other):
        if other is None:
            return False
        if not isinstance(other, ChangeCurrentPasswordPolicyParameters):
            return False
        return super(ChangeCurrentPasswordPolicyParameters, self).__eq__(other) and \
               self.user_type == other.user_type and \
               self.current_password_policy == other.current_password_policy

    def __ne__(self, other):
        return not self.__eq__(other)

    def __repr__(self):
        return common.generate_repr_string(self)

    @property
    def user_type(self):
        """
        Type of user. *(permitted values: SYSTEM, DOMAIN)*

        :rtype: ``TEXT_TYPE``
        """
        return self._user_type[0]

    @user_type.setter
    def user_type(self, value):
        self._user_type = (value, True)

    @property
    def current_password_policy(self):
        """
        Password policy reference.

        :rtype: ``TEXT_TYPE``
        """
        return self._current_password_policy[0]

    @current_password_policy.setter
    def current_password_policy(self, value):
        self._current_password_policy = (value, True)

