1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
# -*- 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 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 str account.PhotoSourceArg.base64_data: Image data in base64-encoded
bytes.
"""
_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 account.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 account.SetProfilePhotoError.file_type_error: File cannot be set as
profile photo.
:ivar account.SetProfilePhotoError.file_size_error: File cannot exceed 10
MB.
:ivar account.SetProfilePhotoError.dimension_error: Image must be larger
than 128 x 128.
:ivar account.SetProfilePhotoError.thumbnail_error: Image could not be
thumbnailed.
:ivar account.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 account.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)
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)]
set_profile_photo = bb.Route(
'set_profile_photo',
1,
False,
SetProfilePhotoArg_validator,
SetProfilePhotoResult_validator,
SetProfilePhotoError_validator,
{'auth': 'user',
'host': 'api',
'style': 'rpc'},
)
ROUTES = {
'set_profile_photo': set_profile_photo,
}
|