Skip to content

Commit

Permalink
Updated specs.
Browse files Browse the repository at this point in the history
Stone specs:
- Updated to new stone spec format (unions are default open).

Auth namespace:
- Added RateLimitReason and RateLimitError for describing 429 responses.

Files namespace:
- Added upload_session/finish_batch route.

Sharing namespace:
- Added change_member_file_access route.
- Added invite_view_no_comment to FolderPolicy.
- Added share_link to FolderAction.
- Added make_viewer_no_comment to MemberAction.
- Added preview_url to SharedFolderMetadata.
- Added access_details to MemberAccessLevelResult, which is the parent folders that amember has access to.
- Added too_many_invitees error to AddFolderMemberError.
- Added automatic_group to AddMemberSelectorError.
- Added insufficient_quota to MountFolderError.
- Added removed to TeamMemberStatus.

Team namespace:
- Added new_group_management_type to GroupUpdateArgs for groups/delete.
- Added include_removed flag to MembersListArg
- Added members/recover route.
  • Loading branch information
braincore committed Jul 27, 2016
1 parent e99ce8c commit 0dc1af7
Show file tree
Hide file tree
Showing 17 changed files with 2,074 additions and 1,021 deletions.
1 change: 0 additions & 1 deletion dropbox/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ class PollError(bb.Union):
:ivar internal_error: Something went wrong with the job on Dropbox's end.
You'll need to verify that the action you were taking succeeded, and if
not, try again. This should happen very rarely.
:ivar other: An unspecified error.
"""

_catch_all = 'other'
Expand Down
159 changes: 158 additions & 1 deletion dropbox/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class AuthError(bb.Union):
is no longer on the team.
:ivar invalid_select_admin: The user specified in 'Dropbox-API-Select-Admin'
is not a Dropbox Business team admin.
:ivar other: An unspecified error.
"""

_catch_all = 'other'
Expand Down Expand Up @@ -72,6 +71,140 @@ def __repr__(self):

AuthError_validator = bv.Union(AuthError)

class RateLimitError(object):
"""
Error occurred because the app is being rate limited.
:ivar reason: The reason why the app is being rate limited.
:ivar retry_after: The number of seconds that the app should wait before
making another request.
"""

__slots__ = [
'_reason_value',
'_reason_present',
'_retry_after_value',
'_retry_after_present',
]

_has_required_fields = True

def __init__(self,
reason=None,
retry_after=None):
self._reason_value = None
self._reason_present = False
self._retry_after_value = None
self._retry_after_present = False
if reason is not None:
self.reason = reason
if retry_after is not None:
self.retry_after = retry_after

@property
def reason(self):
"""
The reason why the app is being rate limited.
:rtype: RateLimitReason
"""
if self._reason_present:
return self._reason_value
else:
raise AttributeError("missing required field 'reason'")

@reason.setter
def reason(self, val):
self._reason_validator.validate_type_only(val)
self._reason_value = val
self._reason_present = True

@reason.deleter
def reason(self):
self._reason_value = None
self._reason_present = False

@property
def retry_after(self):
"""
The number of seconds that the app should wait before making another
request.
:rtype: long
"""
if self._retry_after_present:
return self._retry_after_value
else:
return 1

@retry_after.setter
def retry_after(self, val):
val = self._retry_after_validator.validate(val)
self._retry_after_value = val
self._retry_after_present = True

@retry_after.deleter
def retry_after(self):
self._retry_after_value = None
self._retry_after_present = False

def __repr__(self):
return 'RateLimitError(reason={!r}, retry_after={!r})'.format(
self._reason_value,
self._retry_after_value,
)

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 too_many_requests: You are making too many requests in the past few
minutes.
:ivar 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 __repr__(self):
return 'RateLimitReason(%r, %r)' % (self._tag, self._value)

RateLimitReason_validator = bv.Union(RateLimitReason)

AuthError._invalid_access_token_validator = bv.Void()
AuthError._invalid_select_user_validator = bv.Void()
AuthError._invalid_select_admin_validator = bv.Void()
Expand All @@ -88,6 +221,30 @@ def __repr__(self):
AuthError.invalid_select_admin = AuthError('invalid_select_admin')
AuthError.other = AuthError('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')

token_revoke = bb.Route(
'token/revoke',
False,
Expand Down
83 changes: 83 additions & 0 deletions dropbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,60 @@ def files_upload_session_finish(self,
)
return r

def files_upload_session_finish_batch(self,
entries):
"""
This route helps you commit many files at once into a user's Dropbox.
Use :meth:`upload_session_start` and :meth:`upload_session_append_v2` to
upload file contents. We recommend uploading many files in parallel to
increase throughput. Once the file contents have been uploaded, rather
than calling :meth:`upload_session_finish`, use this route to finish all
your upload sessions in a single request.
``UploadSessionStartArg.close`` or ``UploadSessionAppendArg.close``
needs to be true for last :meth:`upload_session_start` or
:meth:`upload_session_append_v2` call. This route will return job_id
immediately and do the async commit job in background. We have another
route :meth:`upload_session_finish_batch_check` to check the job status.
For the same account, this route should be executed serially. That means
you should not start next job before current job finishes. Also we only
allow up to 1000 entries in a single request
:param list entries: Commit information for each file in the batch.
:rtype: :class:`dropbox.files.LaunchEmptyResult`
"""
arg = files.UploadSessionFinishBatchArg(entries)
r = self.request(
files.upload_session_finish_batch,
'files',
arg,
None,
)
return r

def files_upload_session_finish_batch_check(self,
async_job_id):
"""
Returns the status of an asynchronous job for
:meth:`upload_session_finish_batch`. If success, it returns list of
result for each entry
:param str async_job_id: Id of the asynchronous job. This is the value
of a response returned from the method that launched the job.
:rtype: :class:`dropbox.files.UploadSessionFinishBatchJobStatus`
:raises: :class:`dropbox.exceptions.ApiError`
If this raises, ApiError.reason is of type:
:class:`dropbox.files.PollError`
"""
arg = async.PollArg(async_job_id)
r = self.request(
files.upload_session_finish_batch_check,
'files',
arg,
None,
)
return r

def files_upload_session_start(self,
f,
close=False):
Expand Down Expand Up @@ -1229,6 +1283,35 @@ def sharing_add_folder_member(self,
)
return None

def sharing_change_file_member_access(self,
file,
member,
access_level):
"""
Changes a member's access on a shared file.
:param str file: File for which we are changing a member's access.
:param member: The member whose access we are changing.
:type member: :class:`dropbox.sharing.MemberSelector`
:param access_level: The new access level for the member.
:type access_level: :class:`dropbox.sharing.AccessLevel`
:rtype: :class:`dropbox.sharing.FileMemberActionResult`
:raises: :class:`dropbox.exceptions.ApiError`
If this raises, ApiError.reason is of type:
:class:`dropbox.sharing.FileMemberActionError`
"""
arg = sharing.ChangeFileMemberAccessArgs(file,
member,
access_level)
r = self.request(
sharing.change_file_member_access,
'sharing',
arg,
None,
)
return r

def sharing_check_job_status(self,
async_job_id):
"""
Expand Down
Loading

0 comments on commit 0dc1af7

Please sign in to comment.