# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa
# pylint: skip-file
from __future__ import unicode_literals
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv


class DropboxDuration(bb.Struct):
    __slots__ = [
        "_seconds_value",
        "_nanos_value",
    ]

    _has_required_fields = True

    def __init__(self, seconds=None, nanos=None):
        self._seconds_value = bb.NOT_SET
        self._nanos_value = bb.NOT_SET
        if seconds is not None:
            self.seconds = seconds
        if nanos is not None:
            self.nanos = nanos

    # Instance attribute type: int (validator is set below)
    seconds = bb.Attribute("seconds")

    # Instance attribute type: int (validator is set below)
    nanos = bb.Attribute("nanos")

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(DropboxDuration, self)._process_custom_annotations(
            annotation_type, field_path, processor
        )


DropboxDuration_validator = bv.Struct(DropboxDuration)


class PathRoot(bb.Union):
    """
    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar PathRoot.home:
        Paths are relative to the authenticating user's home namespace, whether
        or not that user belongs to a team.
    :ivar PathRoot.root:
        Paths are relative to the authenticating user's root namespace (This
        results in ``PathRootError.invalid_root`` if the user's root namespace
        has changed.).
    :vartype PathRoot.root: str
    :ivar PathRoot.namespace_id:
        Paths are relative to given namespace id (This results in
        ``PathRootError.no_permission`` if you don't have access to this
        namespace.).
    :vartype PathRoot.namespace_id: str
    """

    _catch_all = "other"
    # Attribute is overwritten below the class definition
    home = None
    # Attribute is overwritten below the class definition
    other = None

    @classmethod
    def root(cls, val):
        """
        Create an instance of this class set to the ``root`` tag with value
        ``val``.

        :param str val:
        :rtype: PathRoot
        """
        return cls("root", val)

    @classmethod
    def namespace_id(cls, val):
        """
        Create an instance of this class set to the ``namespace_id`` tag with
        value ``val``.

        :param str val:
        :rtype: PathRoot
        """
        return cls("namespace_id", val)

    def is_home(self):
        """
        Check if the union tag is ``home``.

        :rtype: bool
        """
        return self._tag == "home"

    def is_root(self):
        """
        Check if the union tag is ``root``.

        :rtype: bool
        """
        return self._tag == "root"

    def is_namespace_id(self):
        """
        Check if the union tag is ``namespace_id``.

        :rtype: bool
        """
        return self._tag == "namespace_id"

    def is_other(self):
        """
        Check if the union tag is ``other``.

        :rtype: bool
        """
        return self._tag == "other"

    def get_root(self):
        """
        Paths are relative to the authenticating user's root namespace (This
        results in ``PathRootError.invalid_root`` if the user's root namespace
        has changed.).

        Only call this if :meth:`is_root` is true.

        :rtype: str
        """
        if not self.is_root():
            raise AttributeError("tag 'root' not set")
        return self._value

    def get_namespace_id(self):
        """
        Paths are relative to given namespace id (This results in
        ``PathRootError.no_permission`` if you don't have access to this
        namespace.).

        Only call this if :meth:`is_namespace_id` is true.

        :rtype: str
        """
        if not self.is_namespace_id():
            raise AttributeError("tag 'namespace_id' not set")
        return self._value

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(PathRoot, self)._process_custom_annotations(annotation_type, field_path, processor)


PathRoot_validator = bv.Union(PathRoot)


