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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
|
# -*- 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 AccessError(bb.Union):
"""
Error occurred because the account doesn't have permission to access the
resource.
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 InvalidAccountTypeError AccessError.invalid_account_type: Current
account type cannot access the resource.
:ivar PaperAccessError AccessError.paper_access_denied: Current account
cannot access Paper.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
other = None
@classmethod
def invalid_account_type(cls, val):
"""
Create an instance of this class set to the ``invalid_account_type`` tag
with value ``val``.
:param InvalidAccountTypeError val:
:rtype: AccessError
"""
return cls('invalid_account_type', val)
@classmethod
def paper_access_denied(cls, val):
"""
Create an instance of this class set to the ``paper_access_denied`` tag
with value ``val``.
:param PaperAccessError val:
:rtype: AccessError
"""
return cls('paper_access_denied', val)
def is_invalid_account_type(self):
"""
Check if the union tag is ``invalid_account_type``.
:rtype: bool
"""
return self._tag == 'invalid_account_type'
def is_paper_access_denied(self):
"""
Check if the union tag is ``paper_access_denied``.
:rtype: bool
"""
return self._tag == 'paper_access_denied'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def get_invalid_account_type(self):
"""
Current account type cannot access the resource.
Only call this if :meth:`is_invalid_account_type` is true.
:rtype: InvalidAccountTypeError
"""
if not self.is_invalid_account_type():
raise AttributeError("tag 'invalid_account_type' not set")
return self._value
def get_paper_access_denied(self):
"""
Current account cannot access Paper.
Only call this if :meth:`is_paper_access_denied` is true.
:rtype: PaperAccessError
"""
if not self.is_paper_access_denied():
raise AttributeError("tag 'paper_access_denied' not set")
return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(AccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
AccessError_validator = bv.Union(AccessError)
class AuthError(bb.Union):
"""
Errors occurred during authentication.
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 auth.AuthError.invalid_access_token: The access token is invalid.
:ivar auth.AuthError.invalid_select_user: The user specified in
'Dropbox-API-Select-User' is no longer on the team.
:ivar auth.AuthError.invalid_select_admin: The user specified in
'Dropbox-API-Select-Admin' is not a Dropbox Business team admin.
:ivar auth.AuthError.user_suspended: The user has been suspended.
:ivar auth.AuthError.expired_access_token: The access token has expired.
:ivar TokenScopeError AuthError.missing_scope: The access token does not
have the required scope to access the route.
:ivar auth.AuthError.route_access_denied: The route is not available to
public.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_access_token = None
# Attribute is overwritten below the class definition
invalid_select_user = None
# Attribute is overwritten below the class definition
invalid_select_admin = None
# Attribute is overwritten below the class definition
user_suspended = None
# Attribute is overwritten below the class definition
expired_access_token = None
# Attribute is overwritten below the class definition
route_access_denied = None
# Attribute is overwritten below the class definition
other = None
@classmethod
def missing_scope(cls, val):
"""
Create an instance of this class set to the ``missing_scope`` tag with
value ``val``.
:param TokenScopeError val:
:rtype: AuthError
"""
return cls('missing_scope', val)
def is_invalid_access_token(self):
"""
Check if the union tag is ``invalid_access_token``.
:rtype: bool
"""
return self._tag == 'invalid_access_token'
def is_invalid_select_user(self):
"""
Check if the union tag is ``invalid_select_user``.
:rtype: bool
"""
return self._tag == 'invalid_select_user'
def is_invalid_select_admin(self):
"""
Check if the union tag is ``invalid_select_admin``.
:rtype: bool
"""
return self._tag == 'invalid_select_admin'
def is_user_suspended(self):
"""
Check if the union tag is ``user_suspended``.
:rtype: bool
"""
return self._tag == 'user_suspended'
def is_expired_access_token(self):
"""
Check if the union tag is ``expired_access_token``.
:rtype: bool
"""
return self._tag == 'expired_access_token'
def is_missing_scope(self):
"""
Check if the union tag is ``missing_scope``.
:rtype: bool
"""
return self._tag == 'missing_scope'
def is_route_access_denied(self):
"""
Check if the union tag is ``route_access_denied``.
:rtype: bool
"""
return self._tag == 'route_access_denied'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def get_missing_scope(self):
"""
The access token does not have the required scope to access the route.
Only call this if :meth:`is_missing_scope` is true.
:rtype: TokenScopeError
"""
if not self.is_missing_scope():
raise AttributeError("tag 'missing_scope' not set")
return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(AuthError, self)._process_custom_annotations(annotation_type, field_path, processor)
AuthError_validator = bv.Union(AuthError)
class InvalidAccountTypeError(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 auth.InvalidAccountTypeError.endpoint: Current account type doesn't
have permission to access this route endpoint.
:ivar auth.InvalidAccountTypeError.feature: Current account type doesn't
have permission to access this feature.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
endpoint = None
# Attribute is overwritten below the class definition
feature = None
# Attribute is overwritten below the class definition
other = None
def is_endpoint(self):
"""
Check if the union tag is ``endpoint``.
:rtype: bool
"""
return self._tag == 'endpoint'
def is_feature(self):
"""
Check if the union tag is ``feature``.
:rtype: bool
"""
return self._tag == 'feature'
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(InvalidAccountTypeError, self)._process_custom_annotations(annotation_type, field_path, processor)
InvalidAccountTypeError_validator = bv.Union(InvalidAccountTypeError)
class PaperAccessError(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 auth.PaperAccessError.paper_disabled: Paper is disabled.
:ivar auth.PaperAccessError.not_paper_user: The provided user has not used
Paper yet.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
paper_disabled = None
# Attribute is overwritten below the class definition
not_paper_user = None
# Attribute is overwritten below the class definition
other = None
def is_paper_disabled(self):
"""
Check if the union tag is ``paper_disabled``.
:rtype: bool
"""
return self._tag == 'paper_disabled'
def is_not_paper_user(self):
"""
Check if the union tag is ``not_paper_user``.
:rtype: bool
"""
return self._tag == 'not_paper_user'
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(PaperAccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
PaperAccessError_validator = bv.Union(PaperAccessError)
class RateLimitError(bb.Struct):
"""
Error occurred because the app is being rate limited.
:ivar auth.RateLimitError.reason: The reason why the app is being rate
limited.
:ivar auth.RateLimitError.retry_after: The number of seconds that the app
should wait before making another request.
"""
__slots__ = [
'_reason_value',
'_retry_after_value',
]
_has_required_fields = True
def __init__(self,
reason=None,
retry_after=None):
self._reason_value = bb.NOT_SET
self._retry_after_value = bb.NOT_SET
if reason is not None:
self.reason = reason
if retry_after is not None:
self.retry_after = retry_after
# Instance attribute type: RateLimitReason (validator is set below)
reason = bb.Attribute("reason", user_defined=True)
# Instance attribute type: int (validator is set below)
retry_after = bb.Attribute("retry_after")
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(RateLimitError, self)._process_custom_annotations(annotation_type, field_path, processor)
RateLimitError_validator = bv.Struct(RateLimitError)
class RateLimitReason(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 auth.RateLimitReason.too_many_requests: You are making too many
requests in the past few minutes.
:ivar auth.RateLimitReason.too_many_write_operations: There are currently
too many write operations happening in the user's Dropbox.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
too_many_requests = None
# Attribute is overwritten below the class definition
too_many_write_operations = None
# Attribute is overwritten below the class definition
other = None
def is_too_many_requests(self):
"""
Check if the union tag is ``too_many_requests``.
:rtype: bool
"""
return self._tag == 'too_many_requests'
def is_too_many_write_operations(self):
"""
Check if the union tag is ``too_many_write_operations``.
:rtype: bool
"""
return self._tag == 'too_many_write_operations'
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(RateLimitReason, self)._process_custom_annotations(annotation_type, field_path, processor)
RateLimitReason_validator = bv.Union(RateLimitReason)
class TokenFromOAuth1Arg(bb.Struct):
"""
:ivar auth.TokenFromOAuth1Arg.oauth1_token: The supplied OAuth 1.0 access
token.
:ivar auth.TokenFromOAuth1Arg.oauth1_token_secret: The token secret
associated with the supplied access token.
"""
__slots__ = [
'_oauth1_token_value',
'_oauth1_token_secret_value',
]
_has_required_fields = True
def __init__(self,
oauth1_token=None,
oauth1_token_secret=None):
self._oauth1_token_value = bb.NOT_SET
self._oauth1_token_secret_value = bb.NOT_SET
if oauth1_token is not None:
self.oauth1_token = oauth1_token
if oauth1_token_secret is not None:
self.oauth1_token_secret = oauth1_token_secret
# Instance attribute type: str (validator is set below)
oauth1_token = bb.Attribute("oauth1_token")
# Instance attribute type: str (validator is set below)
oauth1_token_secret = bb.Attribute("oauth1_token_secret")
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenFromOAuth1Arg, self)._process_custom_annotations(annotation_type, field_path, processor)
TokenFromOAuth1Arg_validator = bv.Struct(TokenFromOAuth1Arg)
class TokenFromOAuth1Error(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 auth.TokenFromOAuth1Error.invalid_oauth1_token_info: Part or all of
the OAuth 1.0 access token info is invalid.
:ivar auth.TokenFromOAuth1Error.app_id_mismatch: The authorized app does not
match the app associated with the supplied access token.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_oauth1_token_info = None
# Attribute is overwritten below the class definition
app_id_mismatch = None
# Attribute is overwritten below the class definition
other = None
def is_invalid_oauth1_token_info(self):
"""
Check if the union tag is ``invalid_oauth1_token_info``.
:rtype: bool
"""
return self._tag == 'invalid_oauth1_token_info'
def is_app_id_mismatch(self):
"""
Check if the union tag is ``app_id_mismatch``.
:rtype: bool
"""
return self._tag == 'app_id_mismatch'
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(TokenFromOAuth1Error, self)._process_custom_annotations(annotation_type, field_path, processor)
TokenFromOAuth1Error_validator = bv.Union(TokenFromOAuth1Error)
class TokenFromOAuth1Result(bb.Struct):
"""
:ivar auth.TokenFromOAuth1Result.oauth2_token: The OAuth 2.0 token generated
from the supplied OAuth 1.0 token.
"""
__slots__ = [
'_oauth2_token_value',
]
_has_required_fields = True
def __init__(self,
oauth2_token=None):
self._oauth2_token_value = bb.NOT_SET
if oauth2_token is not None:
self.oauth2_token = oauth2_token
# Instance attribute type: str (validator is set below)
oauth2_token = bb.Attribute("oauth2_token")
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenFromOAuth1Result, self)._process_custom_annotations(annotation_type, field_path, processor)
TokenFromOAuth1Result_validator = bv.Struct(TokenFromOAuth1Result)
class TokenScopeError(bb.Struct):
"""
:ivar auth.TokenScopeError.required_scope: The required scope to access the
route.
"""
__slots__ = [
'_required_scope_value',
]
_has_required_fields = True
def __init__(self,
required_scope=None):
self._required_scope_value = bb.NOT_SET
if required_scope is not None:
self.required_scope = required_scope
# Instance attribute type: str (validator is set below)
required_scope = bb.Attribute("required_scope")
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenScopeError, self)._process_custom_annotations(annotation_type, field_path, processor)
TokenScopeError_validator = bv.Struct(TokenScopeError)
AccessError._invalid_account_type_validator = InvalidAccountTypeError_validator
AccessError._paper_access_denied_validator = PaperAccessError_validator
AccessError._other_validator = bv.Void()
AccessError._tagmap = {
'invalid_account_type': AccessError._invalid_account_type_validator,
'paper_access_denied': AccessError._paper_access_denied_validator,
'other': AccessError._other_validator,
}
AccessError.other = AccessError('other')
AuthError._invalid_access_token_validator = bv.Void()
AuthError._invalid_select_user_validator = bv.Void()
AuthError._invalid_select_admin_validator = bv.Void()
AuthError._user_suspended_validator = bv.Void()
AuthError._expired_access_token_validator = bv.Void()
AuthError._missing_scope_validator = TokenScopeError_validator
AuthError._route_access_denied_validator = bv.Void()
AuthError._other_validator = bv.Void()
AuthError._tagmap = {
'invalid_access_token': AuthError._invalid_access_token_validator,
'invalid_select_user': AuthError._invalid_select_user_validator,
'invalid_select_admin': AuthError._invalid_select_admin_validator,
'user_suspended': AuthError._user_suspended_validator,
'expired_access_token': AuthError._expired_access_token_validator,
'missing_scope': AuthError._missing_scope_validator,
'route_access_denied': AuthError._route_access_denied_validator,
'other': AuthError._other_validator,
}
AuthError.invalid_access_token = AuthError('invalid_access_token')
AuthError.invalid_select_user = AuthError('invalid_select_user')
AuthError.invalid_select_admin = AuthError('invalid_select_admin')
AuthError.user_suspended = AuthError('user_suspended')
AuthError.expired_access_token = AuthError('expired_access_token')
AuthError.route_access_denied = AuthError('route_access_denied')
AuthError.other = AuthError('other')
InvalidAccountTypeError._endpoint_validator = bv.Void()
InvalidAccountTypeError._feature_validator = bv.Void()
InvalidAccountTypeError._other_validator = bv.Void()
InvalidAccountTypeError._tagmap = {
'endpoint': InvalidAccountTypeError._endpoint_validator,
'feature': InvalidAccountTypeError._feature_validator,
'other': InvalidAccountTypeError._other_validator,
}
InvalidAccountTypeError.endpoint = InvalidAccountTypeError('endpoint')
InvalidAccountTypeError.feature = InvalidAccountTypeError('feature')
InvalidAccountTypeError.other = InvalidAccountTypeError('other')
PaperAccessError._paper_disabled_validator = bv.Void()
PaperAccessError._not_paper_user_validator = bv.Void()
PaperAccessError._other_validator = bv.Void()
PaperAccessError._tagmap = {
'paper_disabled': PaperAccessError._paper_disabled_validator,
'not_paper_user': PaperAccessError._not_paper_user_validator,
'other': PaperAccessError._other_validator,
}
PaperAccessError.paper_disabled = PaperAccessError('paper_disabled')
PaperAccessError.not_paper_user = PaperAccessError('not_paper_user')
PaperAccessError.other = PaperAccessError('other')
RateLimitError.reason.validator = RateLimitReason_validator
RateLimitError.retry_after.validator = bv.UInt64()
RateLimitError._all_field_names_ = set([
'reason',
'retry_after',
])
RateLimitError._all_fields_ = [
('reason', RateLimitError.reason.validator),
('retry_after', RateLimitError.retry_after.validator),
]
RateLimitReason._too_many_requests_validator = bv.Void()
RateLimitReason._too_many_write_operations_validator = bv.Void()
RateLimitReason._other_validator = bv.Void()
RateLimitReason._tagmap = {
'too_many_requests': RateLimitReason._too_many_requests_validator,
'too_many_write_operations': RateLimitReason._too_many_write_operations_validator,
'other': RateLimitReason._other_validator,
}
RateLimitReason.too_many_requests = RateLimitReason('too_many_requests')
RateLimitReason.too_many_write_operations = RateLimitReason('too_many_write_operations')
RateLimitReason.other = RateLimitReason('other')
TokenFromOAuth1Arg.oauth1_token.validator = bv.String(min_length=1)
TokenFromOAuth1Arg.oauth1_token_secret.validator = bv.String(min_length=1)
TokenFromOAuth1Arg._all_field_names_ = set([
'oauth1_token',
'oauth1_token_secret',
])
TokenFromOAuth1Arg._all_fields_ = [
('oauth1_token', TokenFromOAuth1Arg.oauth1_token.validator),
('oauth1_token_secret', TokenFromOAuth1Arg.oauth1_token_secret.validator),
]
TokenFromOAuth1Error._invalid_oauth1_token_info_validator = bv.Void()
TokenFromOAuth1Error._app_id_mismatch_validator = bv.Void()
TokenFromOAuth1Error._other_validator = bv.Void()
TokenFromOAuth1Error._tagmap = {
'invalid_oauth1_token_info': TokenFromOAuth1Error._invalid_oauth1_token_info_validator,
'app_id_mismatch': TokenFromOAuth1Error._app_id_mismatch_validator,
'other': TokenFromOAuth1Error._other_validator,
}
TokenFromOAuth1Error.invalid_oauth1_token_info = TokenFromOAuth1Error('invalid_oauth1_token_info')
TokenFromOAuth1Error.app_id_mismatch = TokenFromOAuth1Error('app_id_mismatch')
TokenFromOAuth1Error.other = TokenFromOAuth1Error('other')
TokenFromOAuth1Result.oauth2_token.validator = bv.String(min_length=1)
TokenFromOAuth1Result._all_field_names_ = set(['oauth2_token'])
TokenFromOAuth1Result._all_fields_ = [('oauth2_token', TokenFromOAuth1Result.oauth2_token.validator)]
TokenScopeError.required_scope.validator = bv.String()
TokenScopeError._all_field_names_ = set(['required_scope'])
TokenScopeError._all_fields_ = [('required_scope', TokenScopeError.required_scope.validator)]
RateLimitError.retry_after.default = 1
token_from_oauth1 = bb.Route(
'token/from_oauth1',
1,
True,
TokenFromOAuth1Arg_validator,
TokenFromOAuth1Result_validator,
TokenFromOAuth1Error_validator,
{'auth': 'app',
'host': 'api',
'style': 'rpc'},
)
token_revoke = bb.Route(
'token/revoke',
1,
False,
bv.Void(),
bv.Void(),
bv.Void(),
{'auth': 'user',
'host': 'api',
'style': 'rpc'},
)
ROUTES = {
'token/from_oauth1': token_from_oauth1,
'token/revoke': token_revoke,
}
|