Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 118 additions & 160 deletions dropbox/account.py

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions dropbox/account_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv


class ContainsDbidAnnotation(bb.AnnotationType):
"""
Annotation type should be applied to Response object fields which contain
account id
"""

__slots__ = [
"_authorize_caller",
'_authorize_caller',
]

def __init__(self, authorize_caller=True):
def __init__(self,
authorize_caller=True):
self._authorize_caller = authorize_caller

@property
Expand All @@ -29,4 +29,6 @@ def authorize_caller(self):
return self._authorize_caller


ROUTES = {}
ROUTES = {
}

85 changes: 34 additions & 51 deletions dropbox/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from stone.backends.python_rsrc import stone_base as bb
from stone.backends.python_rsrc import stone_validators as bv


class LaunchResultBase(bb.Union):
"""
Result returned by methods that launch an asynchronous job. A method who may
Expand Down Expand Up @@ -37,15 +36,15 @@ def async_job_id(cls, val):
:param str val:
:rtype: LaunchResultBase
"""
return cls("async_job_id", val)
return cls('async_job_id', val)

def is_async_job_id(self):
"""
Check if the union tag is ``async_job_id``.

:rtype: bool
"""
return self._tag == "async_job_id"
return self._tag == 'async_job_id'

def get_async_job_id(self):
"""
Expand All @@ -61,14 +60,10 @@ def get_async_job_id(self):
return self._value

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

super(LaunchResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)

LaunchResultBase_validator = bv.Union(LaunchResultBase)


class LaunchEmptyResult(LaunchResultBase):
"""
Result returned by methods that may either launch an asynchronous job or
Expand All @@ -92,17 +87,13 @@ def is_complete(self):

:rtype: bool
"""
return self._tag == "complete"
return self._tag == 'complete'

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

super(LaunchEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)

LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)


class PollArg(bb.Struct):
"""
Arguments for methods that poll the status of an asynchronous job.
Expand All @@ -113,12 +104,13 @@ class PollArg(bb.Struct):
"""

__slots__ = [
"_async_job_id_value",
'_async_job_id_value',
]

_has_required_fields = True

def __init__(self, async_job_id=None):
def __init__(self,
async_job_id=None):
self._async_job_id_value = bb.NOT_SET
if async_job_id is not None:
self.async_job_id = async_job_id
Expand All @@ -129,10 +121,8 @@ def __init__(self, async_job_id=None):
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PollArg, self)._process_custom_annotations(annotation_type, field_path, processor)


PollArg_validator = bv.Struct(PollArg)


class PollResultBase(bb.Union):
"""
Result returned by methods that poll for the status of an asynchronous job.
Expand All @@ -158,17 +148,13 @@ def is_in_progress(self):

:rtype: bool
"""
return self._tag == "in_progress"
return self._tag == 'in_progress'

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

super(PollResultBase, self)._process_custom_annotations(annotation_type, field_path, processor)

PollResultBase_validator = bv.Union(PollResultBase)


class PollEmptyResult(PollResultBase):
"""
Result returned by methods that poll for the status of an asynchronous job.
Expand All @@ -191,17 +177,13 @@ def is_complete(self):

:rtype: bool
"""
return self._tag == "complete"
return self._tag == 'complete'

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

super(PollEmptyResult, self)._process_custom_annotations(annotation_type, field_path, processor)

PollEmptyResult_validator = bv.Union(PollEmptyResult)


class PollError(bb.Union):
"""
Error returned by methods for polling the status of asynchronous job.
Expand All @@ -218,7 +200,7 @@ class PollError(bb.Union):
This should happen very rarely.
"""

_catch_all = "other"
_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_async_job_id = None
# Attribute is overwritten below the class definition
Expand All @@ -232,74 +214,75 @@ def is_invalid_async_job_id(self):

:rtype: bool
"""
return self._tag == "invalid_async_job_id"
return self._tag == 'invalid_async_job_id'

def is_internal_error(self):
"""
Check if the union tag is ``internal_error``.

:rtype: bool
"""
return self._tag == "internal_error"
return self._tag == 'internal_error'

def is_other(self):
"""
Check if the union tag is ``other``.

:rtype: bool
"""
return self._tag == "other"
return self._tag == 'other'

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


PollError_validator = bv.Union(PollError)

AsyncJobId_validator = bv.String(min_length=1)
LaunchResultBase._async_job_id_validator = AsyncJobId_validator
LaunchResultBase._tagmap = {
"async_job_id": LaunchResultBase._async_job_id_validator,
'async_job_id': LaunchResultBase._async_job_id_validator,
}

LaunchEmptyResult._complete_validator = bv.Void()
LaunchEmptyResult._tagmap = {
"complete": LaunchEmptyResult._complete_validator,
'complete': LaunchEmptyResult._complete_validator,
}
LaunchEmptyResult._tagmap.update(LaunchResultBase._tagmap)

LaunchEmptyResult.complete = LaunchEmptyResult("complete")
LaunchEmptyResult.complete = LaunchEmptyResult('complete')

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_field_names_ = set(['async_job_id'])
PollArg._all_fields_ = [('async_job_id', PollArg.async_job_id.validator)]

PollResultBase._in_progress_validator = bv.Void()
PollResultBase._tagmap = {
"in_progress": PollResultBase._in_progress_validator,
'in_progress': PollResultBase._in_progress_validator,
}

PollResultBase.in_progress = PollResultBase("in_progress")
PollResultBase.in_progress = PollResultBase('in_progress')

PollEmptyResult._complete_validator = bv.Void()
PollEmptyResult._tagmap = {
"complete": PollEmptyResult._complete_validator,
'complete': PollEmptyResult._complete_validator,
}
PollEmptyResult._tagmap.update(PollResultBase._tagmap)

PollEmptyResult.complete = PollEmptyResult("complete")
PollEmptyResult.complete = PollEmptyResult('complete')

PollError._invalid_async_job_id_validator = bv.Void()
PollError._internal_error_validator = bv.Void()
PollError._other_validator = bv.Void()
PollError._tagmap = {
"invalid_async_job_id": PollError._invalid_async_job_id_validator,
"internal_error": PollError._internal_error_validator,
"other": PollError._other_validator,
'invalid_async_job_id': PollError._invalid_async_job_id_validator,
'internal_error': PollError._internal_error_validator,
'other': PollError._other_validator,
}

PollError.invalid_async_job_id = PollError("invalid_async_job_id")
PollError.internal_error = PollError("internal_error")
PollError.other = PollError("other")
PollError.invalid_async_job_id = PollError('invalid_async_job_id')
PollError.internal_error = PollError('internal_error')
PollError.other = PollError('other')

ROUTES = {
}

ROUTES = {}
Loading
Loading