Skip to content

Commit 0dc1af7

Browse files
committed
Updated specs.
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.
1 parent e99ce8c commit 0dc1af7

17 files changed

+2074
-1021
lines changed

dropbox/async.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ class PollError(bb.Union):
218218
:ivar internal_error: Something went wrong with the job on Dropbox's end.
219219
You'll need to verify that the action you were taking succeeded, and if
220220
not, try again. This should happen very rarely.
221-
:ivar other: An unspecified error.
222221
"""
223222

224223
_catch_all = 'other'

dropbox/auth.py

Lines changed: 158 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class AuthError(bb.Union):
2222
is no longer on the team.
2323
:ivar invalid_select_admin: The user specified in 'Dropbox-API-Select-Admin'
2424
is not a Dropbox Business team admin.
25-
:ivar other: An unspecified error.
2625
"""
2726

2827
_catch_all = 'other'
@@ -72,6 +71,140 @@ def __repr__(self):
7271

7372
AuthError_validator = bv.Union(AuthError)
7473

74+
class RateLimitError(object):
75+
"""
76+
Error occurred because the app is being rate limited.
77+
78+
:ivar reason: The reason why the app is being rate limited.
79+
:ivar retry_after: The number of seconds that the app should wait before
80+
making another request.
81+
"""
82+
83+
__slots__ = [
84+
'_reason_value',
85+
'_reason_present',
86+
'_retry_after_value',
87+
'_retry_after_present',
88+
]
89+
90+
_has_required_fields = True
91+
92+
def __init__(self,
93+
reason=None,
94+
retry_after=None):
95+
self._reason_value = None
96+
self._reason_present = False
97+
self._retry_after_value = None
98+
self._retry_after_present = False
99+
if reason is not None:
100+
self.reason = reason
101+
if retry_after is not None:
102+
self.retry_after = retry_after
103+
104+
@property
105+
def reason(self):
106+
"""
107+
The reason why the app is being rate limited.
108+
109+
:rtype: RateLimitReason
110+
"""
111+
if self._reason_present:
112+
return self._reason_value
113+
else:
114+
raise AttributeError("missing required field 'reason'")
115+
116+
@reason.setter
117+
def reason(self, val):
118+
self._reason_validator.validate_type_only(val)
119+
self._reason_value = val
120+
self._reason_present = True
121+
122+
@reason.deleter
123+
def reason(self):
124+
self._reason_value = None
125+
self._reason_present = False
126+
127+
@property
128+
def retry_after(self):
129+
"""
130+
The number of seconds that the app should wait before making another
131+
request.
132+
133+
:rtype: long
134+
"""
135+
if self._retry_after_present:
136+
return self._retry_after_value
137+
else:
138+
return 1
139+
140+
@retry_after.setter
141+
def retry_after(self, val):
142+
val = self._retry_after_validator.validate(val)
143+
self._retry_after_value = val
144+
self._retry_after_present = True
145+
146+
@retry_after.deleter
147+
def retry_after(self):
148+
self._retry_after_value = None
149+
self._retry_after_present = False
150+
151+
def __repr__(self):
152+
return 'RateLimitError(reason={!r}, retry_after={!r})'.format(
153+
self._reason_value,
154+
self._retry_after_value,
155+
)
156+
157+
RateLimitError_validator = bv.Struct(RateLimitError)
158+
159+
class RateLimitReason(bb.Union):
160+
"""
161+
This class acts as a tagged union. Only one of the ``is_*`` methods will
162+
return true. To get the associated value of a tag (if one exists), use the
163+
corresponding ``get_*`` method.
164+
165+
:ivar too_many_requests: You are making too many requests in the past few
166+
minutes.
167+
:ivar too_many_write_operations: There are currently too many write
168+
operations happening in the user's Dropbox.
169+
"""
170+
171+
_catch_all = 'other'
172+
# Attribute is overwritten below the class definition
173+
too_many_requests = None
174+
# Attribute is overwritten below the class definition
175+
too_many_write_operations = None
176+
# Attribute is overwritten below the class definition
177+
other = None
178+
179+
def is_too_many_requests(self):
180+
"""
181+
Check if the union tag is ``too_many_requests``.
182+
183+
:rtype: bool
184+
"""
185+
return self._tag == 'too_many_requests'
186+
187+
def is_too_many_write_operations(self):
188+
"""
189+
Check if the union tag is ``too_many_write_operations``.
190+
191+
:rtype: bool
192+
"""
193+
return self._tag == 'too_many_write_operations'
194+
195+
def is_other(self):
196+
"""
197+
Check if the union tag is ``other``.
198+
199+
:rtype: bool
200+
"""
201+
return self._tag == 'other'
202+
203+
def __repr__(self):
204+
return 'RateLimitReason(%r, %r)' % (self._tag, self._value)
205+
206+
RateLimitReason_validator = bv.Union(RateLimitReason)
207+
75208
AuthError._invalid_access_token_validator = bv.Void()
76209
AuthError._invalid_select_user_validator = bv.Void()
77210
AuthError._invalid_select_admin_validator = bv.Void()
@@ -88,6 +221,30 @@ def __repr__(self):
88221
AuthError.invalid_select_admin = AuthError('invalid_select_admin')
89222
AuthError.other = AuthError('other')
90223

