Skip to content

Commit a58eb06

Browse files
committed
Updated spec
1 parent 287bdf7 commit a58eb06

21 files changed

+30000
-18533
lines changed

dropbox/async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# flake8: noqa
55
# pylint: skip-file
66
# If you have issues importing this module because Python recognizes it as a keyword, use async_ instead.
7-
from async_ import *
7+
from .async_ import *

dropbox/async_.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def async_job_id(cls, val):
3838
value ``val``.
3939
4040
:param str val:
41-
:rtype: async_.LaunchResultBase
41+
:rtype: LaunchResultBase
4242
"""
4343
return cls('async_job_id', val)
4444

@@ -63,8 +63,8 @@ def get_async_job_id(self):
6363
raise AttributeError("tag 'async_job_id' not set")
6464
return self._value
6565

66-
def _process_custom_annotations(self, annotation_type, processor):
67-
super(LaunchResultBase, self)._process_custom_annotations(annotation_type, processor)
66+
def _process_custom_annotations(self, annotation_type, field_path, processor):
67+
super(LaunchResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)
6868

6969
def __repr__(self):
7070
return 'LaunchResultBase(%r, %r)' % (self._tag, self._value)
@@ -96,8 +96,8 @@ def is_complete(self):
9696
"""
9797
return self._tag == 'complete'
9898

99-
def _process_custom_annotations(self, annotation_type, processor):
100-
super(LaunchEmptyResult, self)._process_custom_annotations(annotation_type, processor)
99+
def _process_custom_annotations(self, annotation_type, field_path, processor):
100+
super(LaunchEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)
101101

102102
def __repr__(self):
103103
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)
@@ -150,8 +150,8 @@ def async_job_id(self):
150150
self._async_job_id_value = None
151151
self._async_job_id_present = False
152152

153-
def _process_custom_annotations(self, annotation_type, processor):
154-
super(PollArg, self)._process_custom_annotations(annotation_type, processor)
153+
def _process_custom_annotations(self, annotation_type, field_path, processor):
154+
super(PollArg, self)._process_custom_annotations(annotation_type, field_path, processor)
155155

156156
def __repr__(self):
157157
return 'PollArg(async_job_id={!r})'.format(
@@ -187,8 +187,8 @@ def is_in_progress(self):
187187
"""
188188
return self._tag == 'in_progress'
189189

190-
def _process_custom_annotations(self, annotation_type, processor):
191-
super(PollResultBase, self)._process_custom_annotations(annotation_type, processor)
190+
def _process_custom_annotations(self, annotation_type, field_path, processor):
191+
super(PollResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)
192192

193193
def __repr__(self):
194194
return 'PollResultBase(%r, %r)' % (self._tag, self._value)
@@ -219,8 +219,8 @@ def is_complete(self):
219219
"""
220220
return self._tag == 'complete'
221221

222-
def _process_custom_annotations(self, annotation_type, processor):
223-
super(PollEmptyResult, self)._process_custom_annotations(annotation_type, processor)
222+
def _process_custom_annotations(self, annotation_type, field_path, processor):
223+
super(PollEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)
224224

225225
def __repr__(self):
226226
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)
@@ -273,8 +273,8 @@ def is_other(self):
273273
"""
274274
return self._tag == 'other'
275275

276-
def _process_custom_annotations(self, annotation_type, processor):
277-
super(PollError, self)._process_custom_annotations(annotation_type, processor)
276+
def _process_custom_annotations(self, annotation_type, field_path, processor):
277+
super(PollError, self)._process_custom_annotations(annotation_type, field_path, processor)
278278

279279
def __repr__(self):
280280
return 'PollError(%r, %r)' % (self._tag, self._value)

dropbox/auth.py

Lines changed: 119 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class AccessError(bb.Union):
2121
return true. To get the associated value of a tag (if one exists), use the
2222
corresponding ``get_*`` method.
2323
24-
:ivar InvalidAccountTypeError auth.AccessError.invalid_account_type: Current
24+
:ivar InvalidAccountTypeError AccessError.invalid_account_type: Current
2525
account type cannot access the resource.
26-
:ivar PaperAccessError auth.AccessError.paper_access_denied: Current account
26+
:ivar PaperAccessError AccessError.paper_access_denied: Current account
2727
cannot access Paper.
2828
"""
2929

