# -*- 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 AccountPhotoGetArg(bb.Struct):
    """
    :ivar AccountPhotoGetArg.dbx_account_id:
        Encoded ID of the user. Must start either with 'dbid:' or 'dbaphid:'.
    :ivar AccountPhotoGetArg.size:
        A string representing the size of the photo.
    :ivar AccountPhotoGetArg.circle_crop:
        True if the photo should be cropped and false otherwise.
    :ivar AccountPhotoGetArg.expect_account_photo:
        True if we expect account photo to exist.
    """

    __slots__ = [
        "_dbx_account_id_value",
        "_size_value",
        "_circle_crop_value",
        "_expect_account_photo_value",
    ]

    _has_required_fields = True

    def __init__(
        self,
        dbx_account_id=None,
        size=None,
        circle_crop=None,
        expect_account_photo=None,
    ):
        self._dbx_account_id_value = bb.NOT_SET
        self._size_value = bb.NOT_SET
        self._circle_crop_value = bb.NOT_SET
        self._expect_account_photo_value = bb.NOT_SET
        if dbx_account_id is not None:
            self.dbx_account_id = dbx_account_id
        if size is not None:
            self.size = size
        if circle_crop is not None:
            self.circle_crop = circle_crop
        if expect_account_photo is not None:
            self.expect_account_photo = expect_account_photo

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

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

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

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

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


AccountPhotoGetArg_validator = bv.Struct(AccountPhotoGetArg)


