Skip to content

Commit

Permalink
Regenerate client using Stone 3.2.0 (#291)
Browse files Browse the repository at this point in the history
* update version requirement for Stone and regenerate client files

* add UPGRADING.md
  • Loading branch information
yuxiang-he authored Nov 18, 2020
1 parent 50f1d99 commit 0f1ad58
Show file tree
Hide file tree
Showing 33 changed files with 12,297 additions and 74,078 deletions.
13 changes: 13 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Upgrading the Dropbox SDK

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.
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)

# Upgrading from v10.X.X to v11.0.0
The major change that happened in this new version is that we regenerated the client files using Stone 3.2.0,
so relative imports are removed from the generated client files.
This created some issues with the imports in the non-generated files in `dropbox/`.
As a result, we renamed `dropbox.dropbox` to
`dropbox.dropbox_client`. If you used to do imports like `dropbox.dropbox.foo`, such imports need to be changed to `dropbox.dropbox_client.foo`.
However, we preserved the imports in `dropbox/__init__.py`, so imports like `from dropbox import DropboxOAuth2FlowNoRedirect`,
`from dropbox import Dropbox` will continue to work.
8 changes: 6 additions & 2 deletions dropbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from __future__ import absolute_import

from .dropbox import __version__, Dropbox, DropboxTeam, create_session # noqa: F401
from .oauth import DropboxOAuth2Flow, DropboxOAuth2FlowNoRedirect # noqa: F401
from dropbox.dropbox_client import ( # noqa: F401 # pylint: disable=unused-import
__version__, Dropbox, DropboxTeam, create_session
)
from dropbox.oauth import ( # noqa: F401 # pylint: disable=unused-import
DropboxOAuth2Flow, DropboxOAuth2FlowNoRedirect
)
91 changes: 13 additions & 78 deletions dropbox/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
# @generated
# flake8: noqa
# pylint: skip-file
try:
from . import stone_validators as bv
from . import stone_base as bb
except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier.
import stone_validators as bv
import stone_base as bb
from __future__ import unicode_literals
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv

class PhotoSourceArg(bb.Union):
"""
Expand Down Expand Up @@ -68,9 +63,6 @@ def get_base64_data(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PhotoSourceArg, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'PhotoSourceArg(%r, %r)' % (self._tag, self._value)

PhotoSourceArg_validator = bv.Union(PhotoSourceArg)

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

__slots__ = [
'_photo_value',
'_photo_present',
]

_has_required_fields = True

def __init__(self,
photo=None):
self._photo_value = None
self._photo_present = False
self._photo_value = bb.NOT_SET
if photo is not None:
self.photo = photo

@property
def photo(self):
"""
Image to set as the user's new profile photo.
:rtype: PhotoSourceArg
"""
if self._photo_present:
return self._photo_value
else:
raise AttributeError("missing required field 'photo'")

@photo.setter
def photo(self, val):
self._photo_validator.validate_type_only(val)
self._photo_value = val
self._photo_present = True

@photo.deleter
def photo(self):
self._photo_value = None
self._photo_present = False
# Instance attribute type: PhotoSourceArg (validator is set below)
photo = bb.Attribute("photo", user_defined=True)

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

def __repr__(self):
return 'SetProfilePhotoArg(photo={!r})'.format(
self._photo_value,
)

SetProfilePhotoArg_validator = bv.Struct(SetProfilePhotoArg)

class SetProfilePhotoError(bb.Union):
Expand Down Expand Up @@ -209,9 +174,6 @@ def is_other(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SetProfilePhotoError, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'SetProfilePhotoError(%r, %r)' % (self._tag, self._value)

SetProfilePhotoError_validator = bv.Union(SetProfilePhotoError)

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

__slots__ = [
'_profile_photo_url_value',
'_profile_photo_url_present',
]

_has_required_fields = True

def __init__(self,
profile_photo_url=None):
self._profile_photo_url_value = None
self._profile_photo_url_present = False
self._profile_photo_url_value = bb.NOT_SET
if profile_photo_url is not None:
self.profile_photo_url = profile_photo_url

@property
def profile_photo_url(self):
"""
URL for the photo representing the user, if one is set.
:rtype: str
"""
if self._profile_photo_url_present:
return self._profile_photo_url_value
else:
raise AttributeError("missing required field 'profile_photo_url'")

@profile_photo_url.setter
def profile_photo_url(self, val):
val = self._profile_photo_url_validator.validate(val)
self._profile_photo_url_value = val
self._profile_photo_url_present = True

@profile_photo_url.deleter
def profile_photo_url(self):
self._profile_photo_url_value = None
self._profile_photo_url_present = False
# Instance attribute type: str (validator is set below)
profile_photo_url = bb.Attribute("profile_photo_url")

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

def __repr__(self):
return 'SetProfilePhotoResult(profile_photo_url={!r})'.format(
self._profile_photo_url_value,
)

SetProfilePhotoResult_validator = bv.Struct(SetProfilePhotoResult)

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

PhotoSourceArg.other = PhotoSourceArg('other')

SetProfilePhotoArg._photo_validator = PhotoSourceArg_validator
SetProfilePhotoArg.photo.validator = PhotoSourceArg_validator
SetProfilePhotoArg._all_field_names_ = set(['photo'])
SetProfilePhotoArg._all_fields_ = [('photo', SetProfilePhotoArg._photo_validator)]
SetProfilePhotoArg._all_fields_ = [('photo', SetProfilePhotoArg.photo.validator)]

SetProfilePhotoError._file_type_error_validator = bv.Void()
SetProfilePhotoError._file_size_error_validator = bv.Void()
Expand All @@ -302,9 +237,9 @@ def __repr__(self):
SetProfilePhotoError.transient_error = SetProfilePhotoError('transient_error')
SetProfilePhotoError.other = SetProfilePhotoError('other')

SetProfilePhotoResult._profile_photo_url_validator = bv.String()
SetProfilePhotoResult.profile_photo_url.validator = bv.String()
SetProfilePhotoResult._all_field_names_ = set(['profile_photo_url'])
SetProfilePhotoResult._all_fields_ = [('profile_photo_url', SetProfilePhotoResult._profile_photo_url_validator)]
SetProfilePhotoResult._all_fields_ = [('profile_photo_url', SetProfilePhotoResult.profile_photo_url.validator)]

set_profile_photo = bb.Route(
'set_profile_photo',
Expand Down
64 changes: 8 additions & 56 deletions dropbox/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
# @generated
# flake8: noqa
# pylint: skip-file
try:
from . import stone_validators as bv
from . import stone_base as bb
except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier.
import stone_validators as bv
import stone_base as bb
from __future__ import unicode_literals
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv

class LaunchResultBase(bb.Union):
"""
Expand Down Expand Up @@ -66,9 +61,6 @@ def get_async_job_id(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(LaunchResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'LaunchResultBase(%r, %r)' % (self._tag, self._value)

LaunchResultBase_validator = bv.Union(LaunchResultBase)

class LaunchEmptyResult(LaunchResultBase):
Expand Down Expand Up @@ -99,9 +91,6 @@ def is_complete(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(LaunchEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)

LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)

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

__slots__ = [
'_async_job_id_value',
'_async_job_id_present',
]

_has_required_fields = True

def __init__(self,
async_job_id=None):
self._async_job_id_value = None
self._async_job_id_present = False
self._async_job_id_value = bb.NOT_SET
if async_job_id is not None:
self.async_job_id = async_job_id

@property
def async_job_id(self):
"""
Id of the asynchronous job. This is the value of a response returned
from the method that launched the job.
:rtype: str
"""
if self._async_job_id_present:
return self._async_job_id_value
else:
raise AttributeError("missing required field 'async_job_id'")

@async_job_id.setter
def async_job_id(self, val):
val = self._async_job_id_validator.validate(val)
self._async_job_id_value = val
self._async_job_id_present = True

@async_job_id.deleter
def async_job_id(self):
self._async_job_id_value = None
self._async_job_id_present = False
# Instance attribute type: str (validator is set below)
async_job_id = bb.Attribute("async_job_id")

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

def __repr__(self):
return 'PollArg(async_job_id={!r})'.format(
self._async_job_id_value,
)

PollArg_validator = bv.Struct(PollArg)

class PollResultBase(bb.Union):
Expand Down Expand Up @@ -190,9 +151,6 @@ def is_in_progress(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PollResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'PollResultBase(%r, %r)' % (self._tag, self._value)

PollResultBase_validator = bv.Union(PollResultBase)

class PollEmptyResult(PollResultBase):
Expand Down Expand Up @@ -222,9 +180,6 @@ def is_complete(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PollEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)

PollEmptyResult_validator = bv.Union(PollEmptyResult)

class PollError(bb.Union):
Expand Down Expand Up @@ -276,9 +231,6 @@ def is_other(self):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PollError, self)._process_custom_annotations(annotation_type, field_path, processor)

def __repr__(self):
return 'PollError(%r, %r)' % (self._tag, self._value)

PollError_validator = bv.Union(PollError)

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

LaunchEmptyResult.complete = LaunchEmptyResult('complete')

PollArg._async_job_id_validator = AsyncJobId_validator
PollArg.async_job_id.validator = AsyncJobId_validator
PollArg._all_field_names_ = set(['async_job_id'])
PollArg._all_fields_ = [('async_job_id', PollArg._async_job_id_validator)]
PollArg._all_fields_ = [('async_job_id', PollArg.async_job_id.validator)]

PollResultBase._in_progress_validator = bv.Void()
PollResultBase._tagmap = {
Expand Down
Loading

0 comments on commit 0f1ad58

Please sign in to comment.