@@ -37,8 +37,8 @@ def invalid_account_type(cls, val):
3737
Create an instance of this class set to the ``invalid_account_type`` tag
3838
with value ``val``.
3939
40-
:param auth.InvalidAccountTypeError val:
41-
:rtype: auth.AccessError
40+
:param InvalidAccountTypeError val:
41+
:rtype: AccessError
4242
"""
4343
return cls('invalid_account_type', val)
4444

@@ -48,8 +48,8 @@ def paper_access_denied(cls, val):
4848
Create an instance of this class set to the ``paper_access_denied`` tag
4949
with value ``val``.
5050
51-
:param auth.PaperAccessError val:
52-
:rtype: auth.AccessError
51+
:param PaperAccessError val:
52+
:rtype: AccessError
5353
"""
5454
return cls('paper_access_denied', val)
5555

@@ -83,7 +83,7 @@ def get_invalid_account_type(self):
8383
8484
Only call this if :meth:`is_invalid_account_type` is true.
8585
86-
:rtype: auth.InvalidAccountTypeError
86+
:rtype: InvalidAccountTypeError
8787
"""
8888
if not self.is_invalid_account_type():
8989
raise AttributeError("tag 'invalid_account_type' not set")
@@ -95,14 +95,14 @@ def get_paper_access_denied(self):
9595
9696
Only call this if :meth:`is_paper_access_denied` is true.
9797
98-
:rtype: auth.PaperAccessError
98+
:rtype: PaperAccessError
9999
"""
100100
if not self.is_paper_access_denied():
101101
raise AttributeError("tag 'paper_access_denied' not set")
102102
return self._value
103103