224+
RateLimitError._reason_validator = RateLimitReason_validator
225+
RateLimitError._retry_after_validator = bv.UInt64()
226+
RateLimitError._all_field_names_ = set([
227+
'reason',
228+
'retry_after',
229+
])
230+
RateLimitError._all_fields_ = [
231+
('reason', RateLimitError._reason_validator),
232+
('retry_after', RateLimitError._retry_after_validator),
233+
]
234+
235+
RateLimitReason._too_many_requests_validator = bv.Void()
236+
RateLimitReason._too_many_write_operations_validator = bv.Void()
237+
RateLimitReason._other_validator = bv.Void()
238+
RateLimitReason._tagmap = {
239+
'too_many_requests': RateLimitReason._too_many_requests_validator,
240+
'too_many_write_operations': RateLimitReason._too_many_write_operations_validator,
241+
'other': RateLimitReason._other_validator,
242+
}
243+
244+
RateLimitReason.too_many_requests = RateLimitReason('too_many_requests')
245+
RateLimitReason.too_many_write_operations = RateLimitReason('too_many_write_operations')
246+
RateLimitReason.other = RateLimitReason('other')
247+
91248
token_revoke = bb.Route(
92249
'token/revoke',
93250
False,

dropbox/base.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,60 @@ def files_upload_session_finish(self,
11211121
)
11221122
return r
11231123

1124+
def files_upload_session_finish_batch(self,
1125+
entries):
1126+
"""
1127+
This route helps you commit many files at once into a user's Dropbox.
1128+
Use :meth:`upload_session_start` and :meth:`upload_session_append_v2` to
1129+
upload file contents. We recommend uploading many files in parallel to
1130+
increase throughput. Once the file contents have been uploaded, rather
1131+
than calling :meth:`upload_session_finish`, use this route to finish all
1132+
your upload sessions in a single request.
1133+
``UploadSessionStartArg.close`` or ``UploadSessionAppendArg.close``
1134+
needs to be true for last :meth:`upload_session_start` or
1135+
:meth:`upload_session_append_v2` call. This route will return job_id
1136+
immediately and do the async commit job in background. We have another
1137+
route :meth:`upload_session_finish_batch_check` to check the job status.
1138+
For the same account, this route should be executed serially. That means
1139+
you should not start next job before current job finishes. Also we only
1140+
allow up to 1000 entries in a single request
1141+
1142+
:param list entries: Commit information for each file in the batch.
1143+
:rtype: :class:`dropbox.files.LaunchEmptyResult`
1144+
"""
1145+
arg = files.UploadSessionFinishBatchArg(entries)
1146+
r = self.request(
1147+
files.upload_session_finish_batch,
1148+
'files',
1149+
arg,
1150+
None,
1151+
)
1152+
return r
1153+
1154+
def files_upload_session_finish_batch_check(self,
1155+
async_job_id):
1156+
"""
1157+
Returns the status of an asynchronous job for
1158+
:meth:`upload_session_finish_batch`. If success, it returns list of
1159+
result for each entry
1160+
1161+
:param str async_job_id: Id of the asynchronous job. This is the value
1162+
of a response returned from the method that launched the job.
1163+
:rtype: :class:`dropbox.files.UploadSessionFinishBatchJobStatus`
1164+
:raises: :class:`dropbox.exceptions.ApiError`
1165+
1166+
If this raises, ApiError.reason is of type:
1167+
:class:`dropbox.files.PollError`
1168+
"""
1169+
arg = async.PollArg(async_job_id)
1170+
r = self.request(
1171+
files.upload_session_finish_batch_check,
1172+
'files',
1173+
arg,
1174+
None,
1175+
)
1176+
return r
1177+
11241178
def files_upload_session_start(self,
11251179
f,
11261180
close=False):
@@ -1229,6 +1283,35 @@ def sharing_add_folder_member(self,
12291283
)
12301284
return None
12311285

1286+
def sharing_change_file_member_access(self,
1287+
file,
1288+
member,
1289+
access_level):
1290+
"""
1291+
Changes a member's access on a shared file.
1292+
1293+
:param str file: File for which we are changing a member's access.
1294+
:param member: The member whose access we are changing.
1295+
:type member: :class:`dropbox.sharing.MemberSelector`
1296+
:param access_level: The new access level for the member.
1297+
:type access_level: :class:`dropbox.sharing.AccessLevel`
1298+
:rtype: :class:`dropbox.sharing.FileMemberActionResult`
1299+
:raises: :class:`dropbox.exceptions.ApiError`
1300+
1301+
If this raises, ApiError.reason is of type:
1302+
:class:`dropbox.sharing.FileMemberActionError`
1303+
"""
1304+
arg = sharing.ChangeFileMemberAccessArgs(file,
1305+
member,
1306+
access_level)
1307+
r = self.request(
1308+
sharing.change_file_member_access,
1309+
'sharing',
1310+
arg,
1311+
None,
1312+
)
1313+
return r
1314+
12321315
def sharing_check_job_status(self,
12331316
async_job_id):
12341317
"""

0 commit comments

Comments
 (0)