Skip to content

Commit 6289b86

Browse files
author
Brad Rogers
committed
Spec Update
1 parent fdeb3c5 commit 6289b86

19 files changed

+66129
-38326
lines changed

dropbox/account.py

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
# -*- coding: utf-8 -*-
2+
# Auto-generated by Stone, do not modify.
3+
# @generated
4+
# flake8: noqa
5+
# pylint: skip-file
6+
try:
7+
from . import stone_validators as bv
8+
from . import stone_base as bb
9+
except (ImportError, SystemError, ValueError):
10+
# Catch errors raised when importing a relative module when not in a package.
11+
# This makes testing this file directly (outside of a package) easier.
12+
import stone_validators as bv
13+
import stone_base as bb
14+
15+
class PhotoSourceArg(bb.Union):
16+
"""
17+
This class acts as a tagged union. Only one of the ``is_*`` methods will
18+
return true. To get the associated value of a tag (if one exists), use the
19+
corresponding ``get_*`` method.
20+
21+
:ivar str account.PhotoSourceArg.base64_data: Image data in base64-encoded
22+
bytes.
23+
"""
24+
25+
_catch_all = 'other'
26+
# Attribute is overwritten below the class definition
27+
other = None
28+
29+
@classmethod
30+
def base64_data(cls, val):
31+
"""
32+
Create an instance of this class set to the ``base64_data`` tag with
33+
value ``val``.
34+
35+
:param str val:
36+
:rtype: PhotoSourceArg
37+
"""
38+
return cls('base64_data', val)
39+
40+
def is_base64_data(self):
41+
"""
42+
Check if the union tag is ``base64_data``.
43+
44+
:rtype: bool
45+
"""
46+
return self._tag == 'base64_data'
47+
48+
def is_other(self):
49+
"""
50+
Check if the union tag is ``other``.
51+
52+
:rtype: bool
53+
"""
54+
return self._tag == 'other'
55+
56+
def get_base64_data(self):
57+
"""
58+
Image data in base64-encoded bytes.
59+
60+
Only call this if :meth:`is_base64_data` is true.
61+
62+
:rtype: str
63+
"""
64+
if not self.is_base64_data():
65+
raise AttributeError("tag 'base64_data' not set")
66+
return self._value
67+
68+
def _process_custom_annotations(self, annotation_type, field_path, processor):
69+
super(PhotoSourceArg, self)._process_custom_annotations(annotation_type, field_path, processor)
70+
71+
def __repr__(self):
72+
return 'PhotoSourceArg(%r, %r)' % (self._tag, self._value)
73+
74+
PhotoSourceArg_validator = bv.Union(PhotoSourceArg)
75+
76+
class SetProfilePhotoArg(bb.Struct):
77+
"""
78+
:ivar account.SetProfilePhotoArg.photo: Image to set as the user's new
79+
profile photo.
80+
"""
81+
82+
__slots__ = [
83+
'_photo_value',
84+
'_photo_present',
85+
]
86+
87+
_has_required_fields = True
88+
89+
def __init__(self,
90+
photo=None):
91+
self._photo_value = None
92+
self._photo_present = False
93+
if photo is not None:
94+
self.photo = photo
95+
96+
@property
97+
def photo(self):
98+
"""
99+
Image to set as the user's new profile photo.
100+
101+
:rtype: PhotoSourceArg
102+
"""
103+
if self._photo_present:
104+
return self._photo_value
105+
else:
106+
raise AttributeError("missing required field 'photo'")
107+
108+
@photo.setter
109+
def photo(self, val):
110+
self._photo_validator.validate_type_only(val)
111+
self._photo_value = val
112+
self._photo_present = True
113+
114+
@photo.deleter
115+
def photo(self):
116+
self._photo_value = None
117+
self._photo_present = False
118+
119+
def _process_custom_annotations(self, annotation_type, field_path, processor):
120+
super(SetProfilePhotoArg, self)._process_custom_annotations(annotation_type, field_path, processor)
121+
122+
def __repr__(self):
123+
return 'SetProfilePhotoArg(photo={!r})'.format(
124+
self._photo_value,
125+
)
126+
127+
SetProfilePhotoArg_validator = bv.Struct(SetProfilePhotoArg)
128+
129+
class SetProfilePhotoError(bb.Union):
130+
"""
131+
This class acts as a tagged union. Only one of the ``is_*`` methods will
132+
return true. To get the associated value of a tag (if one exists), use the
133+
corresponding ``get_*`` method.
134+
135+
:ivar account.SetProfilePhotoError.file_type_error: File cannot be set as
136+
profile photo.
137+
:ivar account.SetProfilePhotoError.file_size_error: File cannot exceed 10
138+
MB.
139+
:ivar account.SetProfilePhotoError.dimension_error: Image must be larger
140+
than 128 x 128.
141+
:ivar account.SetProfilePhotoError.thumbnail_error: Image could not be
142+
thumbnailed.
143+
:ivar account.SetProfilePhotoError.transient_error: Temporary infrastructure
144+
failure, please retry.
145+
"""
146+
147+
_catch_all = 'other'
148+
# Attribute is overwritten below the class definition
149+
file_type_error = None
150+
# Attribute is overwritten below the class definition
151+
file_size_error = None
152+
# Attribute is overwritten below the class definition
153+
dimension_error = None
154+
# Attribute is overwritten below the class definition
155+
thumbnail_error = None
156+
# Attribute is overwritten below the class definition
157+
transient_error = None
158+
# Attribute is overwritten below the class definition
159+
other = None
160+
161+
def is_file_type_error(self):
162+
"""
163+
Check if the union tag is ``file_type_error``.
164+
165+
:rtype: bool
166+
"""
167+
return self._tag == 'file_type_error'
168+
169+
def is_file_size_error(self):
170+
"""
171+
Check if the union tag is ``file_size_error``.
172+
173+
:rtype: bool
174+
"""
175+
return self._tag == 'file_size_error'
176+
177+
def is_dimension_error(self):
178+
"""
179+
Check if the union tag is ``dimension_error``.
180+
181+
:rtype: bool
182+
"""
183+
return self._tag == 'dimension_error'
184+
185+
def is_thumbnail_error(self):
186+
"""
187+
Check if the union tag is ``thumbnail_error``.
188+
189+
:rtype: bool
190+
"""
191+
return self._tag == 'thumbnail_error'
192+
193+
def is_transient_error(self):
194+
"""
195+
Check if the union tag is ``transient_error``.
196+
197+
:rtype: bool
198+
"""
199+
return self._tag == 'transient_error'
200+
201+
def is_other(self):
202+
"""
203+
Check if the union tag is ``other``.
204+
205+
:rtype: bool
206+
"""
207+
return self._tag == 'other'
208+
209+
def _process_custom_annotations(self, annotation_type, field_path, processor):
210+
super(SetProfilePhotoError, self)._process_custom_annotations(annotation_type, field_path, processor)
211+
212+
def __repr__(self):
213+
return 'SetProfilePhotoError(%r, %r)' % (self._tag, self._value)
214+
215+
SetProfilePhotoError_validator = bv.Union(SetProfilePhotoError)
216+
217+
class SetProfilePhotoResult(bb.Struct):
218+
"""
219+
:ivar account.SetProfilePhotoResult.profile_photo_url: URL for the photo
220+
representing the user, if one is set.
221+
"""
222+
223+
__slots__ = [
224+
'_profile_photo_url_value',
225+
'_profile_photo_url_present',
226+
]
227+
228+
_has_required_fields = True
229+
230+
def __init__(self,
231+
profile_photo_url=None):
232+
self._profile_photo_url_value = None
233+
self._profile_photo_url_present = False
234+
if profile_photo_url is not None:
235+
self.profile_photo_url = profile_photo_url
236+
237+
@property
238+
def profile_photo_url(self):
239+
"""
240+
URL for the photo representing the user, if one is set.
241+
242+
:rtype: str
243+
"""
244+
if self._profile_photo_url_present:
245+
return self._profile_photo_url_value
246+
else:
247+
raise AttributeError("missing required field 'profile_photo_url'")
248+
249+
@profile_photo_url.setter
250+
def profile_photo_url(self, val):
251+
val = self._profile_photo_url_validator.validate(val)
252+
self._profile_photo_url_value = val
253+
self._profile_photo_url_present = True
254+
255+
@profile_photo_url.deleter
256+
def profile_photo_url(self):
257+
self._profile_photo_url_value = None
258+
self._profile_photo_url_present = False
259+
260+
def _process_custom_annotations(self, annotation_type, field_path, processor):
261+
super(SetProfilePhotoResult, self)._process_custom_annotations(annotation_type, field_path, processor)
262+
263+
def __repr__(self):
264+
return 'SetProfilePhotoResult(profile_photo_url={!r})'.format(
265+
self._profile_photo_url_value,
266+
)
267+
268+
SetProfilePhotoResult_validator = bv.Struct(SetProfilePhotoResult)
269+
270+
PhotoSourceArg._base64_data_validator = bv.String()
271+
PhotoSourceArg._other_validator = bv.Void()
272+
PhotoSourceArg._tagmap = {
273+
'base64_data': PhotoSourceArg._base64_data_validator,
274+
'other': PhotoSourceArg._other_validator,
275+
}
276+
277+
PhotoSourceArg.other = PhotoSourceArg('other')
278+
279+
SetProfilePhotoArg._photo_validator = PhotoSourceArg_validator
280+
SetProfilePhotoArg._all_field_names_ = set(['photo'])
281+
SetProfilePhotoArg._all_fields_ = [('photo', SetProfilePhotoArg._photo_validator)]
282+
283+
SetProfilePhotoError._file_type_error_validator = bv.Void()
284+
SetProfilePhotoError._file_size_error_validator = bv.Void()
285+
SetProfilePhotoError._dimension_error_validator = bv.Void()
286+
SetProfilePhotoError._thumbnail_error_validator = bv.Void()
287+
SetProfilePhotoError._transient_error_validator = bv.Void()
288+
SetProfilePhotoError._other_validator = bv.Void()
289+
SetProfilePhotoError._tagmap = {
290+
'file_type_error': SetProfilePhotoError._file_type_error_validator,
291+
'file_size_error': SetProfilePhotoError._file_size_error_validator,
292+
'dimension_error': SetProfilePhotoError._dimension_error_validator,
293+
'thumbnail_error': SetProfilePhotoError._thumbnail_error_validator,
294+
'transient_error': SetProfilePhotoError._transient_error_validator,
295+
'other': SetProfilePhotoError._other_validator,
296+
}
297+
298+
SetProfilePhotoError.file_type_error = SetProfilePhotoError('file_type_error')
299+
SetProfilePhotoError.file_size_error = SetProfilePhotoError('file_size_error')
300+
SetProfilePhotoError.dimension_error = SetProfilePhotoError('dimension_error')
301+
SetProfilePhotoError.thumbnail_error = SetProfilePhotoError('thumbnail_error')
302+
SetProfilePhotoError.transient_error = SetProfilePhotoError('transient_error')
303+
SetProfilePhotoError.other = SetProfilePhotoError('other')
304+
305+
SetProfilePhotoResult._profile_photo_url_validator = bv.String()
306+
SetProfilePhotoResult._all_field_names_ = set(['profile_photo_url'])
307+
SetProfilePhotoResult._all_fields_ = [('profile_photo_url', SetProfilePhotoResult._profile_photo_url_validator)]
308+
309+
set_profile_photo = bb.Route(
310+
'set_profile_photo',
311+
1,
312+
False,
313+
SetProfilePhotoArg_validator,
314+
SetProfilePhotoResult_validator,
315+
SetProfilePhotoError_validator,
316+
{'host': u'api',
317+
'style': u'rpc'},
318+
)
319+
320+
ROUTES = {
321+
'set_profile_photo': set_profile_photo,
322+
}
323+