class PathRootError(bb.Union):
    """
    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar PathRootError.invalid_root:
        The root namespace id in Dropbox-API-Path-Root header is not valid. The
        value of this error is the user's latest root info.
    :vartype PathRootError.invalid_root: RootInfo
    :ivar PathRootError.no_permission:
        You don't have permission to access the namespace id in
        Dropbox-API-Path-Root header.
    """

    _catch_all = "other"
    # Attribute is overwritten below the class definition
    no_permission = None
    # Attribute is overwritten below the class definition
    other = None

    @classmethod
    def invalid_root(cls, val):
        """
        Create an instance of this class set to the ``invalid_root`` tag with
        value ``val``.

        :param RootInfo val:
        :rtype: PathRootError
        """
        return cls("invalid_root", val)

    def is_invalid_root(self):
        """
        Check if the union tag is ``invalid_root``.

        :rtype: bool
        """
        return self._tag == "invalid_root"

    def is_no_permission(self):
        """
        Check if the union tag is ``no_permission``.

        :rtype: bool
        """
        return self._tag == "no_permission"

    def is_other(self):
        """
        Check if the union tag is ``other``.

        :rtype: bool
        """
        return self._tag == "other"

    def get_invalid_root(self):
        """
        The root namespace id in Dropbox-API-Path-Root header is not valid. The
        value of this error is the user's latest root info.

        Only call this if :meth:`is_invalid_root` is true.

        :rtype: RootInfo
        """
        if not self.is_invalid_root():
            raise AttributeError("tag 'invalid_root' not set")
        return self._value

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(PathRootError, self)._process_custom_annotations(
            annotation_type, field_path, processor
        )


PathRootError_validator = bv.Union(PathRootError)


class RootInfo(bb.Struct):
    """
    Information about current user's root.

    :ivar RootInfo.root_namespace_id:
        The namespace ID for user's root namespace. It will be the namespace ID
        of the shared team root if the user is member of a team with a separate
        team root, or the user root if user is member of a team with separate
        distinct roots for users. Otherwise it will be the same as
        ``RootInfo.home_namespace_id``.
    :ivar RootInfo.home_namespace_id:
        The namespace ID for user's home namespace.
    """

    __slots__ = [
        "_root_namespace_id_value",
        "_home_namespace_id_value",
    ]

    _has_required_fields = True

    def __init__(self, root_namespace_id=None, home_namespace_id=None):
        self._root_namespace_id_value = bb.NOT_SET
        self._home_namespace_id_value = bb.NOT_SET
        if root_namespace_id is not None:
            self.root_namespace_id = root_namespace_id
        if home_namespace_id is not None:
            self.home_namespace_id = home_namespace_id

    # Instance attribute type: str (validator is set below)
    root_namespace_id = bb.Attribute("root_namespace_id")

    # Instance attribute type: str (validator is set below)
    home_namespace_id = bb.Attribute("home_namespace_id")

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(RootInfo, self)._process_custom_annotations(annotation_type, field_path, processor)


RootInfo_validator = bv.StructTree(RootInfo)


class TeamRootInfo(RootInfo):
    """
    Root info when user is member of a team with a separate root namespace ID.

    :ivar TeamRootInfo.home_path:
        The path for user's home directory under the shared team root.
    """

    __slots__ = [
        "_home_path_value",
    ]

    _has_required_fields = True

    def __init__(self, root_namespace_id=None, home_namespace_id=None, home_path=None):
        super(TeamRootInfo, self).__init__(root_namespace_id, home_namespace_id)
        self._home_path_value = bb.NOT_SET
        if home_path is not None:
            self.home_path = home_path

    # Instance attribute type: str (validator is set below)
    home_path = bb.Attribute("home_path")

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(TeamRootInfo, self)._process_custom_annotations(
            annotation_type, field_path, processor
        )


TeamRootInfo_validator = bv.Struct(TeamRootInfo)


class UserRootInfo(RootInfo):
    """
    Root info when user is not member of a team or the user is a member of a
    team and the team does not have a separate root namespace.

    :ivar UserRootInfo.home_path:
        The path for user's home directory under the distinct user root.
    """

    __slots__ = [
        "_home_path_value",
    ]

    _has_required_fields = True

    def __init__(self, root_namespace_id=None, home_namespace_id=None, home_path=None):
        super(UserRootInfo, self).__init__(root_namespace_id, home_namespace_id)
        self._home_path_value = bb.NOT_SET
        if home_path is not None:
            self.home_path = home_path

    # Instance attribute type: str (validator is set below)
    home_path = bb.Attribute("home_path", nullable=True)

    def _process_custom_annotations(self, annotation_type, field_path, processor):
        super(UserRootInfo, self)._process_custom_annotations(
            annotation_type, field_path, processor
        )


UserRootInfo_validator = bv.Struct(UserRootInfo)

