Skip to content

Commit 0f1ad58

Browse files
authored
Regenerate client using Stone 3.2.0 (dropbox#291)
* update version requirement for Stone and regenerate client files * add UPGRADING.md
1 parent 50f1d99 commit 0f1ad58

33 files changed

+12297
-74078
lines changed

UPGRADING.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Upgrading the Dropbox SDK
2+
3+
This document is designed to show you how to upgrade to the latest version of the SDK accomodating any breaking changes introduced by major version updates.
4+
If you find any issues with either this guide on upgrading or the changes introduced in the new version, please see [CONTRIBUTING.md](CONTRIBUTING.md)
5+
6+
# Upgrading from v10.X.X to v11.0.0
7+
The major change that happened in this new version is that we regenerated the client files using Stone 3.2.0,
8+
so relative imports are removed from the generated client files.
9+
This created some issues with the imports in the non-generated files in `dropbox/`.
10+
As a result, we renamed `dropbox.dropbox` to
11+
`dropbox.dropbox_client`. If you used to do imports like `dropbox.dropbox.foo`, such imports need to be changed to `dropbox.dropbox_client.foo`.
12+
However, we preserved the imports in `dropbox/__init__.py`, so imports like `from dropbox import DropboxOAuth2FlowNoRedirect`,
13+
`from dropbox import Dropbox` will continue to work.

dropbox/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from __future__ import absolute_import
22

3-
from .dropbox import __version__, Dropbox, DropboxTeam, create_session # noqa: F401
4-
from .oauth import DropboxOAuth2Flow, DropboxOAuth2FlowNoRedirect # noqa: F401
3+
from dropbox.dropbox_client import ( # noqa: F401 # pylint: disable=unused-import
4+
__version__, Dropbox, DropboxTeam, create_session
5+
)
6+
from dropbox.oauth import ( # noqa: F401 # pylint: disable=unused-import
7+
DropboxOAuth2Flow, DropboxOAuth2FlowNoRedirect
8+
)

dropbox/account.py

+13-78
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
# @generated
44
# flake8: noqa
55
# pylint: skip-file
6-
try:
7-
from . import stone_validators as bv
8-
from . import stone_base as bb
9-
except (ImportError, SystemError, ValueError):
10-
# Catch errors raised when importing a relative module when not in a package.
11-
# This makes testing this file directly (outside of a package) easier.
12-
import stone_validators as bv
13-
import stone_base as bb
6+
from __future__ import unicode_literals
7+
from stone.backends.python_rsrc import stone_base as bb
8+
from stone.backends.python_rsrc import stone_validators as bv
149

1510
class PhotoSourceArg(bb.Union):
1611
"""
@@ -68,9 +63,6 @@ def get_base64_data(self):
6863
def _process_custom_annotations(self, annotation_type, field_path, processor):
6964
super(PhotoSourceArg, self)._process_custom_annotations(annotation_type, field_path, processor)
7065

71-
def __repr__(self):
72-
return 'PhotoSourceArg(%r, %r)' % (self._tag, self._value)
73-
7466
PhotoSourceArg_validator = bv.Union(PhotoSourceArg)
7567

7668
class SetProfilePhotoArg(bb.Struct):
@@ -81,49 +73,22 @@ class SetProfilePhotoArg(bb.Struct):
8173

8274
__slots__ = [
8375
'_photo_value',
84-
'_photo_present',
8576
]
8677

8778
_has_required_fields = True
8879

8980
def __init__(self,
9081
photo=None):
91-
self._photo_value = None
92-
self._photo_present = False
82+
self._photo_value = bb.NOT_SET
9383
if photo is not None:
9484
self.photo = photo
9585

96-
@property
97-
def photo(self):
98-
"""
99-
Image to set as the user's new profile photo.
100-
101-
:rtype: PhotoSourceArg
102-
"""
103-
if self._photo_present:
104-
return self._photo_value
105-
else:
106-
raise AttributeError("missing required field 'photo'")
107-
108-
@photo.setter
109-
def photo(self, val):
110-
self._photo_validator.validate_type_only(val)
111-
self._photo_value = val
112-
self._photo_present = True
113-
114-
@photo.deleter
115-
def photo(self):
116-
self._photo_value = None
117-
self._photo_present = False
86+
# Instance attribute type: PhotoSourceArg (validator is set below)
87+
photo = bb.Attribute("photo", user_defined=True)
11888

11989
def _process_custom_annotations(self, annotation_type, field_path, processor):
12090
super(SetProfilePhotoArg, self)._process_custom_annotations(annotation_type, field_path, processor)
12191

122-
def __repr__(self):
123-
return 'SetProfilePhotoArg(photo={!r})'.format(
124-
self._photo_value,
125-
)
126-
12792
SetProfilePhotoArg_validator = bv.Struct(SetProfilePhotoArg)
12893

12994
class SetProfilePhotoError(bb.Union):
@@ -209,9 +174,6 @@ def is_other(self):
209174
def _process_custom_annotations(self, annotation_type, field_path, processor):
210175
super(SetProfilePhotoError, self)._process_custom_annotations(annotation_type, field_path, processor)
211176

212-
def __repr__(self):
213-
return 'SetProfilePhotoError(%r, %r)' % (self._tag, self._value)
214-
215177
SetProfilePhotoError_validator = bv.Union(SetProfilePhotoError)
216178

217179
class SetProfilePhotoResult(bb.Struct):
@@ -222,49 +184,22 @@ class SetProfilePhotoResult(bb.Struct):
222184

223185
__slots__ = [
224186
'_profile_photo_url_value',
225-
'_profile_photo_url_present',
226187
]
227188

228189
_has_required_fields = True
229190

230191
def __init__(self,
231192
profile_photo_url=None):
232-
self._profile_photo_url_value = None
233-
self._profile_photo_url_present = False
193+
self._profile_photo_url_value = bb.NOT_SET
234194
if profile_photo_url is not None:
235195
self.profile_photo_url = profile_photo_url
236196

237-
@property
238-
def profile_photo_url(self):
239-
"""
240-
URL for the photo representing the user, if one is set.
241-
242-
:rtype: str
243-
"""
244-
if self._profile_photo_url_present:
245-
return self._profile_photo_url_value
246-
else:
247-
raise AttributeError("missing required field 'profile_photo_url'")
248-
249-
@profile_photo_url.setter
250-
def profile_photo_url(self, val):
251-
val = self._profile_photo_url_validator.validate(val)
252-
self._profile_photo_url_value = val
253-
self._profile_photo_url_present = True
254-
255-
@profile_photo_url.deleter
256-
def profile_photo_url(self):
257-
self._profile_photo_url_value = None
258-
self._profile_photo_url_present = False
197+
# Instance attribute type: str (validator is set below)
198+
profile_photo_url = bb.Attribute("profile_photo_url")
259199

260200
def _process_custom_annotations(self, annotation_type, field_path, processor):
261201
super(SetProfilePhotoResult, self)._process_custom_annotations(annotation_type, field_path, processor)
262202

263-
def __repr__(self):
264-
return 'SetProfilePhotoResult(profile_photo_url={!r})'.format(
265-
self._profile_photo_url_value,
266-
)
267-
268203
SetProfilePhotoResult_validator = bv.Struct(SetProfilePhotoResult)
269204

270205
PhotoSourceArg._base64_data_validator = bv.String()
@@ -276,9 +211,9 @@ def __repr__(self):
276211

277212
PhotoSourceArg.other = PhotoSourceArg('other')
278213

279-
SetProfilePhotoArg._photo_validator = PhotoSourceArg_validator
214+
SetProfilePhotoArg.photo.validator = PhotoSourceArg_validator
280215
SetProfilePhotoArg._all_field_names_ = set(['photo'])
281-
SetProfilePhotoArg._all_fields_ = [('photo', SetProfilePhotoArg._photo_validator)]
216+
SetProfilePhotoArg._all_fields_ = [('photo', SetProfilePhotoArg.photo.validator)]
282217

283218
SetProfilePhotoError._file_type_error_validator = bv.Void()
284219
SetProfilePhotoError._file_size_error_validator = bv.Void()
@@ -302,9 +237,9 @@ def __repr__(self):
302237
SetProfilePhotoError.transient_error = SetProfilePhotoError('transient_error')
303238
SetProfilePhotoError.other = SetProfilePhotoError('other')
304239

305-
SetProfilePhotoResult._profile_photo_url_validator = bv.String()
240+
SetProfilePhotoResult.profile_photo_url.validator = bv.String()
306241
SetProfilePhotoResult._all_field_names_ = set(['profile_photo_url'])
307-
SetProfilePhotoResult._all_fields_ = [('profile_photo_url', SetProfilePhotoResult._profile_photo_url_validator)]
242+
SetProfilePhotoResult._all_fields_ = [('profile_photo_url', SetProfilePhotoResult.profile_photo_url.validator)]
308243

309244
set_profile_photo = bb.Route(
310245
'set_profile_photo',

dropbox/async_.py

+8-56
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
# @generated
44
# flake8: noqa
55
# pylint: skip-file
6-
try:
7-
from . import stone_validators as bv
8-
from . import stone_base as bb
9-
except (ImportError, SystemError, ValueError):
10-
# Catch errors raised when importing a relative module when not in a package.
11-
# This makes testing this file directly (outside of a package) easier.
12-
import stone_validators as bv
13-
import stone_base as bb
6+
from __future__ import unicode_literals
7+
from stone.backends.python_rsrc import stone_base as bb
8+
from stone.backends.python_rsrc import stone_validators as bv
149

1510
class LaunchResultBase(bb.Union):
1611
"""
@@ -66,9 +61,6 @@ def get_async_job_id(self):
6661
def _process_custom_annotations(self, annotation_type, field_path, processor):
6762
super(LaunchResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)
6863

69-
def __repr__(self):
70-
return 'LaunchResultBase(%r, %r)' % (self._tag, self._value)
71-
7264
LaunchResultBase_validator = bv.Union(LaunchResultBase)
7365

7466
class LaunchEmptyResult(LaunchResultBase):
@@ -99,9 +91,6 @@ def is_complete(self):
9991
def _process_custom_annotations(self, annotation_type, field_path, processor):
10092
super(LaunchEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)
10193

102-
def __repr__(self):
103-
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)
104-
10594
LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)
10695

