Skip to content

Commit

Permalink
Update public spec.
Browse files Browse the repository at this point in the history
- Files
  - Add save_url endpoint for saving online content to your Dropbox.
- Shared folders
  - Add viewer_no_comment to AccessLevel.
  - Add is_owner to GroupInfo.
  - Change return type of SharePathError.already_shared from Void to SharedFolderMetadata.
  - Add leave_a_copy parameter to relinquish_folder_membership endpoint.
  - Change relinquish_folder_membership to return async job ID when leaving a copy.
  - Add relinquish_folder_membership_error to JobError.
- Business endpoints
  - Add membership_type to MemberProfile.
  - Add keep_account parameter to members/remove endpoint.
  - Add cannot_keep_account_and_transfer and cannot_keep_account_and_delete_data to MembersRemoveError.
  • Loading branch information
braincore committed Jun 1, 2016
1 parent b314dab commit da0ab5a
Show file tree
Hide file tree
Showing 11 changed files with 2,742 additions and 835 deletions.
19 changes: 17 additions & 2 deletions dropbox/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class AuthError(bb.Union):
:ivar invalid_access_token: The access token is invalid.
:ivar invalid_select_user: The user specified in 'Dropbox-API-Select-User'
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.
"""

Expand All @@ -29,6 +31,8 @@ class AuthError(bb.Union):
# 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
other = None

def is_invalid_access_token(self):
Expand All @@ -47,6 +51,14 @@ def is_invalid_select_user(self):
"""
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_other(self):
"""
Check if the union tag is ``other``.
Expand All @@ -62,15 +74,18 @@ def __repr__(self):

AuthError._invalid_access_token_validator = bv.Void()
AuthError._invalid_select_user_validator = bv.Void()
AuthError._invalid_select_admin_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,
'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.other = AuthError('other')

token_revoke = bb.Route(
Expand All @@ -79,8 +94,8 @@ def __repr__(self):
bv.Void(),
bv.Void(),
bv.Void(),
{'host': None,
'style': None},
{'host': u'api',
'style': u'rpc'},
)

ROUTES = {
Expand Down
71 changes: 63 additions & 8 deletions dropbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
properties,
sharing,
team,
team_common,
team_policies,
users,
)
Expand Down Expand Up @@ -538,8 +539,8 @@ def files_list_folder_longpoll(self,
timeout=30):
"""
A longpoll endpoint to wait for changes on an account. In conjunction
with :meth:`list_folder`, this call gives you a low-latency way to
monitor an account for file changes. The connection will block until
with :meth:`list_folder_continue`, this call gives you a low-latency way
to monitor an account for file changes. The connection will block until
there are changes available or a timeout occurs. This endpoint is useful
mostly for client-side apps. If you're looking for server-side
notifications, check out our `webhooks documentation
Expand Down Expand Up @@ -665,6 +666,54 @@ def files_restore(self,
)
return r

def files_save_url(self,
path,
url):
"""
Save a specified URL into a file in user's Dropbox. If the given path
already exists, the file will be renamed to avoid the conflict (e.g.
myfile (1).txt).
:param str path: The path in Dropbox where the URL will be saved to.
:param str url: The URL to be saved.
:rtype: :class:`dropbox.files.SaveUrlResult`
:raises: :class:`dropbox.exceptions.ApiError`
If this raises, ApiError.reason is of type:
:class:`dropbox.files.SaveUrlError`
"""
arg = files.SaveUrlArg(path,
url)
r = self.request(
files.save_url,
'files',
arg,
None,
)
return r

def files_save_url_check_job_status(self,
async_job_id):
"""
Check the status of a :meth:`save_url` job.
: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.SaveUrlJobStatus`
: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.save_url_check_job_status,
'files',
arg,
None,
)
return r

def files_search(self,
path,
query,
Expand Down Expand Up @@ -1423,28 +1472,34 @@ def sharing_mount_folder(self,
return r

def sharing_relinquish_folder_membership(self,
shared_folder_id):
shared_folder_id,
leave_a_copy=False):
"""
The current user relinquishes their membership in the designated shared
folder and will no longer have access to the folder. A folder owner
cannot relinquish membership in their own folder. Apps must have full
Dropbox access to use this endpoint.
cannot relinquish membership in their own folder. This will run
synchronously if leave_a_copy is false, and asynchronously if
leave_a_copy is true. Apps must have full Dropbox access to use this
endpoint.
:param str shared_folder_id: The ID for the shared folder.
:rtype: None
:param bool leave_a_copy: Keep a copy of the folder's contents upon
relinquishing membership.
:rtype: :class:`dropbox.sharing.LaunchEmptyResult`
:raises: :class:`dropbox.exceptions.ApiError`
If this raises, ApiError.reason is of type:
:class:`dropbox.sharing.RelinquishFolderMembershipError`
"""
arg = sharing.RelinquishFolderMembershipArg(shared_folder_id)
arg = sharing.RelinquishFolderMembershipArg(shared_folder_id,
leave_a_copy)
r = self.request(
sharing.relinquish_folder_membership,
'sharing',
arg,
None,
)
return None
return r

def sharing_remove_folder_member(self,
shared_folder_id,
Expand Down
Loading

0 comments on commit da0ab5a

Please sign in to comment.