class AccountPhotoGetError(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 AccountPhotoGetError.thumbnail_error:
        Indicates infrastructural failure.
    :vartype AccountPhotoGetError.thumbnail_error: ThumbnailError
    :ivar AccountPhotoGetError.account_photo_missing:
        Account photo is missing (but we did not expect it to exist).
    :ivar AccountPhotoGetError.expected_account_photo_missing:
        Account photo was expected to exist, but it's missing.
    """

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

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

        :param ThumbnailError val:
        :rtype: AccountPhotoGetError
        """
        return cls("thumbnail_error", val)

    def is_thumbnail_error(self):
        """
        Check if the union tag is ``thumbnail_error``.

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

    def is_account_photo_missing(self):
        """
        Check if the union tag is ``account_photo_missing``.

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

    def is_expected_account_photo_missing(self):
        """
        Check if the union tag is ``expected_account_photo_missing``.

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

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

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

    def get_thumbnail_error(self):
        """
        Indicates infrastructural failure.

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

        :rtype: ThumbnailError
        """
        if not self.is_thumbnail_error():
            raise AttributeError("tag 'thumbnail_error' not set")
        return self._value

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


AccountPhotoGetError_validator = bv.Union(AccountPhotoGetError)


class AccountPhotoGetResult(bb.Struct):
    """
    :ivar AccountPhotoGetResult.content_type:
        The data returned by get_photo.
    """

    __slots__ = [
        "_content_type_value",
    ]

    _has_required_fields = True

    def __init__(self, content_type=None):
        self._content_type_value = bb.NOT_SET
        if content_type is not None:
            self.content_type = content_type

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

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


AccountPhotoGetResult_validator = bv.Struct(AccountPhotoGetResult)


class DeleteProfilePhotoArg(bb.Struct):
    """
    This struct is empty. The comment here is intentionally emitted to avoid
    indentation issues with Stone.
    """

    __slots__ = []

    _has_required_fields = False

    def __init__(self):
        pass

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


DeleteProfilePhotoArg_validator = bv.Struct(DeleteProfilePhotoArg)


class DeleteProfilePhotoError(bb.Union):
    """
    This union is empty. The comment here is intentionally emitted to avoid
    indentation issues with Stone.

    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.
    """

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

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

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

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


DeleteProfilePhotoError_validator = bv.Union(DeleteProfilePhotoError)


class DeleteProfilePhotoResult(bb.Struct):
    """
    This struct is empty. The comment here is intentionally emitted to avoid
    indentation issues with Stone.
    """

    __slots__ = []

    _has_required_fields = False

    def __init__(self):
        pass

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


DeleteProfilePhotoResult_validator = bv.Struct(DeleteProfilePhotoResult)


class PhotoSourceArg(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 PhotoSourceArg.base64_data:
        Image data in base64-encoded bytes.
    :vartype PhotoSourceArg.base64_data: str
    """

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

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

        :param str val:
        :rtype: PhotoSourceArg
        """
        return cls("base64_data", val)

    def is_base64_data(self):
        """
        Check if the union tag is ``base64_data``.

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

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

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

    def get_base64_data(self):
        """
        Image data in base64-encoded bytes.

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

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

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


PhotoSourceArg_validator = bv.Union(PhotoSourceArg)


class SetProfilePhotoArg(bb.Struct):
    """
    :ivar SetProfilePhotoArg.photo:
        Image to set as the user's new profile photo.
    """

    __slots__ = [
        "_photo_value",
    ]

    _has_required_fields = True

    def __init__(self, photo=None):
        self._photo_value = bb.NOT_SET
        if photo is not None:
            self.photo = photo

    # Instance attribute type: PhotoSourceArg (validator is set below)
    photo = bb.Attribute("photo", user_defined=True)

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


SetProfilePhotoArg_validator = bv.Struct(SetProfilePhotoArg)


class SetProfilePhotoError(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 SetProfilePhotoError.file_type_error:
        File cannot be set as profile photo.
    :ivar SetProfilePhotoError.file_size_error:
        File cannot exceed 10 MB.
    :ivar SetProfilePhotoError.dimension_error:
        Image must be larger than 128 x 128.
    :ivar SetProfilePhotoError.thumbnail_error:
        Image could not be thumbnailed.
    :ivar SetProfilePhotoError.transient_error:
        Temporary infrastructure failure, please retry.
    """

    _catch_all = "other"
    # Attribute is overwritten below the class definition
    file_type_error = None
    # Attribute is overwritten below the class definition
    file_size_error = None
    # Attribute is overwritten below the class definition
    dimension_error = None
    # Attribute is overwritten below the class definition
    thumbnail_error = None
    # Attribute is overwritten below the class definition
    transient_error = None
    # Attribute is overwritten below the class definition
    other = None

    def is_file_type_error(self):
        """
        Check if the union tag is ``file_type_error``.

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

    def is_file_size_error(self):
        """
        Check if the union tag is ``file_size_error``.

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

    def is_dimension_error(self):
        """
        Check if the union tag is ``dimension_error``.

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

    def is_thumbnail_error(self):
        """
        Check if the union tag is ``thumbnail_error``.

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

    def is_transient_error(self):
        """
        Check if the union tag is ``transient_error``.

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

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

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

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


SetProfilePhotoError_validator = bv.Union(SetProfilePhotoError)


class SetProfilePhotoResult(bb.Struct):
    """
    :ivar SetProfilePhotoResult.profile_photo_url:
        URL for the photo representing the user, if one is set.
    """

    __slots__ = [
        "_profile_photo_url_value",
    ]

    _has_required_fields = True

    def __init__(self, profile_photo_url=None):
        self._profile_photo_url_value = bb.NOT_SET
        if profile_photo_url is not None:
            self.profile_photo_url = profile_photo_url

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

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


SetProfilePhotoResult_validator = bv.Struct(SetProfilePhotoResult)


class ThumbnailError(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 ThumbnailError.permanent_failure:
        Indicates permanent infrastructural failure.
    :ivar ThumbnailError.temporary_failure:
        Indicates temporary infrastructural failure.
    """

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

    def is_permanent_failure(self):
        """
        Check if the union tag is ``permanent_failure``.

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

    def is_temporary_failure(self):
        """
        Check if the union tag is ``temporary_failure``.

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

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

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

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


ThumbnailError_validator = bv.Union(ThumbnailError)

AccountPhotoGetArg.dbx_account_id.validator = bv.String()
AccountPhotoGetArg.size.validator = bv.String()
AccountPhotoGetArg.circle_crop.validator = bv.Boolean()
AccountPhotoGetArg.expect_account_photo.validator = bv.Boolean()
AccountPhotoGetArg._all_field_names_ = set(
    [
        "dbx_account_id",
        "size",
        "circle_crop",
        "expect_account_photo",
    ]
)
AccountPhotoGetArg._all_fields_ = [
    ("dbx_account_id", AccountPhotoGetArg.dbx_account_id.validator),
    ("size", AccountPhotoGetArg.size.validator),
    ("circle_crop", AccountPhotoGetArg.circle_crop.validator),
    ("expect_account_photo", AccountPhotoGetArg.expect_account_photo.validator),
]

AccountPhotoGetError._thumbnail_error_validator = ThumbnailError_validator
AccountPhotoGetError._account_photo_missing_validator = bv.Void()
AccountPhotoGetError._expected_account_photo_missing_validator = bv.Void()
AccountPhotoGetError._other_validator = bv.Void()
AccountPhotoGetError._tagmap = {
    "thumbnail_error": AccountPhotoGetError._thumbnail_error_validator,
    "account_photo_missing": AccountPhotoGetError._account_photo_missing_validator,
    "expected_account_photo_missing": AccountPhotoGetError._expected_account_photo_missing_validator,
    "other": AccountPhotoGetError._other_validator,
}

AccountPhotoGetError.account_photo_missing = AccountPhotoGetError("account_photo_missing")
AccountPhotoGetError.expected_account_photo_missing = AccountPhotoGetError(
    "expected_account_photo_missing"
)
AccountPhotoGetError.other = AccountPhotoGetError("other")

AccountPhotoGetResult.content_type.validator = bv.String()
AccountPhotoGetResult._all_field_names_ = set(["content_type"])
AccountPhotoGetResult._all_fields_ = [
    ("content_type", AccountPhotoGetResult.content_type.validator)
]

DeleteProfilePhotoArg._all_field_names_ = set([])
DeleteProfilePhotoArg._all_fields_ = []

DeleteProfilePhotoError._other_validator = bv.Void()
DeleteProfilePhotoError._tagmap = {
    "other": DeleteProfilePhotoError._other_validator,
}

DeleteProfilePhotoError.other = DeleteProfilePhotoError("other")

DeleteProfilePhotoResult._all_field_names_ = set([])
DeleteProfilePhotoResult._all_fields_ = []

PhotoSourceArg._base64_data_validator = bv.String()
PhotoSourceArg._other_validator = bv.Void()
PhotoSourceArg._tagmap = {
    "base64_data": PhotoSourceArg._base64_data_validator,
    "other": PhotoSourceArg._other_validator,
}

PhotoSourceArg.other = PhotoSourceArg("other")

SetProfilePhotoArg.photo.validator = PhotoSourceArg_validator
SetProfilePhotoArg._all_field_names_ = set(["photo"])
SetProfilePhotoArg._all_fields_ = [("photo", SetProfilePhotoArg.photo.validator)]

SetProfilePhotoError._file_type_error_validator = bv.Void()
SetProfilePhotoError._file_size_error_validator = bv.Void()
SetProfilePhotoError._dimension_error_validator = bv.Void()
SetProfilePhotoError._thumbnail_error_validator = bv.Void()
SetProfilePhotoError._transient_error_validator = bv.Void()
SetProfilePhotoError._other_validator = bv.Void()
SetProfilePhotoError._tagmap = {
    "file_type_error": SetProfilePhotoError._file_type_error_validator,
    "file_size_error": SetProfilePhotoError._file_size_error_validator,
    "dimension_error": SetProfilePhotoError._dimension_error_validator,
    "thumbnail_error": SetProfilePhotoError._thumbnail_error_validator,
    "transient_error": SetProfilePhotoError._transient_error_validator,
    "other": SetProfilePhotoError._other_validator,
}

SetProfilePhotoError.file_type_error = SetProfilePhotoError("file_type_error")
SetProfilePhotoError.file_size_error = SetProfilePhotoError("file_size_error")
SetProfilePhotoError.dimension_error = SetProfilePhotoError("dimension_error")
SetProfilePhotoError.thumbnail_error = SetProfilePhotoError("thumbnail_error")
SetProfilePhotoError.transient_error = SetProfilePhotoError("transient_error")
SetProfilePhotoError.other = SetProfilePhotoError("other")

SetProfilePhotoResult.profile_photo_url.validator = bv.String()
SetProfilePhotoResult._all_field_names_ = set(["profile_photo_url"])
SetProfilePhotoResult._all_fields_ = [
    ("profile_photo_url", SetProfilePhotoResult.profile_photo_url.validator)
]

ThumbnailError._permanent_failure_validator = bv.Void()
ThumbnailError._temporary_failure_validator = bv.Void()
ThumbnailError._other_validator = bv.Void()
ThumbnailError._tagmap = {
    "permanent_failure": ThumbnailError._permanent_failure_validator,
    "temporary_failure": ThumbnailError._temporary_failure_validator,
    "other": ThumbnailError._other_validator,
}

ThumbnailError.permanent_failure = ThumbnailError("permanent_failure")
ThumbnailError.temporary_failure = ThumbnailError("temporary_failure")
ThumbnailError.other = ThumbnailError("other")

delete_profile_photo = bb.Route(
    "delete_profile_photo",
    1,
    False,
    DeleteProfilePhotoArg_validator,
    DeleteProfilePhotoResult_validator,
    DeleteProfilePhotoError_validator,
    {"auth": "user", "host": "api", "style": "rpc"},
)
get_photo = bb.Route(
    "get_photo",
    1,
    False,
    AccountPhotoGetArg_validator,
    AccountPhotoGetResult_validator,
    AccountPhotoGetError_validator,
    {"auth": "user", "host": "content", "style": "download"},
)
set_profile_photo = bb.Route(
    "set_profile_photo",
    1,
    False,
    SetProfilePhotoArg_validator,
    SetProfilePhotoResult_validator,
    SetProfilePhotoError_validator,
    {"auth": "user", "host": "api", "style": "rpc"},
)

ROUTES = {
    "delete_profile_photo": delete_profile_photo,
    "get_photo": get_photo,
    "set_profile_photo": set_profile_photo,
}
