#
# 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-dvc-application-container-create-parameters.json
#
# Do not edit this file manually!
#

from __future__ import unicode_literals

from delphixpy.v1_3_0.web.objects.DVCApplicationCreateParameters import DVCApplicationCreateParameters
from delphixpy.v1_3_0 import common

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

_UNDEFINED = __Undef()

try:
    TEXT_TYPE = unicode
except NameError:
    TEXT_TYPE = str

class DVCApplicationContainerCreateParameters(DVCApplicationCreateParameters):
    """
    *(extends* :py:class:`v1_3_0.web.vo.DVCApplicationCreateParameters` *)* The
    parameters used to create an application container.
    """
    def __init__(self, undef_enabled=True):
        super(DVCApplicationContainerCreateParameters, self).__init__()
        self._type = ("DVCApplicationContainerCreateParameters", True)
        self._bookmark = (self.__undef__, True)
        self._owner = (self.__undef__, True)
        self._template = (self.__undef__, True)

    API_VERSION = "1.3.0"

    @classmethod
    def from_dict(cls, data, dirty=False, undef_enabled=True):
        obj = super(DVCApplicationContainerCreateParameters, cls).from_dict(data, dirty, undef_enabled)
        obj._bookmark = (data.get("bookmark", obj.__undef__), dirty)
        if obj._bookmark[0] is not None and obj._bookmark[0] is not obj.__undef__:
            assert isinstance(obj._bookmark[0], TEXT_TYPE), ("Expected one of [u'string'], but got %s of type %s" % (obj._bookmark[0], type(obj._bookmark[0])))
            common.validate_format(obj._bookmark[0], "objectReference", None, None)
        obj._owner = (data.get("owner", obj.__undef__), dirty)
        if obj._owner[0] is not None and obj._owner[0] is not obj.__undef__:
            assert isinstance(obj._owner[0], TEXT_TYPE), ("Expected one of [u'string'], but got %s of type %s" % (obj._owner[0], type(obj._owner[0])))
            common.validate_format(obj._owner[0], "objectReference", None, None)
        obj._template = (data.get("template", obj.__undef__), dirty)
        if obj._template[0] is not None and obj._template[0] is not obj.__undef__:
            assert isinstance(obj._template[0], TEXT_TYPE), ("Expected one of [u'string'], but got %s of type %s" % (obj._template[0], type(obj._template[0])))
            common.validate_format(obj._template[0], "objectReference", None, None)
        return obj

    def to_dict(self, dirty=False, belongs_to_parent=False):
        dct = super(DVCApplicationContainerCreateParameters, 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 "bookmark" == "type" or (self.bookmark is not self.__undef__ and (not (dirty and not self._bookmark[1]) or isinstance(self.bookmark, list) or belongs_to_parent)):
            dct["bookmark"] = dictify(self.bookmark)
        if "owner" == "type" or (self.owner is not self.__undef__ and (not (dirty and not self._owner[1]) or isinstance(self.owner, list) or belongs_to_parent)):
            dct["owner"] = dictify(self.owner)
        if "template" == "type" or (self.template is not self.__undef__ and (not (dirty and not self._template[1]) or isinstance(self.template, list) or belongs_to_parent)):
            dct["template"] = dictify(self.template)
        return dct

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

    def force_dirty(self):
        self._bookmark = (self._bookmark[0], True)
        self._owner = (self._owner[0], True)
        self._template = (self._template[0], True)

    def is_dirty(self):
        return any([self._bookmark[1], self._owner[1], self._template[1]])

    def __eq__(self, other):
        if other is None:
            return False
        if not isinstance(other, DVCApplicationContainerCreateParameters):
            return False
        return super(DVCApplicationContainerCreateParameters, self).__eq__(other) and \
               self.bookmark == other.bookmark and \
               self.owner == other.owner and \
               self.template == other.template

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

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

    @property
    def bookmark(self):
        """
        A reference to the bookmark that represents the inital state of the new
        application container. If no bookmark is specified then one is created
        at now on the template.

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

    @bookmark.setter
    def bookmark(self, value):
        self._bookmark = (value, True)

    @property
    def owner(self):
        """
        A reference to the user that owns this application container.

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

    @owner.setter
    def owner(self, value):
        self._owner = (value, True)

    @property
    def template(self):
        """
        A reference to the template that this application container is
        provisioned from.

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

    @template.setter
    def template(self, value):
        self._template = (value, True)

