@@ -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
632665TokenFromOAuth1Result_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+
634720AccessError ._invalid_account_type_validator = InvalidAccountTypeError_validator
635721AccessError ._paper_access_denied_validator = PaperAccessError_validator
636722AccessError ._other_validator = bv .Void ()
@@ -647,13 +733,15 @@ def __repr__(self):
647733AuthError ._invalid_select_admin_validator = bv .Void ()
648734AuthError ._user_suspended_validator = bv .Void ()
649735AuthError ._expired_access_token_validator = bv .Void ()
736+ AuthError ._missing_scope_validator = TokenScopeError_validator
650737AuthError ._other_validator = bv .Void ()
651738AuthError ._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):
742830TokenFromOAuth1Result ._all_field_names_ = set (['oauth2_token' ])
743831TokenFromOAuth1Result ._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+
745837token_from_oauth1 = bb .Route (
746838 'token/from_oauth1' ,
747839 1 ,
0 commit comments