Skip to content

Commit 40f8a32

Browse files
committed
Updated spec
1 parent 1e6cd32 commit 40f8a32

File tree

11 files changed

+9243
-2151
lines changed

11 files changed

+9243
-2151
lines changed

dropbox/base.py

Lines changed: 128 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
file_requests,
1515
files,
1616
paper,
17+
seen_state,
1718
sharing,
1819
team,
1920
team_common,
@@ -143,8 +144,9 @@ def file_properties_properties_remove(self,
143144
remove specific property field key value pairs, see
144145
:meth:`file_properties_properties_update`. To update a template, see
145146
:meth:`file_properties_templates_update_for_user` or
146-
:meth:`file_properties_templates_update_for_team`. Templates can't be
147-
removed once created.
147+
:meth:`file_properties_templates_update_for_team`. To remove a template,
148+
see :meth:`file_properties_templates_remove_for_user` or
149+
:meth:`file_properties_templates_remove_for_team`.
148150
149151
:param str path: A unique identifier for the file or folder.
150152
:param list property_template_ids: A list of identifiers for a template
@@ -926,6 +928,61 @@ def files_create_folder(self,
926928
)
927929
return r
928930

931+
def files_create_folder_batch(self,
932+
paths,
933+
autorename=False,
934+
force_async=False):
935+
"""
936+
Create multiple folders at once. This route is asynchronous for large
937+
batches, which returns a job ID immediately and runs the create folder
938+
batch asynchronously. Otherwise, creates the folders and returns the
939+
result synchronously for smaller inputs. You can force asynchronous
940+
behaviour by using the ``CreateFolderBatchArg.force_async`` flag. Use
941+
:meth:`files_create_folder_batch_check` to check the job status.
942+
943+
:param list paths: List of paths to be created in the user's Dropbox.
944+
Duplicate path arguments in the batch are considered only once.
945+
:param bool autorename: If there's a conflict, have the Dropbox server
946+
try to autorename the folder to avoid the conflict.
947+
:param bool force_async: Whether to force the create to happen
948+
asynchronously.
949+
:rtype: :class:`dropbox.files.CreateFolderBatchLaunch`
950+
"""
951+
arg = files.CreateFolderBatchArg(paths,
952+
autorename,
953+
force_async)
954+
r = self.request(
955+
files.create_folder_batch,
956+
'files',
957+
arg,
958+
None,
959+
)
960+
return r
961+
962+
def files_create_folder_batch_check(self,
963+
async_job_id):
964+
"""
965+
Returns the status of an asynchronous job for
966+
:meth:`files_create_folder_batch`. If success, it returns list of result
967+
for each entry.
968+
969+
:param str async_job_id: Id of the asynchronous job. This is the value
970+
of a response returned from the method that launched the job.
971+
:rtype: :class:`dropbox.files.CreateFolderBatchJobStatus`
972+
:raises: :class:`.exceptions.ApiError`
973+
974+
If this raises, ApiError will contain:
975+
:class:`dropbox.files.PollError`
976+
"""
977+
arg = async.PollArg(async_job_id)
978+
r = self.request(
979+
files.create_folder_batch_check,
980+
'files',
981+
arg,
982+
None,
983+
)
984+
return r
985+
929986
def files_create_folder_v2(self,
930987
path,
931988
autorename=False):
@@ -952,7 +1009,8 @@ def files_create_folder_v2(self,
9521009
return r
9531010

9541011
def files_delete(self,
955-
path):
1012+
path,
1013+
parent_rev=None):
9561014
"""
9571015
Delete the file or folder at a given path. If the path is a folder, all
9581016
its contents will be deleted too. A successful response indicates that
@@ -962,6 +1020,9 @@ def files_delete(self,
9621020
and not a :class:`dropbox.files.DeletedMetadata` object.
9631021
9641022
:param str path: Path in the user's Dropbox to delete.
1023+
:param Nullable parent_rev: Perform delete if given "rev" matches the
1024+
existing file's latest "rev". This field does not support deleting a
1025+
folder.
9651026
:rtype: :class:`dropbox.files.Metadata`
9661027
:raises: :class:`.exceptions.ApiError`
9671028
@@ -972,7 +1033,8 @@ def files_delete(self,
9721033
'delete is deprecated. Use delete_v2.',
9731034
DeprecationWarning,
9741035
)
975-
arg = files.DeleteArg(path)
1036+
arg = files.DeleteArg(path,
1037+
parent_rev)
9761038
r = self.request(
9771039
files.delete,
9781040
'files',
@@ -1025,7 +1087,8 @@ def files_delete_batch_check(self,
10251087
return r
10261088

10271089
def files_delete_v2(self,
1028-
path):
1090+
path,
1091+
parent_rev=None):
10291092
"""
10301093
Delete the file or folder at a given path. If the path is a folder, all
10311094
its contents will be deleted too. A successful response indicates that
@@ -1035,13 +1098,17 @@ def files_delete_v2(self,
10351098
and not a :class:`dropbox.files.DeletedMetadata` object.
10361099
10371100
:param str path: Path in the user's Dropbox to delete.
1101+
:param Nullable parent_rev: Perform delete if given "rev" matches the
1102+
existing file's latest "rev". This field does not support deleting a
1103+
folder.
10381104
:rtype: :class:`dropbox.files.DeleteResult`
10391105
:raises: :class:`.exceptions.ApiError`
10401106
10411107
If this raises, ApiError will contain:
10421108
:class:`dropbox.files.DeleteError`
10431109
"""
1044-
arg = files.DeleteArg(path)
1110+
arg = files.DeleteArg(path,
1111+
parent_rev)
10451112
r = self.request(
10461113
files.delete_v2,
10471114
'files',
@@ -1299,7 +1366,8 @@ def files_get_temporary_link(self,
12991366
def files_get_thumbnail(self,
13001367
path,
13011368
format=files.ThumbnailFormat.jpeg,
1302-
size=files.ThumbnailSize.w64h64):
1369+
size=files.ThumbnailSize.w64h64,
1370+
mode=files.ThumbnailMode.strict):
13031371
"""
13041372
Get a thumbnail for an image. This method currently supports files with
13051373
the following file extensions: jpg, jpeg, png, tiff, tif, gif and bmp.
@@ -1313,6 +1381,9 @@ def files_get_thumbnail(self,
13131381
:type format: :class:`dropbox.files.ThumbnailFormat`
13141382
:param size: The size for the thumbnail image.
13151383
:type size: :class:`dropbox.files.ThumbnailSize`
1384+
:param mode: How to resize and crop the image to achieve the desired
1385+
size.
1386+
:type mode: :class:`dropbox.files.ThumbnailMode`
13161387
:rtype: (:class:`dropbox.files.FileMetadata`,
13171388
:class:`requests.models.Response`)
13181389
:raises: :class:`.exceptions.ApiError`
@@ -1328,7 +1399,8 @@ def files_get_thumbnail(self,
13281399
"""
13291400
arg = files.ThumbnailArg(path,
13301401
format,
1331-
size)
1402+
size,
1403+
mode)
13321404
r = self.request(
13331405
files.get_thumbnail,
13341406
'files',
@@ -1341,7 +1413,8 @@ def files_get_thumbnail_to_file(self,
13411413
download_path,
13421414
path,
13431415
format=files.ThumbnailFormat.jpeg,
1344-
size=files.ThumbnailSize.w64h64):
1416+
size=files.ThumbnailSize.w64h64,
1417+
mode=files.ThumbnailMode.strict):
13451418
"""
13461419
Get a thumbnail for an image. This method currently supports files with
13471420
the following file extensions: jpg, jpeg, png, tiff, tif, gif and bmp.
@@ -1356,6 +1429,9 @@ def files_get_thumbnail_to_file(self,
13561429
:type format: :class:`dropbox.files.ThumbnailFormat`
13571430
:param size: The size for the thumbnail image.
13581431
:type size: :class:`dropbox.files.ThumbnailSize`
1432+
:param mode: How to resize and crop the image to achieve the desired
1433+
size.
1434+
:type mode: :class:`dropbox.files.ThumbnailMode`
13591435
:rtype: :class:`dropbox.files.FileMetadata`
13601436
:raises: :class:`.exceptions.ApiError`
13611437
@@ -1364,7 +1440,8 @@ def files_get_thumbnail_to_file(self,
13641440
"""
13651441
arg = files.ThumbnailArg(path,
13661442
format,
1367-
size)
1443+
size,
1444+
mode)
13681445
r = self.request(
13691446
files.get_thumbnail,
13701447
'files',
@@ -1790,20 +1867,25 @@ def files_move_v2(self,
17901867
return r
17911868

17921869
def files_permanently_delete(self,
1793-
path):
1870+
path,
1871+
parent_rev=None):
17941872
"""
17951873
Permanently delete the file or folder at a given path (see
17961874
https://www.dropbox.com/en/help/40). Note: This endpoint is only
17971875
available for Dropbox Business apps.
17981876
17991877
:param str path: Path in the user's Dropbox to delete.
1878+
:param Nullable parent_rev: Perform delete if given "rev" matches the
1879+
existing file's latest "rev". This field does not support deleting a
1880+
folder.
18001881
:rtype: None
18011882
:raises: :class:`.exceptions.ApiError`
18021883
18031884
If this raises, ApiError will contain:
18041885
:class:`dropbox.files.DeleteError`
18051886
"""
1806-
arg = files.DeleteArg(path)
1887+
arg = files.DeleteArg(path,
1888+
parent_rev)
18071889
r = self.request(
18081890
files.permanently_delete,
18091891
'files',
@@ -2481,7 +2563,7 @@ def paper_docs_get_folder_info(self,
24812563
Retrieves folder information for the given Paper doc. This includes: -
24822564
folder sharing policy; permissions for subfolders are set by the
24832565
top-level folder. - full 'filepath', i.e. the list of folders (both
2484-
folderId and folderName) from the root folder to the folder directly
2566+
folderId and folderName) from the root folder to the folder directly
24852567
containing the Paper doc. Note: If the Paper doc is not in any folder
24862568
(aka unfiled) the response will be empty.
24872569
@@ -3815,6 +3897,36 @@ def sharing_revoke_shared_link(self,
38153897
)
38163898
return None
38173899

3900+
def sharing_set_access_inheritance(self,
3901+
shared_folder_id,
3902+
access_inheritance=sharing.AccessInheritance.inherit):
3903+
"""
3904+
Change the inheritance policy of an existing Shared Folder. Only
3905+
permitted for shared folders in a shared team root. If a
3906+
``ShareFolderLaunch.async_job_id`` is returned, you'll need to call
3907+
:meth:`sharing_check_share_job_status` until the action completes to get
3908+
the metadata for the folder.
3909+
3910+
:param access_inheritance: The access inheritance settings for the
3911+
folder.
3912+
:type access_inheritance: :class:`dropbox.sharing.AccessInheritance`
3913+
:param str shared_folder_id: The ID for the shared folder.
3914+
:rtype: :class:`dropbox.sharing.ShareFolderLaunch`
3915+
:raises: :class:`.exceptions.ApiError`
3916+
3917+
If this raises, ApiError will contain:
3918+
:class:`dropbox.sharing.SetAccessInheritanceError`
3919+
"""
3920+
arg = sharing.SetAccessInheritanceArg(shared_folder_id,
3921+
access_inheritance)
3922+
r = self.request(
3923+
sharing.set_access_inheritance,
3924+
'sharing',
3925+
arg,
3926+
None,
3927+
)
3928+
return r
3929+
38183930
def sharing_share_folder(self,
38193931
path,
38203932
acl_update_policy=None,
@@ -4076,7 +4188,9 @@ def team_log_get_events(self,
40764188
time=None,
40774189
category=None):
40784190
"""
4079-
Retrieves team events. Permission : Team Auditing.
4191+
Retrieves team events. Events have a lifespan of two years. Events older
4192+
than two years will not be returned. Many attributes note 'may be
4193+
missing due to historical data gap'. Permission : Team Auditing.
40804194
40814195
:param long limit: Number of results to return per call.
40824196
:param Nullable account_id: Filter the events by account ID. Return ony

dropbox/base_team.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
file_requests,
1515
files,
1616
paper,
17+
seen_state,
1718
sharing,
1819
team,
1920
team_common,
@@ -1501,19 +1502,23 @@ def team_team_folder_archive_check(self,
15011502
return r
15021503

15031504
def team_team_folder_create(self,
1504-
name):
1505+
name,
1506+
sync_setting=None):
15051507
"""
15061508
Creates a new, active, team folder with no members. Permission : Team
15071509
member file access.
15081510
15091511
:param str name: Name for the new team folder.
1512+
:param Nullable sync_setting: The sync setting to apply to this team
1513+
folder. Only permitted if the team has team selective sync enabled.
15101514
:rtype: :class:`dropbox.team.TeamFolderMetadata`
15111515
:raises: :class:`.exceptions.ApiError`
15121516
15131517
If this raises, ApiError will contain:
15141518
:class:`dropbox.team.TeamFolderCreateError`
15151519
"""
1516-
arg = team.TeamFolderCreateArg(name)
1520+
arg = team.TeamFolderCreateArg(name,
1521+
sync_setting)
15171522
r = self.request(
15181523
team.team_folder_create,
15191524
'team',
@@ -1627,6 +1632,36 @@ def team_team_folder_rename(self,
16271632
)
16281633
return r
16291634

1635+
def team_team_folder_update_sync_settings(self,
1636+
team_folder_id,
1637+
sync_setting=None,
1638+
content_sync_settings=None):
1639+
"""
1640+
Updates the sync settings on a team folder or its contents. Use of this
1641+
endpoint requires that the team has team selective sync enabled.
1642+
1643+
:param Nullable sync_setting: Sync setting to apply to the team folder
1644+
itself. Only meaningful if the team folder is not a shared team
1645+
root.
1646+
:param Nullable content_sync_settings: Sync settings to apply to
1647+
contents of this team folder.
1648+
:rtype: :class:`dropbox.team.TeamFolderMetadata`
1649+
:raises: :class:`.exceptions.ApiError`
1650+
1651+
If this raises, ApiError will contain:
1652+
:class:`dropbox.team.TeamFolderUpdateSyncSettingsError`
1653+
"""
1654+
arg = team.TeamFolderUpdateSyncSettingsArg(team_folder_id,
1655+
sync_setting,
1656+
content_sync_settings)
1657+
r = self.request(
1658+
team.team_folder_update_sync_settings,
1659+
'team',
1660+
arg,
1661+
None,
1662+
)
1663+
return r
1664+
16301665
def team_token_get_authenticated_admin(self):
16311666
"""
16321667
Returns the member profile of the admin who generated the team access

dropbox/file_properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
Templates are owned either by a user/app pair or team/app pair. Templates and their associated properties can't be accessed by any app other than the app that created them, and even then, only when the app is linked with the owner of the template (either a user or team).
2020
21-
User-owned templates are accessed via the user-auth template/*_for_user endpoints, while team-owned templates are accessed via the team-auth template/*_for_team endpoints. Properties associated with either type of template can be accessed via the user-auth properties/* endpoints.
21+
User-owned templates are accessed via the user-auth file_properties/templates/*_for_user endpoints, while team-owned templates are accessed via the team-auth file_properties/templates/*_for_team endpoints. Properties associated with either type of template can be accessed via the user-auth properties/* endpoints.
2222
2323
Finally, properties can be accessed from a number of endpoints that return metadata, including `files/get_metadata`, and `files/list_folder`. Properties can also be added during upload, using `files/upload`.
2424
"""

0 commit comments

Comments
 (0)