Date_validator = bv.Timestamp("%Y-%m-%d")
DisplayName_validator = bv.String(pattern='[^/:?*<>"|]*')
DisplayNameLegacy_validator = bv.String()
DropboxTimestamp_validator = bv.Timestamp("%Y-%m-%dT%H:%M:%SZ")
EmailAddress_validator = bv.String(
    max_length=255,
    pattern="^['#&A-Za-z0-9._%+-]+@[A-Za-z0-9-][A-Za-z0-9.-]*\\.[A-Za-z]{2,15}$",
)
LanguageCode_validator = bv.String(min_length=2)
NamePart_validator = bv.String(min_length=1, max_length=50, pattern='[^/:?*<>"|]*')
NamespaceId_validator = bv.String(pattern="[-_0-9a-zA-Z:]+")
OptionalNamePart_validator = bv.String(max_length=50, pattern='[^/:?*<>"|]*')
SessionId_validator = bv.String()
SharedFolderId_validator = NamespaceId_validator
DropboxDuration.seconds.validator = bv.Int64()
DropboxDuration.nanos.validator = bv.Int32()
DropboxDuration._all_field_names_ = set(
    [
        "seconds",
        "nanos",
    ]
)
DropboxDuration._all_fields_ = [
    ("seconds", DropboxDuration.seconds.validator),
    ("nanos", DropboxDuration.nanos.validator),
]

PathRoot._home_validator = bv.Void()
PathRoot._root_validator = NamespaceId_validator
PathRoot._namespace_id_validator = NamespaceId_validator
PathRoot._other_validator = bv.Void()
PathRoot._tagmap = {
    "home": PathRoot._home_validator,
    "root": PathRoot._root_validator,
    "namespace_id": PathRoot._namespace_id_validator,
    "other": PathRoot._other_validator,
}

PathRoot.home = PathRoot("home")
PathRoot.other = PathRoot("other")

PathRootError._invalid_root_validator = RootInfo_validator
PathRootError._no_permission_validator = bv.Void()
PathRootError._other_validator = bv.Void()
PathRootError._tagmap = {
    "invalid_root": PathRootError._invalid_root_validator,
    "no_permission": PathRootError._no_permission_validator,
    "other": PathRootError._other_validator,
}

PathRootError.no_permission = PathRootError("no_permission")
PathRootError.other = PathRootError("other")

RootInfo.root_namespace_id.validator = NamespaceId_validator
RootInfo.home_namespace_id.validator = NamespaceId_validator
RootInfo._field_names_ = set(
    [
        "root_namespace_id",
        "home_namespace_id",
    ]
)
RootInfo._all_field_names_ = RootInfo._field_names_
RootInfo._fields_ = [
    ("root_namespace_id", RootInfo.root_namespace_id.validator),
    ("home_namespace_id", RootInfo.home_namespace_id.validator),
]
RootInfo._all_fields_ = RootInfo._fields_

RootInfo._tag_to_subtype_ = {
    ("team",): TeamRootInfo_validator,
    ("user",): UserRootInfo_validator,
}
RootInfo._pytype_to_tag_and_subtype_ = {
    TeamRootInfo: (("team",), TeamRootInfo_validator),
    UserRootInfo: (("user",), UserRootInfo_validator),
}
RootInfo._is_catch_all_ = True

TeamRootInfo.home_path.validator = bv.String()
TeamRootInfo._field_names_ = set(["home_path"])
TeamRootInfo._all_field_names_ = RootInfo._all_field_names_.union(TeamRootInfo._field_names_)
TeamRootInfo._fields_ = [("home_path", TeamRootInfo.home_path.validator)]
TeamRootInfo._all_fields_ = RootInfo._all_fields_ + TeamRootInfo._fields_

UserRootInfo.home_path.validator = bv.Nullable(bv.String())
UserRootInfo._field_names_ = set(["home_path"])
UserRootInfo._all_field_names_ = RootInfo._all_field_names_.union(UserRootInfo._field_names_)
UserRootInfo._fields_ = [("home_path", UserRootInfo.home_path.validator)]
UserRootInfo._all_fields_ = RootInfo._all_fields_ + UserRootInfo._fields_

ROUTES = {}
