Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 21 additions & 199 deletions dropbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
async_,
auth,
check,
cloud_docs,
common,
contacts,
file_properties,
Expand Down Expand Up @@ -154,194 +153,6 @@ def check_user(self,
)
return r

# ------------------------------------------
# Routes in cloud_docs namespace

def cloud_docs_get_content(self,
file_id):
"""
Fetch the binary content of the requested document. This route requires
Cloud Docs auth. Please make a request to cloud_docs/authorize and
supply that token in the Authorization header.

:type file_id: str
:rtype: (None,
:class:`requests.models.Response`)
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.CloudDocsAccessError`

If you do not consume the entire response body, then you must call close
on the response object, otherwise you will max out your available
connections. We recommend using the `contextlib.closing
<https://docs.python.org/2/library/contextlib.html#contextlib.closing>`_
context manager to ensure this.
"""
arg = cloud_docs.GetContentArg(file_id)
r = self.request(
cloud_docs.get_content,
'cloud_docs',
arg,
None,
)
return None

def cloud_docs_get_content_to_file(self,
download_path,
file_id):
"""
Fetch the binary content of the requested document. This route requires
Cloud Docs auth. Please make a request to cloud_docs/authorize and
supply that token in the Authorization header.

:param str download_path: Path on local machine to save file.
:type file_id: str
:rtype: None
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.CloudDocsAccessError`
"""
arg = cloud_docs.GetContentArg(file_id)
r = self.request(
cloud_docs.get_content,
'cloud_docs',
arg,
None,
)
self._save_body_to_file(download_path, r[1])
return None

def cloud_docs_get_metadata(self,
file_id=u''):
"""
Fetches metadata associated with a Cloud Doc and user. This route
requires Cloud Docs auth. Please make a request to cloud_docs/authorize
and supply that token in the Authorization header.

:param str file_id: API ID ("id:...") associated with the Cloud Doc.
:rtype: :class:`dropbox.cloud_docs.GetMetadataResult`
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.GetMetadataError`
"""
arg = cloud_docs.GetMetadataArg(file_id)
r = self.request(
cloud_docs.get_metadata,
'cloud_docs',
arg,
None,
)
return r

def cloud_docs_lock(self,
file_id=u''):
"""
Lock a Cloud Doc. This route requires Cloud Docs auth. Please make a
request to cloud_docs/authorize and supply that token in the
Authorization header.

:param str file_id: The API ID ("id:...") associated with the Cloud Doc
:rtype: :class:`dropbox.cloud_docs.LockResult`
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.LockingError`
"""
arg = cloud_docs.LockArg(file_id)
r = self.request(
cloud_docs.lock,
'cloud_docs',
arg,
None,
)
return r

def cloud_docs_rename(self,
file_id=u'',
title=u''):
"""
Update the title of a Cloud Doc. This route requires Cloud Docs auth.
Please make a request to cloud_docs/authorize and supply that token in
the Authorization header.

:param str file_id: The API ID ("id:...") associated with the Cloud Doc
:param str title: The new title of the doc, excluding extension
:rtype: :class:`dropbox.cloud_docs.RenameResult`
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.RenameError`
"""
arg = cloud_docs.RenameArg(file_id,
title)
r = self.request(
cloud_docs.rename,
'cloud_docs',
arg,
None,
)
return r

def cloud_docs_unlock(self,
file_id=u''):
"""
Unlock a Cloud Doc. This route requires Cloud Docs auth. Please make a
request to cloud_docs/authorize and supply that token in the
Authorization header.

:param str file_id: The API ID ("id:...") associated with the Cloud Doc
:rtype: :class:`dropbox.cloud_docs.UnlockResult`
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.LockingError`
"""
arg = cloud_docs.UnlockArg(file_id)
r = self.request(
cloud_docs.unlock,
'cloud_docs',
arg,
None,
)
return r

