Skip to content

Commit d53cc31

Browse files
authored
Spec Update (#190)
Change Notes: Stone configuration - added a new route property is_cloud_doc_auth indicating whether the endpoint is a Dropbox cloud docs endpoint which takes cloud docs auth token. Files namespace - lock_file_batch, unlock_file_batch and get_file_lock_batch are no longer preview routes - Update query description on SearchArg Struct, SearchV2Arg Struct - Update move:2 and move_batch:2 route descirption Team namespace - Deleted deprecated routes legal_holds/export_policy and legal_holds/export_policy_job_status/check Team_log namespace: - Added AccountState union - Added AccountLockOrUnlockedType struct - Added AccountLockOrUnlockedDetails struct - Added MemberSendInvitePolicy union - Added MemberSendInvitePolicyChangedType struct - Added MemberSendInvitePolicyChangedDetails struct - Added a new tag first_party_token_exchange to LoginMethod union - Added new tags account_lock_or_unlocked_details and member_send_invite_policy_changed_details to EventDetails union - Added new tags account_lock_or_unlocked and member_send_invite_policy_changed to EventType union - Added a new field file_size to FileOrFolderLogInfo and FileLogInfo struct - Added a new field file_count to FolderLogInfo struct - Add NoExpirationLinkGenCreateReportDetails, NoExpirationLinkGenReportFailedDetails, NoPasswordLinkGenCreateReportDetails, NoPasswordLinkGenReportFailedDetails, NoPasswordLinkViewCreateReportDetails, NoPasswordLinkViewReportFailedDetails, OutdatedLinkViewCreateReportDetails, OutdatedLnkViewReportFailedDetails structs to the EventDetails union - Add NoExpirationLinkGenCreateReportType, NoExpirationLinkGenReportFailedType, NoPasswordLinkGenCreateReportType, NoPasswordLinkGenReportFailedType, NoPasswordLinkViewCreateReportType, NoPasswordLinkViewReportFailedType, OutdatedLinkViewCreateReportType, OutdatedLinkViewReportFailedType structs to the EventType union Cloud Docs Namespace - Add get_content, get_metadata, rename, unlock, and lock routes - Add corresponding args, results, and errors File Properties Namespace - Update AddPropertiesArg description - Add duplicate_property_groups to InvalidPropertyGroupError Union - Update property_groups description on AddPropertiesError Union Shared Links Namespace - Update SharedLinkSettings example Stone CFG Namespace - Update auth type string patterns - Update host string patterns - Update style string patterns - Update select_admin_mode string patterns Team Legal Holds Namespace - Add team_exceeded_legal_hold_quota to LegalHoldsPolicyCreateError union - Change LegalHoldsListHeldRevisionsError and LegalHoldsPolicyReleaseError to extend LegalHoldsError Team Secondary Mails Namespace: - Remove is_preview from route add, resend_verification_emails, and delete
1 parent 4471b7e commit d53cc31

File tree

10 files changed

+4963
-738
lines changed

10 files changed

+4963
-738
lines changed

.github/workflows/pypiupload.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ jobs:
2727
- name: Build
2828
run: |
2929
python setup.py bdist_wheel
30-
- name: Build Sources
30+
- name: Build Sources (3.x)
31+
run: python setup.py sdist
3132
if: matrix.python-version == '3.x'
32-
run: |
33-
python setup.py sdist
3433
- name: Publish
3534
env:
3635
TWINE_USERNAME: __token__

dropbox/base.py

Lines changed: 209 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
async_,
1212
auth,
1313
check,
14+
cloud_docs,
1415
common,
1516
contacts,
1617
file_properties,
@@ -152,6 +153,194 @@ def check_user(self,
152153
)
153154
return r
154155

156+
# ------------------------------------------
157+
# Routes in cloud_docs namespace
158+
159+
def cloud_docs_get_content(self,
160+
file_id):
161+
"""
162+
Fetch the binary content of the requested document. This route requires
163+
Cloud Docs auth. Please make a request to cloud_docs/authorize and
164+
supply that token in the Authorization header.
165+
166+
:type file_id: str
167+
:rtype: (None,
168+
:class:`requests.models.Response`)
169+
:raises: :class:`.exceptions.ApiError`
170+
171+
If this raises, ApiError will contain:
172+
:class:`dropbox.cloud_docs.CloudDocsAccessError`
173+
174+
If you do not consume the entire response body, then you must call close
175+
on the response object, otherwise you will max out your available
176+
connections. We recommend using the `contextlib.closing
177+
<https://docs.python.org/2/library/contextlib.html#contextlib.closing>`_
178+
context manager to ensure this.
179+
"""
180+
arg = cloud_docs.GetContentArg(file_id)
181+
r = self.request(
182+
cloud_docs.get_content,
183+
'cloud_docs',
184+
arg,
185+
None,
186+
)
187+
return None
188+
189+
def cloud_docs_get_content_to_file(self,
190+
download_path,
191+
file_id):
192+
"""
193+
Fetch the binary content of the requested document. This route requires
194+
Cloud Docs auth. Please make a request to cloud_docs/authorize and
195+
supply that token in the Authorization header.
196+
197+
:param str download_path: Path on local machine to save file.
198+
:type file_id: str
199+
:rtype: None
200+
:raises: :class:`.exceptions.ApiError`
201+
202+
If this raises, ApiError will contain:
203+
:class:`dropbox.cloud_docs.CloudDocsAccessError`
204+
"""
205+
arg = cloud_docs.GetContentArg(file_id)
206+
r = self.request(
207+
cloud_docs.get_content,
208+
'cloud_docs',
209+
arg,
210+
None,
211+
)
212+
self._save_body_to_file(download_path, r[1])
213+
return None
214+
215+
def cloud_docs_get_metadata(self,
216+
file_id=u''):
217+
"""
218+
Fetches metadata associated with a Cloud Doc and user. This route
219+
requires Cloud Docs auth. Please make a request to cloud_docs/authorize
220+
and supply that token in the Authorization header.
221+
222+
:param str file_id: API ID ("id:...") associated with the Cloud Doc.
223+
:rtype: :class:`dropbox.cloud_docs.GetMetadataResult`
224+
:raises: :class:`.exceptions.ApiError`
225+
226+
If this raises, ApiError will contain:
227+
:class:`dropbox.cloud_docs.GetMetadataError`
228+
"""
229+
arg = cloud_docs.GetMetadataArg(file_id)
230+
r = self.request(
231+
cloud_docs.get_metadata,
232+
'cloud_docs',
233+
arg,
234+
None,
235+
)
236+
return r
237+
238+
def cloud_docs_lock(self,
239+
file_id=u''):
240+
"""
241+
Lock a Cloud Doc. This route requires Cloud Docs auth. Please make a
242+
request to cloud_docs/authorize and supply that token in the
243+
Authorization header.
244+
245+
:param str file_id: The API ID ("id:...") associated with the Cloud Doc
246+
:rtype: :class:`dropbox.cloud_docs.LockResult`
247+
:raises: :class:`.exceptions.ApiError`
248+
249+
If this raises, ApiError will contain:
250+
:class:`dropbox.cloud_docs.LockingError`
251+
"""
252+
arg = cloud_docs.LockArg(file_id)
253+
r = self.request(
254+
cloud_docs.lock,
255+
'cloud_docs',
256+
arg,
257+
None,
258+
)
259+
return r
260+
261+
def cloud_docs_rename(self,
262+
file_id=u'',
263+
title=u''):
264+
"""
265+
Update the title of a Cloud Doc. This route requires Cloud Docs auth.
266+
Please make a request to cloud_docs/authorize and supply that token in
267+
the Authorization header.
268+
269+
:param str file_id: The API ID ("id:...") associated with the Cloud Doc
270+
:param str title: The new title of the doc, excluding extension
271+
:rtype: :class:`dropbox.cloud_docs.RenameResult`
272+
:raises: :class:`.exceptions.ApiError`
273+
274+
If this raises, ApiError will contain:
275+
:class:`dropbox.cloud_docs.RenameError`
276+
"""
277+
arg = cloud_docs.RenameArg(file_id,
278+
title)
279+
r = self.request(
280+
cloud_docs.rename,
281+
'cloud_docs',
282+
arg,
283+
None,
284+
)
285+
return r
286+
287+
def cloud_docs_unlock(self,
288+
file_id=u''):
289+
"""
290+
Unlock a Cloud Doc. This route requires Cloud Docs auth. Please make a
291+
request to cloud_docs/authorize and supply that token in the
292+
Authorization header.
293+
294+
:param str file_id: The API ID ("id:...") associated with the Cloud Doc
295+
:rtype: :class:`dropbox.cloud_docs.UnlockResult`
296+
:raises: :class:`.exceptions.ApiError`
297+
298+
If this raises, ApiError will contain:
299+
:class:`dropbox.cloud_docs.LockingError`
300+
"""
301+
arg = cloud_docs.UnlockArg(file_id)
302+
r = self.request(
303+
cloud_docs.unlock,
304+
'cloud_docs',
305+
arg,
306+
None,
307+
)
308+
return r
309+
310+
def cloud_docs_update_content(self,
311+
f,
312+
file_id,
313+
actor_tokens,
314+
additional_contents=None):
315+
"""
316+
Update the contents of a Cloud Doc. This should be called for files with
317+
a max size of 150MB. This route requires Cloud Docs auth. Please make a
318+
request to cloud_docs/authorize and supply that token in the
319+
Authorization header.
320+
321+
:param bytes f: Contents to upload.
322+
:type file_id: str
323+
:param list actor_tokens: A list of auth_tokens, one for each editor who
324+
made changes to the document since the last call to update_content.
325+
:param Nullable additional_contents: Currently, this will always be
326+
empty until we implement upload_additional_content.
327+
:rtype: :class:`dropbox.cloud_docs.UpdateContentResult`
328+
:raises: :class:`.exceptions.ApiError`
329+
330+
If this raises, ApiError will contain:
331+
:class:`dropbox.cloud_docs.UpdateContentError`
332+
"""
333+
arg = cloud_docs.UpdateContentArg(file_id,
334+
actor_tokens,
335+
additional_contents)
336+
r = self.request(
337+
cloud_docs.update_content,
338+
'cloud_docs',
339+
arg,
340+
f,
341+
)
342+
return r
343+
155344
# ------------------------------------------
156345
# Routes in contacts namespace
157346

@@ -207,7 +396,8 @@ def file_properties_properties_add(self,
207396
208397
:param str path: A unique identifier for the file or folder.
209398
:param list property_groups: The property groups which are to be added
210-
to a Dropbox file.
399+
to a Dropbox file. No two groups in the input should refer to the
400+
same template.
211401
:rtype: None
212402
:raises: :class:`.exceptions.ApiError`
213403
@@ -237,7 +427,8 @@ def file_properties_properties_overwrite(self,
237427
238428
:param str path: A unique identifier for the file or folder.
239429
:param list property_groups: The property groups "snapshot" updates to
240-
force apply.
430+
force apply. No two groups in the input should refer to the same
431+
template.
241432
:rtype: None
242433
:raises: :class:`.exceptions.ApiError`
243434
@@ -2133,7 +2324,8 @@ def files_move_v2(self,
21332324
allow_ownership_transfer=False):
21342325
"""
21352326
Move a file or folder to a different location in the user's Dropbox. If
2136-
the source path is a folder all its contents will be moved.
2327+
the source path is a folder all its contents will be moved. Note that we
2328+
do not currently support case-only renaming.
21372329
21382330
:param bool allow_shared_folder: If true, :meth:`files_copy` will copy
21392331
contents in shared folder, otherwise
@@ -2213,8 +2405,9 @@ def files_move_batch_v2(self,
22132405
allow_ownership_transfer=False):
22142406
"""
22152407
Move multiple files or folders to different locations at once in the
2216-
user's Dropbox. This route will replace :meth:`files_move_batch`. The
2217-
main difference is this route will return status for each entry, while
2408+
user's Dropbox. Note that we do not currently support case-only
2409+
renaming. This route will replace :meth:`files_move_batch`. The main
2410+
difference is this route will return status for each entry, while
22182411
:meth:`files_move_batch` raises failure if any entry fails. This route
22192412
will either finish synchronously, or return a job ID and do the async
22202413
move job in background. Please use :meth:`files_move_batch_check_v2` to
@@ -2357,7 +2550,8 @@ def files_properties_add(self,
23572550
"""
23582551
:param str path: A unique identifier for the file or folder.
23592552
:param list property_groups: The property groups which are to be added
2360-
to a Dropbox file.
2553+
to a Dropbox file. No two groups in the input should refer to the
2554+
same template.
23612555
:rtype: None
23622556
:raises: :class:`.exceptions.ApiError`
23632557
@@ -2384,7 +2578,8 @@ def files_properties_overwrite(self,
23842578
"""
23852579
:param str path: A unique identifier for the file or folder.
23862580
:param list property_groups: The property groups "snapshot" updates to
2387-
force apply.
2581+
force apply. No two groups in the input should refer to the same
2582+
template.
23882583
:rtype: None
23892584
:raises: :class:`.exceptions.ApiError`
23902585
@@ -2585,10 +2780,11 @@ def files_search(self,
25852780
25862781
:param str path: The path in the user's Dropbox to search. Should
25872782
probably be a folder.
2588-
:param str query: The string to search for. The search string is split
2589-
on spaces into multiple tokens. For file name searching, the last
2590-
token is used for prefix matching (i.e. "bat c" matches "bat cave"
2591-
but not "batman car").
2783+
:param str query: The string to search for. Query string may be
2784+
rewritten to improve relevance of results. The string is split on
2785+
spaces into multiple tokens. For file name searching, the last token
2786+
is used for prefix matching (i.e. "bat c" matches "bat cave" but not
2787+
"batman car").
25922788
:param int start: The starting index within the search results (used for
25932789
paging).
25942790
:param int max_results: The maximum number of search results to return.
@@ -2631,7 +2827,8 @@ def files_search_v2(self,
26312827
be returned across pages. Some results may not be returned.
26322828
26332829
:param str query: The string to search for. May match across multiple
2634-
fields based on the request arguments.
2830+
fields based on the request arguments. Query string may be rewritten
2831+
to improve relevance of results.
26352832
:param Nullable options: Options for more targeted search results.
26362833
:type include_highlights: bool
26372834
:rtype: :class:`dropbox.files.SearchV2Result`

0 commit comments

Comments
 (0)