10796
class PollArg(bb.Struct):
@@ -114,50 +103,22 @@ class PollArg(bb.Struct):
114103

115104
__slots__ = [
116105
'_async_job_id_value',
117-
'_async_job_id_present',
118106
]
119107

120108
_has_required_fields = True
121109

122110
def __init__(self,
123111
async_job_id=None):
124-
self._async_job_id_value = None
125-
self._async_job_id_present = False
112+
self._async_job_id_value = bb.NOT_SET
126113
if async_job_id is not None:
127114
self.async_job_id = async_job_id
128115

129-
@property
130-
def async_job_id(self):
131-
"""
132-
Id of the asynchronous job. This is the value of a response returned
133-
from the method that launched the job.
134-
135-
:rtype: str
136-
"""
137-
if self._async_job_id_present:
138-
return self._async_job_id_value
139-
else:
140-
raise AttributeError("missing required field 'async_job_id'")
141-
142-
@async_job_id.setter
143-
def async_job_id(self, val):
144-
val = self._async_job_id_validator.validate(val)
145-
self._async_job_id_value = val
146-
self._async_job_id_present = True
147-
148-
@async_job_id.deleter
149-
def async_job_id(self):
150-
self._async_job_id_value = None
151-
self._async_job_id_present = False
116+
# Instance attribute type: str (validator is set below)
117+
async_job_id = bb.Attribute("async_job_id")
152118