def cloud_docs_update_content(self,
f,
file_id,
actor_tokens,
additional_contents=None):
"""
Update the contents of a Cloud Doc. This should be called for files with
a max size of 150MB. This route requires Cloud Docs auth. Please make a
request to cloud_docs/authorize and supply that token in the
Authorization header.

:param bytes f: Contents to upload.
:type file_id: str
:param list actor_tokens: A list of auth_tokens, one for each editor who
made changes to the document since the last call to update_content.
:param Nullable additional_contents: Currently, this will always be
empty until we implement upload_additional_content.
:rtype: :class:`dropbox.cloud_docs.UpdateContentResult`
:raises: :class:`.exceptions.ApiError`

If this raises, ApiError will contain:
:class:`dropbox.cloud_docs.UpdateContentError`
"""
arg = cloud_docs.UpdateContentArg(file_id,
actor_tokens,
additional_contents)
r = self.request(
cloud_docs.update_content,
'cloud_docs',
arg,
f,
)
return r

# ------------------------------------------
# Routes in contacts namespace

Expand Down Expand Up @@ -719,7 +530,8 @@ def file_requests_create(self,
title,
destination,
deadline=None,
open=True):
open=True,
description=None):
"""
Creates a file request for this user.

Expand All @@ -732,6 +544,7 @@ def file_requests_create(self,
:param bool open: Whether or not the file request should be open. If the
file request is closed, it will not accept any file submissions, but
it can be opened later.
:param Nullable description: A description of the file request.
:rtype: :class:`dropbox.file_requests.FileRequest`
:raises: :class:`.exceptions.ApiError`

Expand All @@ -741,7 +554,8 @@ def file_requests_create(self,
arg = file_requests.CreateFileRequestArgs(title,
destination,
deadline,
open)
open,
description)
r = self.request(
file_requests.create,
'file_requests',
Expand Down Expand Up @@ -870,7 +684,8 @@ def file_requests_update(self,
title=None,
destination=None,
deadline=file_requests.UpdateFileRequestDeadline.no_update,
open=None):
open=None,
description=None):
"""
Update a file request.

Expand All @@ -885,13 +700,15 @@ def file_requests_update(self,
:type deadline: :class:`dropbox.file_requests.UpdateFileRequestDeadline`
:param Nullable open: Whether to set this file request as open or
closed.
:param Nullable description: The description of the file request.
:rtype: :class:`dropbox.file_requests.FileRequest`
"""
arg = file_requests.UpdateFileRequestArgs(id,
title,
destination,
deadline,
open)
open,
description)
r = self.request(
file_requests.update,
'file_requests',
Expand Down Expand Up @@ -2949,7 +2766,8 @@ def files_upload(self,
:class:`dropbox.files.WriteMode` detects conflict. For example,
always return a conflict error when ``mode`` = ``WriteMode.update``
and the given "rev" doesn't match the existing file's "rev", even if
the existing file has been deleted.
the existing file has been deleted. This also forces a conflict even
when the target path refers to a file with identical contents.
:rtype: :class:`dropbox.files.FileMetadata`
:raises: :class:`.exceptions.ApiError`

Expand Down Expand Up @@ -4645,11 +4463,15 @@ def sharing_list_shared_links(self,
direct_only=None):
"""
List shared links of this user. If no path is given, returns a list of
all shared links for the current user. If a non-empty path is given,
returns a list of all shared links that allow access to the given path -
direct links to the given path and links to parent folders of the given
path. Links to parent folders can be suppressed by setting direct_only
to true.
all shared links for the current user. For members of business teams
using team space and member folders, returns all shared links in the
team member's home folder unless the team space ID is specified in the
request header. For more information, refer to the `Namespace Guide
<https://www.dropbox.com/developers/reference/namespace-guide>`_. If a
non-empty path is given, returns a list of all shared links that allow
access to the given path - direct links to the given path and links to
parent folders of the given path. Links to parent folders can be
suppressed by setting direct_only to true.

:param Nullable path: See :meth:`sharing_list_shared_links` description.
:param Nullable cursor: The cursor returned by your last call to
Expand Down
4 changes: 0 additions & 4 deletions dropbox/base_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
async_,
auth,
check,
cloud_docs,
common,
contacts,
file_properties,
Expand Down Expand Up @@ -47,9 +46,6 @@ def request(self, route, namespace, arg, arg_binary=None):
# ------------------------------------------
# Routes in check namespace

# ------------------------------------------
# Routes in cloud_docs namespace

# ------------------------------------------
# Routes in contacts namespace

Expand Down
Loading