104-
def _process_custom_annotations(self, annotation_type, processor):
105-
super(AccessError, self)._process_custom_annotations(annotation_type, processor)
104+
def _process_custom_annotations(self, annotation_type, field_path, processor):
105+
super(AccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
106106

107107
def __repr__(self):
108108
return 'AccessError(%r, %r)' % (self._tag, self._value)
@@ -124,6 +124,8 @@ class AuthError(bb.Union):
124124
'Dropbox-API-Select-Admin' is not a Dropbox Business team admin.
125125
:ivar auth.AuthError.user_suspended: The user has been suspended.
126126
:ivar auth.AuthError.expired_access_token: The access token has expired.
127+
:ivar TokenScopeError AuthError.missing_scope: The access token does not
128+
have the required scope to access the route.
127129
"""
128130

129131
_catch_all = 'other'
@@ -140,6 +142,17 @@ class AuthError(bb.Union):
140142
# Attribute is overwritten below the class definition
141143
other = None
142144

145+
@classmethod
146+
def missing_scope(cls, val):
147+
"""
148+
Create an instance of this class set to the ``missing_scope`` tag with
149+
value ``val``.
150+
151+
:param TokenScopeError val:
152+
:rtype: AuthError
153+
"""
154+
return cls('missing_scope', val)
155+
143156
def is_invalid_access_token(self):
144157
"""
145158
Check if the union tag is ``invalid_access_token``.
@@ -180,6 +193,14 @@ def is_expired_access_token(self):
180193
"""
181194
return self._tag == 'expired_access_token'
182195

196+
def is_missing_scope(self):
197+
"""
198+
Check if the union tag is ``missing_scope``.
199+
200+
:rtype: bool
201+
"""
202+
return self._tag == 'missing_scope'
203+
183204
def is_other(self):
184205
"""
185206
Check if the union tag is ``other``.
@@ -188,8 +209,20 @@ def is_other(self):
188209
"""
189210
return self._tag == 'other'
190211

191-
def _process_custom_annotations(self, annotation_type, processor):
192-
super(AuthError, self)._process_custom_annotations(annotation_type, processor)
212+
def get_missing_scope(self):
213+
"""
214+
The access token does not have the required scope to access the route.
215+
216+
Only call this if :meth:`is_missing_scope` is true.
217+
218+
:rtype: TokenScopeError
219+
"""
220+
if not self.is_missing_scope():
221+
raise AttributeError("tag 'missing_scope' not set")
222+
return self._value
223+
224+
def _process_custom_annotations(self, annotation_type, field_path, processor):
225+
super(AuthError, self)._process_custom_annotations(annotation_type, field_path, processor)
193226

194227
def __repr__(self):
195228
return 'AuthError(%r, %r)' % (self._tag, self._value)
@@ -240,8 +273,8 @@ def is_other(self):
240273
"""
241274
return self._tag == 'other'
242275

243-
def _process_custom_annotations(self, annotation_type, processor):
244-
super(InvalidAccountTypeError, self)._process_custom_annotations(annotation_type, processor)
276+
def _process_custom_annotations(self, annotation_type, field_path, processor):
277+
super(InvalidAccountTypeError, self)._process_custom_annotations(annotation_type, field_path, processor)
245278

246279
def __repr__(self):
247280
return 'InvalidAccountTypeError(%r, %r)' % (self._tag, self._value)
@@ -291,8 +324,8 @@ def is_other(self):
291324
"""
292325
return self._tag == 'other'
293326

294-
def _process_custom_annotations(self, annotation_type, processor):
295-
super(PaperAccessError, self)._process_custom_annotations(annotation_type, processor)
327+
def _process_custom_annotations(self, annotation_type, field_path, processor):
328+
super(PaperAccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
296329

297330
def __repr__(self):
298331
return 'PaperAccessError(%r, %r)' % (self._tag, self._value)
@@ -335,7 +368,7 @@ def reason(self):
335368
"""
336369
The reason why the app is being rate limited.
337370
338-
:rtype: auth.RateLimitReason
371+
:rtype: RateLimitReason
339372
"""
340373
if self._reason_present:
341374
return self._reason_value
@@ -377,8 +410,8 @@ def retry_after(self):
377410
self._retry_after_value = None
378411
self._retry_after_present = False
379412

380-
def _process_custom_annotations(self, annotation_type, processor):
381-
super(RateLimitError, self)._process_custom_annotations(annotation_type, processor)
413+
def _process_custom_annotations(self, annotation_type, field_path, processor):
414+
super(RateLimitError, self)._process_custom_annotations(annotation_type, field_path, processor)
382415

383416
def __repr__(self):
384417
return 'RateLimitError(reason={!r}, retry_after={!r})'.format(
@@ -432,8 +465,8 @@ def is_other(self):
432465
"""
433466
return self._tag == 'other'
434467

435-
def _process_custom_annotations(self, annotation_type, processor):
436-
super(RateLimitReason, self)._process_custom_annotations(annotation_type, processor)
468+
def _process_custom_annotations(self, annotation_type, field_path, processor):
469+
super(RateLimitReason, self)._process_custom_annotations(annotation_type, field_path, processor)
437470

438471
def __repr__(self):
439472
return 'RateLimitReason(%r, %r)' % (self._tag, self._value)
@@ -515,8 +548,8 @@ def oauth1_token_secret(self):
515548
self._oauth1_token_secret_value = None
516549
self._oauth1_token_secret_present = False
517550

518-
def _process_custom_annotations(self, annotation_type, processor):
519-
super(TokenFromOAuth1Arg, self)._process_custom_annotations(annotation_type, processor)
551+
def _process_custom_annotations(self, annotation_type, field_path, processor):
552+
super(TokenFromOAuth1Arg, self)._process_custom_annotations(annotation_type, field_path, processor)
520553

521554
def __repr__(self):
522555
return 'TokenFromOAuth1Arg(oauth1_token={!r}, oauth1_token_secret={!r})'.format(
@@ -570,8 +603,8 @@ def is_other(self):
570603
"""
571604
return self._tag == 'other'
572605

573-
def _process_custom_annotations(self, annotation_type, processor):
574-
super(TokenFromOAuth1Error, self)._process_custom_annotations(annotation_type, processor)
606+
def _process_custom_annotations(self, annotation_type, field_path, processor):
607+
super(TokenFromOAuth1Error, self)._process_custom_annotations(annotation_type, field_path, processor)
575608

576609
def __repr__(self):
577610
return 'TokenFromOAuth1Error(%r, %r)' % (self._tag, self._value)
@@ -621,8 +654,8 @@ def oauth2_token(self):
621654
self._oauth2_token_value = None
622655
self._oauth2_token_present = False
623656

624-
def _process_custom_annotations(self, annotation_type, processor):
625-
super(TokenFromOAuth1Result, self)._process_custom_annotations(annotation_type, processor)
657+
def _process_custom_annotations(self, annotation_type, field_path, processor):
658+
super(TokenFromOAuth1Result, self)._process_custom_annotations(annotation_type, field_path, processor)
626659

627660
def __repr__(self):
628661
return 'TokenFromOAuth1Result(oauth2_token={!r})'.format(
@@ -631,6 +664,59 @@ def __repr__(self):
631664

632665
TokenFromOAuth1Result_validator = bv.Struct(TokenFromOAuth1Result)
633666

667+
class TokenScopeError(bb.Struct):
668+
"""
669+
:ivar auth.TokenScopeError.required_scope: The required scope to access the
670+
route.
671+
"""
672+
673+
__slots__ = [
674+
'_required_scope_value',
675+
'_required_scope_present',
676+
]
677+
678+
_has_required_fields = True
679+
680+
def __init__(self,
681+
required_scope=None):
682+
self._required_scope_value = None
683+
self._required_scope_present = False
684+
if required_scope is not None:
685+
self.required_scope = required_scope
686+
687+
@property
688+
def required_scope(self):
689+
"""
690+
The required scope to access the route.
691+
692+
:rtype: str
693+
"""
694+
if self._required_scope_present:
695+
return self._required_scope_value
696+
else:
697+
raise AttributeError("missing required field 'required_scope'")
698+
699+
@required_scope.setter
700+
def required_scope(self, val):
701+
val = self._required_scope_validator.validate(val)
702+
self._required_scope_value = val
703+
self._required_scope_present = True
704+
705+
@required_scope.deleter
706+
def required_scope(self):
707+
self._required_scope_value = None
708+
self._required_scope_present = False
709+
710+
def _process_custom_annotations(self, annotation_type, field_path, processor):
711+
super(TokenScopeError, self)._process_custom_annotations(annotation_type, field_path, processor)
712+
713+
def __repr__(self):
714+
return 'TokenScopeError(required_scope={!r})'.format(
715+
self._required_scope_value,
716+
)
717+
718+
TokenScopeError_validator = bv.Struct(TokenScopeError)
719+
634720
AccessError._invalid_account_type_validator = InvalidAccountTypeError_validator
635721
AccessError._paper_access_denied_validator = PaperAccessError_validator
636722
AccessError._other_validator = bv.Void()
@@ -647,13 +733,15 @@ def __repr__(self):
647733
AuthError._invalid_select_admin_validator = bv.Void()
648734
AuthError._user_suspended_validator = bv.Void()
649735
AuthError._expired_access_token_validator = bv.Void()
736+
AuthError._missing_scope_validator = TokenScopeError_validator
650737
AuthError._other_validator = bv.Void()
651738
AuthError._tagmap = {
652739
'invalid_access_token': AuthError._invalid_access_token_validator,
653740
'invalid_select_user': AuthError._invalid_select_user_validator,
654741
'invalid_select_admin': AuthError._invalid_select_admin_validator,
655742
'user_suspended': AuthError._user_suspended_validator,
656743
'expired_access_token': AuthError._expired_access_token_validator,
744+
'missing_scope': AuthError._missing_scope_validator,
657745
'other': AuthError._other_validator,
658746
}
659747

@@ -742,6 +830,10 @@ def __repr__(self):
742830
TokenFromOAuth1Result._all_field_names_ = set(['oauth2_token'])
743831
TokenFromOAuth1Result._all_fields_ = [('oauth2_token', TokenFromOAuth1Result._oauth2_token_validator)]
744832

833+
TokenScopeError._required_scope_validator = bv.String()
834+
TokenScopeError._all_field_names_ = set(['required_scope'])
835+
TokenScopeError._all_fields_ = [('required_scope', TokenScopeError._required_scope_validator)]
836+
745837
token_from_oauth1 = bb.Route(
746838
'token/from_oauth1',
747839
1,

0 commit comments

Comments
 (0)