dropbox/auth.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class AuthError(bb.Union):
126126
:ivar auth.AuthError.expired_access_token: The access token has expired.
127127
:ivar TokenScopeError AuthError.missing_scope: The access token does not
128128
have the required scope to access the route.
129+
:ivar auth.AuthError.route_access_denied: The route is not available to
130+
public.
129131
"""
130132

131133
_catch_all = 'other'
@@ -140,6 +142,8 @@ class AuthError(bb.Union):
140142
# Attribute is overwritten below the class definition
141143
expired_access_token = None
142144
# Attribute is overwritten below the class definition
145+
route_access_denied = None
146+
# Attribute is overwritten below the class definition
143147
other = None
144148

145149
@classmethod
@@ -201,6 +205,14 @@ def is_missing_scope(self):
201205
"""
202206
return self._tag == 'missing_scope'
203207

208+
def is_route_access_denied(self):
209+
"""
210+
Check if the union tag is ``route_access_denied``.
211+
212+
:rtype: bool
213+
"""
214+
return self._tag == 'route_access_denied'
215+
204216
def is_other(self):
205217
"""
206218
Check if the union tag is ``other``.
@@ -734,6 +746,7 @@ def __repr__(self):
734746
AuthError._user_suspended_validator = bv.Void()
735747
AuthError._expired_access_token_validator = bv.Void()
736748
AuthError._missing_scope_validator = TokenScopeError_validator
749+
AuthError._route_access_denied_validator = bv.Void()
737750
AuthError._other_validator = bv.Void()
738751
AuthError._tagmap = {
739752
'invalid_access_token': AuthError._invalid_access_token_validator,
@@ -742,6 +755,7 @@ def __repr__(self):
742755
'user_suspended': AuthError._user_suspended_validator,
743756
'expired_access_token': AuthError._expired_access_token_validator,
744757
'missing_scope': AuthError._missing_scope_validator,
758+
'route_access_denied': AuthError._route_access_denied_validator,
745759
'other': AuthError._other_validator,
746760
}
747761

@@ -750,6 +764,7 @@ def __repr__(self):
750764
AuthError.invalid_select_admin = AuthError('invalid_select_admin')
751765
AuthError.user_suspended = AuthError('user_suspended')
752766
AuthError.expired_access_token = AuthError('expired_access_token')
767+
AuthError.route_access_denied = AuthError('route_access_denied')
753768
AuthError.other = AuthError('other')
754769

755770
InvalidAccountTypeError._endpoint_validator = bv.Void()

0 commit comments

Comments
 (0)