153119
def _process_custom_annotations(self, annotation_type, field_path, processor):
154120
super(PollArg, self)._process_custom_annotations(annotation_type, field_path, processor)
155121

156-
def __repr__(self):
157-
return 'PollArg(async_job_id={!r})'.format(
158-
self._async_job_id_value,
159-
)
160-
161122
PollArg_validator = bv.Struct(PollArg)
162123

163124
class PollResultBase(bb.Union):
@@ -190,9 +151,6 @@ def is_in_progress(self):
190151
def _process_custom_annotations(self, annotation_type, field_path, processor):
191152
super(PollResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)
192153

193-
def __repr__(self):
194-
return 'PollResultBase(%r, %r)' % (self._tag, self._value)
195-
196154
PollResultBase_validator = bv.Union(PollResultBase)
197155

198156
class PollEmptyResult(PollResultBase):
@@ -222,9 +180,6 @@ def is_complete(self):
222180
def _process_custom_annotations(self, annotation_type, field_path, processor):
223181
super(PollEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)
224182

225-
def __repr__(self):
226-
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)
227-
228183
PollEmptyResult_validator = bv.Union(PollEmptyResult)
229184

230185
class PollError(bb.Union):
@@ -276,9 +231,6 @@ def is_other(self):
276231
def _process_custom_annotations(self, annotation_type, field_path, processor):
277232
super(PollError, self)._process_custom_annotations(annotation_type, field_path, processor)
278233

279-
def __repr__(self):
280-
return 'PollError(%r, %r)' % (self._tag, self._value)
281-
282234
PollError_validator = bv.Union(PollError)
283235

284236
AsyncJobId_validator = bv.String(min_length=1)
@@ -295,9 +247,9 @@ def __repr__(self):
295247

296248
LaunchEmptyResult.complete = LaunchEmptyResult('complete')
297249

298-
PollArg._async_job_id_validator = AsyncJobId_validator
250+
PollArg.async_job_id.validator = AsyncJobId_validator
299251
PollArg._all_field_names_ = set(['async_job_id'])
300-
PollArg._all_fields_ = [('async_job_id', PollArg._async_job_id_validator)]
252+
PollArg._all_fields_ = [('async_job_id', PollArg.async_job_id.validator)]
301253

302254
PollResultBase._in_progress_validator = bv.Void()
303255
PollResultBase._tagmap = {

0 commit comments

Comments
 (0)