updated Dropbox lib

This commit is contained in:
Rob Weber 2019-08-28 14:48:24 -05:00
parent 30f8b93629
commit 456ebe9374
25 changed files with 66252 additions and 17023 deletions

View File

@ -1,310 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
try: # If you have issues importing this module because Python recognizes it as a keyword, use async_ instead.
from . import stone_validators as bv from .async_ import *
from . import stone_base as bb
except (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
class LaunchResultBase(bb.Union):
"""
Result returned by methods that launch an asynchronous job. A method who may
either launch an asynchronous job, or complete the request synchronously,
can use this union by extending it, and adding a 'complete' field with the
type of the synchronous response. See :class:`LaunchEmptyResult` for an
example.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar str async_job_id: This response indicates that the processing is
asynchronous. The string is an id that can be used to obtain the status
of the asynchronous job.
"""
_catch_all = None
@classmethod
def async_job_id(cls, val):
"""
Create an instance of this class set to the ``async_job_id`` tag with
value ``val``.
:param str val:
:rtype: LaunchResultBase
"""
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'
def get_async_job_id(self):
"""
This response indicates that the processing is asynchronous. The string
is an id that can be used to obtain the status of the asynchronous job.
Only call this if :meth:`is_async_job_id` is true.
:rtype: str
"""
if not self.is_async_job_id():
raise AttributeError("tag 'async_job_id' not set")
return self._value
def __repr__(self):
return 'LaunchResultBase(%r, %r)' % (self._tag, self._value)
LaunchResultBase_validator = bv.Union(LaunchResultBase)
class LaunchEmptyResult(LaunchResultBase):
"""
Result returned by methods that may either launch an asynchronous job or
complete synchronously. Upon synchronous completion of the job, no
additional information is returned.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar complete: The job finished synchronously and successfully.
"""
# Attribute is overwritten below the class definition
complete = None
def is_complete(self):
"""
Check if the union tag is ``complete``.
:rtype: bool
"""
return self._tag == 'complete'
def __repr__(self):
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)
LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)
class PollArg(object):
"""
Arguments for methods that poll the status of an asynchronous job.
:ivar async_job_id: Id of the asynchronous job. This is the value of a
response returned from the method that launched the job.
"""
__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
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
def __repr__(self):
return 'PollArg(async_job_id={!r})'.format(
self._async_job_id_value,
)
PollArg_validator = bv.Struct(PollArg)
class PollResultBase(bb.Union):
"""
Result returned by methods that poll for the status of an asynchronous job.
Unions that extend this union should add a 'complete' field with a type of
the information returned upon job completion. See :class:`PollEmptyResult`
for an example.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar in_progress: The asynchronous job is still in progress.
"""
_catch_all = None
# Attribute is overwritten below the class definition
in_progress = None
def is_in_progress(self):
"""
Check if the union tag is ``in_progress``.
:rtype: bool
"""
return self._tag == 'in_progress'
def __repr__(self):
return 'PollResultBase(%r, %r)' % (self._tag, self._value)
PollResultBase_validator = bv.Union(PollResultBase)
class PollEmptyResult(PollResultBase):
"""
Result returned by methods that poll for the status of an asynchronous job.
Upon completion of the job, no additional information is returned.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar complete: The asynchronous job has completed successfully.
"""
# Attribute is overwritten below the class definition
complete = None
def is_complete(self):
"""
Check if the union tag is ``complete``.
:rtype: bool
"""
return self._tag == 'complete'
def __repr__(self):
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)
PollEmptyResult_validator = bv.Union(PollEmptyResult)
class PollError(bb.Union):
"""
Error returned by methods for polling the status of asynchronous job.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar invalid_async_job_id: The job ID is invalid.
:ivar internal_error: Something went wrong with the job on Dropbox's end.
You'll need to verify that the action you were taking succeeded, and if
not, try again. This should happen very rarely.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_async_job_id = None
# Attribute is overwritten below the class definition
internal_error = None
# Attribute is overwritten below the class definition
other = None
def is_invalid_async_job_id(self):
"""
Check if the union tag is ``invalid_async_job_id``.
:rtype: bool
"""
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'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def __repr__(self):
return 'PollError(%r, %r)' % (self._tag, self._value)
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,
}
LaunchEmptyResult._complete_validator = bv.Void()
LaunchEmptyResult._tagmap = {
'complete': LaunchEmptyResult._complete_validator,
}
LaunchEmptyResult._tagmap.update(LaunchResultBase._tagmap)
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)]
PollResultBase._in_progress_validator = bv.Void()
PollResultBase._tagmap = {
'in_progress': PollResultBase._in_progress_validator,
}
PollResultBase.in_progress = PollResultBase('in_progress')
PollEmptyResult._complete_validator = bv.Void()
PollEmptyResult._tagmap = {
'complete': PollEmptyResult._complete_validator,
}
PollEmptyResult._tagmap.update(PollResultBase._tagmap)
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,
}
PollError.invalid_async_job_id = PollError('invalid_async_job_id')
PollError.internal_error = PollError('internal_error')
PollError.other = PollError('other')
ROUTES = {
}

View File

@ -0,0 +1,332 @@
# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# @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
class LaunchResultBase(bb.Union):
"""
Result returned by methods that launch an asynchronous job. A method who may
either launch an asynchronous job, or complete the request synchronously,
can use this union by extending it, and adding a 'complete' field with the
type of the synchronous response. See :class:`LaunchEmptyResult` for an
example.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar str async.LaunchResultBase.async_job_id: This response indicates that
the processing is asynchronous. The string is an id that can be used to
obtain the status of the asynchronous job.
"""
_catch_all = None
@classmethod
def async_job_id(cls, val):
"""
Create an instance of this class set to the ``async_job_id`` tag with
value ``val``.
:param str val:
:rtype: LaunchResultBase
"""
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'
def get_async_job_id(self):
"""
This response indicates that the processing is asynchronous. The string
is an id that can be used to obtain the status of the asynchronous job.
Only call this if :meth:`is_async_job_id` is true.
:rtype: str
"""
if not self.is_async_job_id():
raise AttributeError("tag 'async_job_id' not set")
return self._value
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):
"""
Result returned by methods that may either launch an asynchronous job or
complete synchronously. Upon synchronous completion of the job, no
additional information is returned.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar async.LaunchEmptyResult.complete: The job finished synchronously and
successfully.
"""
# Attribute is overwritten below the class definition
complete = None
def is_complete(self):
"""
Check if the union tag is ``complete``.
:rtype: bool
"""
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)
def __repr__(self):
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)
LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)
class PollArg(bb.Struct):
"""
Arguments for methods that poll the status of an asynchronous job.
:ivar async.PollArg.async_job_id: Id of the asynchronous job. This is the
value of a response returned from the method that launched the job.
"""
__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
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
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):
"""
Result returned by methods that poll for the status of an asynchronous job.
Unions that extend this union should add a 'complete' field with a type of
the information returned upon job completion. See :class:`PollEmptyResult`
for an example.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar async.PollResultBase.in_progress: The asynchronous job is still in
progress.
"""
_catch_all = None
# Attribute is overwritten below the class definition
in_progress = None
def is_in_progress(self):
"""
Check if the union tag is ``in_progress``.
:rtype: bool
"""
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)
def __repr__(self):
return 'PollResultBase(%r, %r)' % (self._tag, self._value)
PollResultBase_validator = bv.Union(PollResultBase)
class PollEmptyResult(PollResultBase):
"""
Result returned by methods that poll for the status of an asynchronous job.
Upon completion of the job, no additional information is returned.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar async.PollEmptyResult.complete: The asynchronous job has completed
successfully.
"""
# Attribute is overwritten below the class definition
complete = None
def is_complete(self):
"""
Check if the union tag is ``complete``.
:rtype: bool
"""
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)
def __repr__(self):
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)
PollEmptyResult_validator = bv.Union(PollEmptyResult)
class PollError(bb.Union):
"""
Error returned by methods for polling the status of asynchronous job.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar async.PollError.invalid_async_job_id: The job ID is invalid.
:ivar async.PollError.internal_error: Something went wrong with the job on
Dropbox's end. You'll need to verify that the action you were taking
succeeded, and if not, try again. This should happen very rarely.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_async_job_id = None
# Attribute is overwritten below the class definition
internal_error = None
# Attribute is overwritten below the class definition
other = None
def is_invalid_async_job_id(self):
"""
Check if the union tag is ``invalid_async_job_id``.
:rtype: bool
"""
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'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
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)
def __repr__(self):
return 'PollError(%r, %r)' % (self._tag, self._value)
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,
}
LaunchEmptyResult._complete_validator = bv.Void()
LaunchEmptyResult._tagmap = {
'complete': LaunchEmptyResult._complete_validator,
}
LaunchEmptyResult._tagmap.update(LaunchResultBase._tagmap)
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)]
PollResultBase._in_progress_validator = bv.Void()
PollResultBase._tagmap = {
'in_progress': PollResultBase._in_progress_validator,
}
PollResultBase.in_progress = PollResultBase('in_progress')
PollEmptyResult._complete_validator = bv.Void()
PollEmptyResult._tagmap = {
'complete': PollEmptyResult._complete_validator,
}
PollEmptyResult._tagmap.update(PollResultBase._tagmap)
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,
}
PollError.invalid_async_job_id = PollError('invalid_async_job_id')
PollError.internal_error = PollError('internal_error')
PollError.other = PollError('other')
ROUTES = {
}

View File

@ -1,11 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
@ -20,10 +21,10 @@ class AccessError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar InvalidAccountTypeError invalid_account_type: Current account type :ivar InvalidAccountTypeError AccessError.invalid_account_type: Current
cannot access the resource. account type cannot access the resource.
:ivar PaperAccessError paper_access_denied: Current account cannot access :ivar PaperAccessError AccessError.paper_access_denied: Current account
Paper. cannot access Paper.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -100,6 +101,9 @@ class AccessError(bb.Union):
raise AttributeError("tag 'paper_access_denied' not set") raise AttributeError("tag 'paper_access_denied' not set")
return self._value return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(AccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'AccessError(%r, %r)' % (self._tag, self._value) return 'AccessError(%r, %r)' % (self._tag, self._value)
@ -113,12 +117,15 @@ class AuthError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar invalid_access_token: The access token is invalid. :ivar auth.AuthError.invalid_access_token: The access token is invalid.
:ivar invalid_select_user: The user specified in 'Dropbox-API-Select-User' :ivar auth.AuthError.invalid_select_user: The user specified in
is no longer on the team. 'Dropbox-API-Select-User' is no longer on the team.
:ivar invalid_select_admin: The user specified in 'Dropbox-API-Select-Admin' :ivar auth.AuthError.invalid_select_admin: The user specified in
is not a Dropbox Business team admin. 'Dropbox-API-Select-Admin' is not a Dropbox Business team admin.
:ivar user_suspended: The user has been suspended. :ivar auth.AuthError.user_suspended: The user has been suspended.
:ivar auth.AuthError.expired_access_token: The access token has expired.
:ivar TokenScopeError AuthError.missing_scope: The access token does not
have the required scope to access the route.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -131,8 +138,21 @@ class AuthError(bb.Union):
# Attribute is overwritten below the class definition # Attribute is overwritten below the class definition
user_suspended = None user_suspended = None
# Attribute is overwritten below the class definition # Attribute is overwritten below the class definition
expired_access_token = None
# Attribute is overwritten below the class definition
other = None other = None
@classmethod
def missing_scope(cls, val):
"""
Create an instance of this class set to the ``missing_scope`` tag with
value ``val``.
:param TokenScopeError val:
:rtype: AuthError
"""
return cls('missing_scope', val)
def is_invalid_access_token(self): def is_invalid_access_token(self):
""" """
Check if the union tag is ``invalid_access_token``. Check if the union tag is ``invalid_access_token``.
@ -165,6 +185,22 @@ class AuthError(bb.Union):
""" """
return self._tag == 'user_suspended' return self._tag == 'user_suspended'
def is_expired_access_token(self):
"""
Check if the union tag is ``expired_access_token``.
:rtype: bool
"""
return self._tag == 'expired_access_token'
def is_missing_scope(self):
"""
Check if the union tag is ``missing_scope``.
:rtype: bool
"""
return self._tag == 'missing_scope'
def is_other(self): def is_other(self):
""" """
Check if the union tag is ``other``. Check if the union tag is ``other``.
@ -173,6 +209,21 @@ class AuthError(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def get_missing_scope(self):
"""
The access token does not have the required scope to access the route.
Only call this if :meth:`is_missing_scope` is true.
:rtype: TokenScopeError
"""
if not self.is_missing_scope():
raise AttributeError("tag 'missing_scope' not set")
return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(AuthError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'AuthError(%r, %r)' % (self._tag, self._value) return 'AuthError(%r, %r)' % (self._tag, self._value)
@ -184,10 +235,10 @@ class InvalidAccountTypeError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar endpoint: Current account type doesn't have permission to access this :ivar auth.InvalidAccountTypeError.endpoint: Current account type doesn't
route endpoint. have permission to access this route endpoint.
:ivar feature: Current account type doesn't have permission to access this :ivar auth.InvalidAccountTypeError.feature: Current account type doesn't
feature. have permission to access this feature.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -222,6 +273,9 @@ class InvalidAccountTypeError(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(InvalidAccountTypeError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'InvalidAccountTypeError(%r, %r)' % (self._tag, self._value) return 'InvalidAccountTypeError(%r, %r)' % (self._tag, self._value)
@ -233,8 +287,9 @@ class PaperAccessError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar paper_disabled: Paper is disabled. :ivar auth.PaperAccessError.paper_disabled: Paper is disabled.
:ivar not_paper_user: The provided user has not used Paper yet. :ivar auth.PaperAccessError.not_paper_user: The provided user has not used
Paper yet.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -269,18 +324,22 @@ class PaperAccessError(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PaperAccessError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PaperAccessError(%r, %r)' % (self._tag, self._value) return 'PaperAccessError(%r, %r)' % (self._tag, self._value)
PaperAccessError_validator = bv.Union(PaperAccessError) PaperAccessError_validator = bv.Union(PaperAccessError)
class RateLimitError(object): class RateLimitError(bb.Struct):
""" """
Error occurred because the app is being rate limited. Error occurred because the app is being rate limited.
:ivar reason: The reason why the app is being rate limited. :ivar auth.RateLimitError.reason: The reason why the app is being rate
:ivar retry_after: The number of seconds that the app should wait before limited.
making another request. :ivar auth.RateLimitError.retry_after: The number of seconds that the app
should wait before making another request.
""" """
__slots__ = [ __slots__ = [
@ -333,7 +392,7 @@ class RateLimitError(object):
The number of seconds that the app should wait before making another The number of seconds that the app should wait before making another
request. request.
:rtype: long :rtype: int
""" """
if self._retry_after_present: if self._retry_after_present:
return self._retry_after_value return self._retry_after_value
@ -351,6 +410,9 @@ class RateLimitError(object):
self._retry_after_value = None self._retry_after_value = None
self._retry_after_present = False self._retry_after_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(RateLimitError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'RateLimitError(reason={!r}, retry_after={!r})'.format( return 'RateLimitError(reason={!r}, retry_after={!r})'.format(
self._reason_value, self._reason_value,
@ -365,10 +427,10 @@ class RateLimitReason(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar too_many_requests: You are making too many requests in the past few :ivar auth.RateLimitReason.too_many_requests: You are making too many
minutes. requests in the past few minutes.
:ivar too_many_write_operations: There are currently too many write :ivar auth.RateLimitReason.too_many_write_operations: There are currently
operations happening in the user's Dropbox. too many write operations happening in the user's Dropbox.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -403,16 +465,20 @@ class RateLimitReason(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(RateLimitReason, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'RateLimitReason(%r, %r)' % (self._tag, self._value) return 'RateLimitReason(%r, %r)' % (self._tag, self._value)
RateLimitReason_validator = bv.Union(RateLimitReason) RateLimitReason_validator = bv.Union(RateLimitReason)
class TokenFromOAuth1Arg(object): class TokenFromOAuth1Arg(bb.Struct):
""" """
:ivar oauth1_token: The supplied OAuth 1.0 access token. :ivar auth.TokenFromOAuth1Arg.oauth1_token: The supplied OAuth 1.0 access
:ivar oauth1_token_secret: The token secret associated with the supplied token.
access token. :ivar auth.TokenFromOAuth1Arg.oauth1_token_secret: The token secret
associated with the supplied access token.
""" """
__slots__ = [ __slots__ = [
@ -482,6 +548,9 @@ class TokenFromOAuth1Arg(object):
self._oauth1_token_secret_value = None self._oauth1_token_secret_value = None
self._oauth1_token_secret_present = False self._oauth1_token_secret_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenFromOAuth1Arg, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TokenFromOAuth1Arg(oauth1_token={!r}, oauth1_token_secret={!r})'.format( return 'TokenFromOAuth1Arg(oauth1_token={!r}, oauth1_token_secret={!r})'.format(
self._oauth1_token_value, self._oauth1_token_value,
@ -496,10 +565,10 @@ class TokenFromOAuth1Error(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar invalid_oauth1_token_info: Part or all of the OAuth 1.0 access token :ivar auth.TokenFromOAuth1Error.invalid_oauth1_token_info: Part or all of
info is invalid. the OAuth 1.0 access token info is invalid.
:ivar app_id_mismatch: The authorized app does not match the app associated :ivar auth.TokenFromOAuth1Error.app_id_mismatch: The authorized app does not
with the supplied access token. match the app associated with the supplied access token.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -534,15 +603,18 @@ class TokenFromOAuth1Error(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenFromOAuth1Error, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TokenFromOAuth1Error(%r, %r)' % (self._tag, self._value) return 'TokenFromOAuth1Error(%r, %r)' % (self._tag, self._value)
TokenFromOAuth1Error_validator = bv.Union(TokenFromOAuth1Error) TokenFromOAuth1Error_validator = bv.Union(TokenFromOAuth1Error)
class TokenFromOAuth1Result(object): class TokenFromOAuth1Result(bb.Struct):
""" """
:ivar oauth2_token: The OAuth 2.0 token generated from the supplied OAuth :ivar auth.TokenFromOAuth1Result.oauth2_token: The OAuth 2.0 token generated
1.0 token. from the supplied OAuth 1.0 token.
""" """
__slots__ = [ __slots__ = [
@ -582,6 +654,9 @@ class TokenFromOAuth1Result(object):
self._oauth2_token_value = None self._oauth2_token_value = None
self._oauth2_token_present = False self._oauth2_token_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenFromOAuth1Result, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TokenFromOAuth1Result(oauth2_token={!r})'.format( return 'TokenFromOAuth1Result(oauth2_token={!r})'.format(
self._oauth2_token_value, self._oauth2_token_value,
@ -589,6 +664,59 @@ class TokenFromOAuth1Result(object):
TokenFromOAuth1Result_validator = bv.Struct(TokenFromOAuth1Result) TokenFromOAuth1Result_validator = bv.Struct(TokenFromOAuth1Result)
class TokenScopeError(bb.Struct):
"""
:ivar auth.TokenScopeError.required_scope: The required scope to access the
route.
"""
__slots__ = [
'_required_scope_value',
'_required_scope_present',
]
_has_required_fields = True
def __init__(self,
required_scope=None):
self._required_scope_value = None
self._required_scope_present = False
if required_scope is not None:
self.required_scope = required_scope
@property
def required_scope(self):
"""
The required scope to access the route.
:rtype: str
"""
if self._required_scope_present:
return self._required_scope_value
else:
raise AttributeError("missing required field 'required_scope'")
@required_scope.setter
def required_scope(self, val):
val = self._required_scope_validator.validate(val)
self._required_scope_value = val
self._required_scope_present = True
@required_scope.deleter
def required_scope(self):
self._required_scope_value = None
self._required_scope_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TokenScopeError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'TokenScopeError(required_scope={!r})'.format(
self._required_scope_value,
)
TokenScopeError_validator = bv.Struct(TokenScopeError)
AccessError._invalid_account_type_validator = InvalidAccountTypeError_validator AccessError._invalid_account_type_validator = InvalidAccountTypeError_validator
AccessError._paper_access_denied_validator = PaperAccessError_validator AccessError._paper_access_denied_validator = PaperAccessError_validator
AccessError._other_validator = bv.Void() AccessError._other_validator = bv.Void()
@ -604,12 +732,16 @@ AuthError._invalid_access_token_validator = bv.Void()
AuthError._invalid_select_user_validator = bv.Void() AuthError._invalid_select_user_validator = bv.Void()
AuthError._invalid_select_admin_validator = bv.Void() AuthError._invalid_select_admin_validator = bv.Void()
AuthError._user_suspended_validator = bv.Void() AuthError._user_suspended_validator = bv.Void()
AuthError._expired_access_token_validator = bv.Void()
AuthError._missing_scope_validator = TokenScopeError_validator
AuthError._other_validator = bv.Void() AuthError._other_validator = bv.Void()
AuthError._tagmap = { AuthError._tagmap = {
'invalid_access_token': AuthError._invalid_access_token_validator, 'invalid_access_token': AuthError._invalid_access_token_validator,
'invalid_select_user': AuthError._invalid_select_user_validator, 'invalid_select_user': AuthError._invalid_select_user_validator,
'invalid_select_admin': AuthError._invalid_select_admin_validator, 'invalid_select_admin': AuthError._invalid_select_admin_validator,
'user_suspended': AuthError._user_suspended_validator, 'user_suspended': AuthError._user_suspended_validator,
'expired_access_token': AuthError._expired_access_token_validator,
'missing_scope': AuthError._missing_scope_validator,
'other': AuthError._other_validator, 'other': AuthError._other_validator,
} }
@ -617,6 +749,7 @@ AuthError.invalid_access_token = AuthError('invalid_access_token')
AuthError.invalid_select_user = AuthError('invalid_select_user') AuthError.invalid_select_user = AuthError('invalid_select_user')
AuthError.invalid_select_admin = AuthError('invalid_select_admin') AuthError.invalid_select_admin = AuthError('invalid_select_admin')
AuthError.user_suspended = AuthError('user_suspended') AuthError.user_suspended = AuthError('user_suspended')
AuthError.expired_access_token = AuthError('expired_access_token')
AuthError.other = AuthError('other') AuthError.other = AuthError('other')
InvalidAccountTypeError._endpoint_validator = bv.Void() InvalidAccountTypeError._endpoint_validator = bv.Void()
@ -697,8 +830,13 @@ TokenFromOAuth1Result._oauth2_token_validator = bv.String(min_length=1)
TokenFromOAuth1Result._all_field_names_ = set(['oauth2_token']) TokenFromOAuth1Result._all_field_names_ = set(['oauth2_token'])
TokenFromOAuth1Result._all_fields_ = [('oauth2_token', TokenFromOAuth1Result._oauth2_token_validator)] TokenFromOAuth1Result._all_fields_ = [('oauth2_token', TokenFromOAuth1Result._oauth2_token_validator)]
TokenScopeError._required_scope_validator = bv.String()
TokenScopeError._all_field_names_ = set(['required_scope'])
TokenScopeError._all_fields_ = [('required_scope', TokenScopeError._required_scope_validator)]
token_from_oauth1 = bb.Route( token_from_oauth1 = bb.Route(
'token/from_oauth1', 'token/from_oauth1',
1,
False, False,
TokenFromOAuth1Arg_validator, TokenFromOAuth1Arg_validator,
TokenFromOAuth1Result_validator, TokenFromOAuth1Result_validator,
@ -708,6 +846,7 @@ token_from_oauth1 = bb.Route(
) )
token_revoke = bb.Route( token_revoke = bb.Route(
'token/revoke', 'token/revoke',
1,
False, False,
bv.Void(), bv.Void(),
bv.Void(), bv.Void(),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,50 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
import stone_base as bb import stone_base as bb
class InvalidPathRootError(object):
"""
:ivar path_root: The latest path root id for user's team if the user is
still in a team.
"""
__slots__ = [
'_path_root_value',
'_path_root_present',
]
_has_required_fields = False
def __init__(self,
path_root=None):
self._path_root_value = None
self._path_root_present = False
if path_root is not None:
self.path_root = path_root
@property
def path_root(self):
"""
The latest path root id for user's team if the user is still in a team.
:rtype: str
"""
if self._path_root_present:
return self._path_root_value
else:
return None
@path_root.setter
def path_root(self, val):
if val is None:
del self.path_root
return
val = self._path_root_validator.validate(val)
self._path_root_value = val
self._path_root_present = True
@path_root.deleter
def path_root(self):
self._path_root_value = None
self._path_root_present = False
def __repr__(self):
return 'InvalidPathRootError(path_root={!r})'.format(
self._path_root_value,
)
InvalidPathRootError_validator = bv.Struct(InvalidPathRootError)
class PathRoot(bb.Union): class PathRoot(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar home: Paths are relative to the authenticating user's home directory, :ivar common.PathRoot.home: Paths are relative to the authenticating user's
whether or not that user belongs to a team. home namespace, whether or not that user belongs to a team.
:ivar member_home: Paths are relative to the authenticating team member's :ivar str common.PathRoot.root: Paths are relative to the authenticating
home directory. (This results in ``PathRootError.invalid`` if the user user's root namespace (This results in
does not belong to a team.). :field:`PathRootError.invalid_root` if the user's root namespace has
:ivar str team: Paths are relative to the given team directory. (This changed.).
results in :field:`PathRootError.invalid` if the user is not a member of :ivar str common.PathRoot.namespace_id: Paths are relative to given
the team associated with that path root id.). namespace id (This results in :field:`PathRootError.no_permission` if
:ivar user_home: Paths are relative to the user's home directory. (This you don't have access to this namespace.).
results in ``PathRootError.invalid`` if the belongs to a team.).
:ivar str namespace_id: Paths are relative to given namespace id (This
results in :field:`PathRootError.no_permission` if you don't have access
to this namespace.).
""" """
_catch_all = 'other' _catch_all = 'other'
# Attribute is overwritten below the class definition # Attribute is overwritten below the class definition
home = None home = None
# Attribute is overwritten below the class definition # Attribute is overwritten below the class definition
member_home = None
# Attribute is overwritten below the class definition
user_home = None
# Attribute is overwritten below the class definition
other = None other = None
@classmethod @classmethod
def team(cls, val): def root(cls, val):
""" """
Create an instance of this class set to the ``team`` tag with value Create an instance of this class set to the ``root`` tag with value
``val``. ``val``.
:param str val: :param str val:
:rtype: PathRoot :rtype: PathRoot
""" """
return cls('team', val) return cls('root', val)
@classmethod @classmethod
def namespace_id(cls, val): def namespace_id(cls, val):
@ -125,29 +65,13 @@ class PathRoot(bb.Union):
""" """
return self._tag == 'home' return self._tag == 'home'
def is_member_home(self): def is_root(self):
""" """
Check if the union tag is ``member_home``. Check if the union tag is ``root``.
:rtype: bool :rtype: bool
""" """
return self._tag == 'member_home' return self._tag == 'root'
def is_team(self):
"""
Check if the union tag is ``team``.
:rtype: bool
"""
return self._tag == 'team'
def is_user_home(self):
"""
Check if the union tag is ``user_home``.
:rtype: bool
"""
return self._tag == 'user_home'
def is_namespace_id(self): def is_namespace_id(self):
""" """
@ -165,18 +89,18 @@ class PathRoot(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def get_team(self): def get_root(self):
""" """
Paths are relative to the given team directory. (This results in Paths are relative to the authenticating user's root namespace (This
``PathRootError.invalid`` if the user is not a member of the team results in ``PathRootError.invalid_root`` if the user's root namespace
associated with that path root id.). has changed.).
Only call this if :meth:`is_team` is true. Only call this if :meth:`is_root` is true.
:rtype: str :rtype: str
""" """
if not self.is_team(): if not self.is_root():
raise AttributeError("tag 'team' not set") raise AttributeError("tag 'root' not set")
return self._value return self._value
def get_namespace_id(self): def get_namespace_id(self):
@ -193,6 +117,9 @@ class PathRoot(bb.Union):
raise AttributeError("tag 'namespace_id' not set") raise AttributeError("tag 'namespace_id' not set")
return self._value return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PathRoot, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PathRoot(%r, %r)' % (self._tag, self._value) return 'PathRoot(%r, %r)' % (self._tag, self._value)
@ -204,10 +131,11 @@ class PathRootError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar InvalidPathRootError invalid: The path root id value in :ivar RootInfo PathRootError.invalid_root: The root namespace id in
Dropbox-API-Path-Root header is no longer valid. Dropbox-API-Path-Root header is not valid. The value of this error is
:ivar no_permission: You don't have permission to access the path root id in use's latest root info.
Dropbox-API-Path-Root header. :ivar common.PathRootError.no_permission: You don't have permission to
access the namespace id in Dropbox-API-Path-Root header.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -217,23 +145,23 @@ class PathRootError(bb.Union):
other = None other = None
@classmethod @classmethod
def invalid(cls, val): def invalid_root(cls, val):
""" """
Create an instance of this class set to the ``invalid`` tag with value Create an instance of this class set to the ``invalid_root`` tag with
``val``. value ``val``.
:param InvalidPathRootError val: :param RootInfo val:
:rtype: PathRootError :rtype: PathRootError
""" """
return cls('invalid', val) return cls('invalid_root', val)
def is_invalid(self): def is_invalid_root(self):
""" """
Check if the union tag is ``invalid``. Check if the union tag is ``invalid_root``.
:rtype: bool :rtype: bool
""" """
return self._tag == 'invalid' return self._tag == 'invalid_root'
def is_no_permission(self): def is_no_permission(self):
""" """
@ -251,66 +179,239 @@ class PathRootError(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def get_invalid(self): def get_invalid_root(self):
""" """
The path root id value in Dropbox-API-Path-Root header is no longer The root namespace id in Dropbox-API-Path-Root header is not valid. The
valid. value of this error is use's latest root info.
Only call this if :meth:`is_invalid` is true. Only call this if :meth:`is_invalid_root` is true.
:rtype: InvalidPathRootError :rtype: RootInfo
""" """
if not self.is_invalid(): if not self.is_invalid_root():
raise AttributeError("tag 'invalid' not set") raise AttributeError("tag 'invalid_root' not set")
return self._value return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PathRootError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PathRootError(%r, %r)' % (self._tag, self._value) return 'PathRootError(%r, %r)' % (self._tag, self._value)
PathRootError_validator = bv.Union(PathRootError) PathRootError_validator = bv.Union(PathRootError)
class RootInfo(bb.Struct):
"""
Information about current user's root.
:ivar common.RootInfo.root_namespace_id: The namespace ID for user's root
namespace. It will be the namespace ID of the shared team root if the
user is member of a team with a separate team root. Otherwise it will be
same as ``RootInfo.home_namespace_id``.
:ivar common.RootInfo.home_namespace_id: The namespace ID for user's home
namespace.
"""
__slots__ = [
'_root_namespace_id_value',
'_root_namespace_id_present',
'_home_namespace_id_value',
'_home_namespace_id_present',
]
_has_required_fields = True
def __init__(self,
root_namespace_id=None,
home_namespace_id=None):
self._root_namespace_id_value = None
self._root_namespace_id_present = False
self._home_namespace_id_value = None
self._home_namespace_id_present = False
if root_namespace_id is not None:
self.root_namespace_id = root_namespace_id
if home_namespace_id is not None:
self.home_namespace_id = home_namespace_id
@property
def root_namespace_id(self):
"""
The namespace ID for user's root namespace. It will be the namespace ID
of the shared team root if the user is member of a team with a separate
team root. Otherwise it will be same as ``RootInfo.home_namespace_id``.
:rtype: str
"""
if self._root_namespace_id_present:
return self._root_namespace_id_value
else:
raise AttributeError("missing required field 'root_namespace_id'")
@root_namespace_id.setter
def root_namespace_id(self, val):
val = self._root_namespace_id_validator.validate(val)
self._root_namespace_id_value = val
self._root_namespace_id_present = True
@root_namespace_id.deleter
def root_namespace_id(self):
self._root_namespace_id_value = None
self._root_namespace_id_present = False
@property
def home_namespace_id(self):
"""
The namespace ID for user's home namespace.
:rtype: str
"""
if self._home_namespace_id_present:
return self._home_namespace_id_value
else:
raise AttributeError("missing required field 'home_namespace_id'")
@home_namespace_id.setter
def home_namespace_id(self, val):
val = self._home_namespace_id_validator.validate(val)
self._home_namespace_id_value = val
self._home_namespace_id_present = True
@home_namespace_id.deleter
def home_namespace_id(self):
self._home_namespace_id_value = None
self._home_namespace_id_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(RootInfo, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'RootInfo(root_namespace_id={!r}, home_namespace_id={!r})'.format(
self._root_namespace_id_value,
self._home_namespace_id_value,
)
RootInfo_validator = bv.StructTree(RootInfo)
class TeamRootInfo(RootInfo):
"""
Root info when user is member of a team with a separate root namespace ID.
:ivar common.TeamRootInfo.home_path: The path for user's home directory
under the shared team root.
"""
__slots__ = [
'_home_path_value',
'_home_path_present',
]
_has_required_fields = True
def __init__(self,
root_namespace_id=None,
home_namespace_id=None,
home_path=None):
super(TeamRootInfo, self).__init__(root_namespace_id,
home_namespace_id)
self._home_path_value = None
self._home_path_present = False
if home_path is not None:
self.home_path = home_path
@property
def home_path(self):
"""
The path for user's home directory under the shared team root.
:rtype: str
"""
if self._home_path_present:
return self._home_path_value
else:
raise AttributeError("missing required field 'home_path'")
@home_path.setter
def home_path(self, val):
val = self._home_path_validator.validate(val)
self._home_path_value = val
self._home_path_present = True
@home_path.deleter
def home_path(self):
self._home_path_value = None
self._home_path_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TeamRootInfo, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'TeamRootInfo(root_namespace_id={!r}, home_namespace_id={!r}, home_path={!r})'.format(
self._root_namespace_id_value,
self._home_namespace_id_value,
self._home_path_value,
)
TeamRootInfo_validator = bv.Struct(TeamRootInfo)
class UserRootInfo(RootInfo):
"""
Root info when user is not member of a team or the user is a member of a
team and the team does not have a separate root namespace.
"""
__slots__ = [
]
_has_required_fields = True
def __init__(self,
root_namespace_id=None,
home_namespace_id=None):
super(UserRootInfo, self).__init__(root_namespace_id,
home_namespace_id)
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(UserRootInfo, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'UserRootInfo(root_namespace_id={!r}, home_namespace_id={!r})'.format(
self._root_namespace_id_value,
self._home_namespace_id_value,
)
UserRootInfo_validator = bv.Struct(UserRootInfo)
Date_validator = bv.Timestamp(u'%Y-%m-%d') Date_validator = bv.Timestamp(u'%Y-%m-%d')
DisplayName_validator = bv.String(min_length=1, pattern=u'[^/:?*<>"|]*') DisplayName_validator = bv.String(min_length=1, pattern=u'[^/:?*<>"|]*')
DisplayNameLegacy_validator = bv.String(min_length=1) DisplayNameLegacy_validator = bv.String()
DropboxTimestamp_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ') DropboxTimestamp_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')
EmailAddress_validator = bv.String(max_length=255, pattern=u"^['&A-Za-z0-9._%+-]+@[A-Za-z0-9-][A-Za-z0-9.-]*.[A-Za-z]{2,15}$") EmailAddress_validator = bv.String(max_length=255, pattern=u"^['&A-Za-z0-9._%+-]+@[A-Za-z0-9-][A-Za-z0-9.-]*\\.[A-Za-z]{2,15}$")
# A ISO639-1 code. # A ISO639-1 code.
LanguageCode_validator = bv.String(min_length=2) LanguageCode_validator = bv.String(min_length=2)
NamePart_validator = bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*') NamePart_validator = bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*')
NamespaceId_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') NamespaceId_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+')
OptionalNamePart_validator = bv.String(max_length=100, pattern=u'[^/:?*<>"|]*') OptionalNamePart_validator = bv.String(max_length=100, pattern=u'[^/:?*<>"|]*')
PathRootId_validator = NamespaceId_validator
SessionId_validator = bv.String() SessionId_validator = bv.String()
SharedFolderId_validator = NamespaceId_validator SharedFolderId_validator = NamespaceId_validator
InvalidPathRootError._path_root_validator = bv.Nullable(PathRootId_validator)
InvalidPathRootError._all_field_names_ = set(['path_root'])
InvalidPathRootError._all_fields_ = [('path_root', InvalidPathRootError._path_root_validator)]
PathRoot._home_validator = bv.Void() PathRoot._home_validator = bv.Void()
PathRoot._member_home_validator = bv.Void() PathRoot._root_validator = NamespaceId_validator
PathRoot._team_validator = PathRootId_validator PathRoot._namespace_id_validator = NamespaceId_validator
PathRoot._user_home_validator = bv.Void()
PathRoot._namespace_id_validator = PathRootId_validator
PathRoot._other_validator = bv.Void() PathRoot._other_validator = bv.Void()
PathRoot._tagmap = { PathRoot._tagmap = {
'home': PathRoot._home_validator, 'home': PathRoot._home_validator,
'member_home': PathRoot._member_home_validator, 'root': PathRoot._root_validator,
'team': PathRoot._team_validator,
'user_home': PathRoot._user_home_validator,
'namespace_id': PathRoot._namespace_id_validator, 'namespace_id': PathRoot._namespace_id_validator,
'other': PathRoot._other_validator, 'other': PathRoot._other_validator,
} }
PathRoot.home = PathRoot('home') PathRoot.home = PathRoot('home')
PathRoot.member_home = PathRoot('member_home')
PathRoot.user_home = PathRoot('user_home')
PathRoot.other = PathRoot('other') PathRoot.other = PathRoot('other')
PathRootError._invalid_validator = InvalidPathRootError_validator PathRootError._invalid_root_validator = RootInfo_validator
PathRootError._no_permission_validator = bv.Void() PathRootError._no_permission_validator = bv.Void()
PathRootError._other_validator = bv.Void() PathRootError._other_validator = bv.Void()
PathRootError._tagmap = { PathRootError._tagmap = {
'invalid': PathRootError._invalid_validator, 'invalid_root': PathRootError._invalid_root_validator,
'no_permission': PathRootError._no_permission_validator, 'no_permission': PathRootError._no_permission_validator,
'other': PathRootError._other_validator, 'other': PathRootError._other_validator,
} }
@ -318,6 +419,40 @@ PathRootError._tagmap = {
PathRootError.no_permission = PathRootError('no_permission') PathRootError.no_permission = PathRootError('no_permission')
PathRootError.other = PathRootError('other') PathRootError.other = PathRootError('other')
RootInfo._root_namespace_id_validator = NamespaceId_validator
RootInfo._home_namespace_id_validator = NamespaceId_validator
RootInfo._field_names_ = set([
'root_namespace_id',
'home_namespace_id',
])
RootInfo._all_field_names_ = RootInfo._field_names_
RootInfo._fields_ = [
('root_namespace_id', RootInfo._root_namespace_id_validator),
('home_namespace_id', RootInfo._home_namespace_id_validator),
]
RootInfo._all_fields_ = RootInfo._fields_
RootInfo._tag_to_subtype_ = {
(u'team',): TeamRootInfo_validator,
(u'user',): UserRootInfo_validator,
}
RootInfo._pytype_to_tag_and_subtype_ = {
TeamRootInfo: ((u'team',), TeamRootInfo_validator),
UserRootInfo: ((u'user',), UserRootInfo_validator),
}
RootInfo._is_catch_all_ = True
TeamRootInfo._home_path_validator = bv.String()
TeamRootInfo._field_names_ = set(['home_path'])
TeamRootInfo._all_field_names_ = RootInfo._all_field_names_.union(TeamRootInfo._field_names_)
TeamRootInfo._fields_ = [('home_path', TeamRootInfo._home_path_validator)]
TeamRootInfo._all_fields_ = RootInfo._all_fields_ + TeamRootInfo._fields_
UserRootInfo._field_names_ = set([])
UserRootInfo._all_field_names_ = RootInfo._all_field_names_.union(UserRootInfo._field_names_)
UserRootInfo._fields_ = []
UserRootInfo._all_fields_ = RootInfo._all_fields_ + UserRootInfo._fields_
ROUTES = { ROUTES = {
} }

View File

@ -0,0 +1,176 @@
# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# @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
try:
from . import (
common,
)
except (ImportError, SystemError, ValueError):
import common
class DeleteManualContactsArg(bb.Struct):
"""
:ivar contacts.DeleteManualContactsArg.email_addresses: List of manually
added contacts to be deleted.
"""
__slots__ = [
'_email_addresses_value',
'_email_addresses_present',
]
_has_required_fields = True
def __init__(self,
email_addresses=None):
self._email_addresses_value = None
self._email_addresses_present = False
if email_addresses is not None:
self.email_addresses = email_addresses
@property
def email_addresses(self):
"""
List of manually added contacts to be deleted.
:rtype: list of [str]
"""
if self._email_addresses_present:
return self._email_addresses_value
else:
raise AttributeError("missing required field 'email_addresses'")
@email_addresses.setter
def email_addresses(self, val):
val = self._email_addresses_validator.validate(val)
self._email_addresses_value = val
self._email_addresses_present = True
@email_addresses.deleter
def email_addresses(self):
self._email_addresses_value = None
self._email_addresses_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(DeleteManualContactsArg, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'DeleteManualContactsArg(email_addresses={!r})'.format(
self._email_addresses_value,
)
DeleteManualContactsArg_validator = bv.Struct(DeleteManualContactsArg)
class DeleteManualContactsError(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar list of [str] contacts.DeleteManualContactsError.contacts_not_found:
Can't delete contacts from this list. Make sure the list only has
manually added contacts. The deletion was cancelled.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
other = None
@classmethod
def contacts_not_found(cls, val):
"""
Create an instance of this class set to the ``contacts_not_found`` tag
with value ``val``.
:param list of [str] val:
:rtype: DeleteManualContactsError
"""
return cls('contacts_not_found', val)
def is_contacts_not_found(self):
"""
Check if the union tag is ``contacts_not_found``.
:rtype: bool
"""
return self._tag == 'contacts_not_found'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def get_contacts_not_found(self):
"""
Can't delete contacts from this list. Make sure the list only has
manually added contacts. The deletion was cancelled.
Only call this if :meth:`is_contacts_not_found` is true.
:rtype: list of [str]
"""
if not self.is_contacts_not_found():
raise AttributeError("tag 'contacts_not_found' not set")
return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(DeleteManualContactsError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'DeleteManualContactsError(%r, %r)' % (self._tag, self._value)
DeleteManualContactsError_validator = bv.Union(DeleteManualContactsError)
DeleteManualContactsArg._email_addresses_validator = bv.List(common.EmailAddress_validator)
DeleteManualContactsArg._all_field_names_ = set(['email_addresses'])
DeleteManualContactsArg._all_fields_ = [('email_addresses', DeleteManualContactsArg._email_addresses_validator)]
DeleteManualContactsError._contacts_not_found_validator = bv.List(common.EmailAddress_validator)
DeleteManualContactsError._other_validator = bv.Void()
DeleteManualContactsError._tagmap = {
'contacts_not_found': DeleteManualContactsError._contacts_not_found_validator,
'other': DeleteManualContactsError._other_validator,
}
DeleteManualContactsError.other = DeleteManualContactsError('other')
delete_manual_contacts = bb.Route(
'delete_manual_contacts',
1,
False,
bv.Void(),
bv.Void(),
bv.Void(),
{'host': u'api',
'style': u'rpc'},
)
delete_manual_contacts_batch = bb.Route(
'delete_manual_contacts_batch',
1,
False,
DeleteManualContactsArg_validator,
bv.Void(),
DeleteManualContactsError_validator,
{'host': u'api',
'style': u'rpc'},
)
ROUTES = {
'delete_manual_contacts': delete_manual_contacts,
'delete_manual_contacts_batch': delete_manual_contacts_batch,
}

View File

@ -22,6 +22,11 @@ from .auth import (
AuthError_validator, AuthError_validator,
RateLimitError_validator, RateLimitError_validator,
) )
from .common import (
PathRoot,
PathRoot_validator,
PathRootError_validator
)
from .base import DropboxBase from .base import DropboxBase
from .base_team import DropboxTeamBase from .base_team import DropboxTeamBase
from .exceptions import ( from .exceptions import (
@ -29,6 +34,7 @@ from .exceptions import (
AuthError, AuthError,
BadInputError, BadInputError,
HttpError, HttpError,
PathRootError,
InternalServerError, InternalServerError,
RateLimitError, RateLimitError,
) )
@ -42,6 +48,9 @@ from .session import (
pinned_session, pinned_session,
) )
PATH_ROOT_HEADER = 'Dropbox-API-Path-Root'
HTTP_STATUS_INVALID_PATH_ROOT = 422
class RouteResult(object): class RouteResult(object):
"""The successful result of a call to a route.""" """The successful result of a call to a route."""
@ -117,7 +126,7 @@ class _DropboxTransport(object):
_ROUTE_STYLE_RPC = 'rpc' _ROUTE_STYLE_RPC = 'rpc'
# This is the default longest time we'll block on receiving data from the server # This is the default longest time we'll block on receiving data from the server
_DEFAULT_TIMEOUT = 30 _DEFAULT_TIMEOUT = 100
def __init__(self, def __init__(self,
oauth2_access_token, oauth2_access_token,
@ -182,6 +191,35 @@ class _DropboxTransport(object):
self._timeout = timeout self._timeout = timeout
def clone(
self,
oauth2_access_token=None,
max_retries_on_error=None,
max_retries_on_rate_limit=None,
user_agent=None,
session=None,
headers=None,
timeout=None):
"""
Creates a new copy of the Dropbox client with the same defaults unless modified by
arguments to clone()
See constructor for original parameter descriptions.
:return: New instance of Dropbox clent
:rtype: Dropbox
"""
return self.__class__(
oauth2_access_token or self._oauth2_access_token,
max_retries_on_error or self._max_retries_on_error,
max_retries_on_rate_limit or self._max_retries_on_rate_limit,
user_agent or self._user_agent,
session or self._session,
headers or self._headers,
timeout or self._timeout
)
def request(self, def request(self,
route, route,
namespace, namespace,
@ -211,6 +249,8 @@ class _DropboxTransport(object):
""" """
host = route.attrs['host'] or 'api' host = route.attrs['host'] or 'api'
route_name = namespace + '/' + route.name route_name = namespace + '/' + route.name
if route.version > 1:
route_name += '_v{}'.format(route.version)
route_style = route.attrs['style'] or 'rpc' route_style = route.attrs['style'] or 'rpc'
serialized_arg = stone_serializers.json_encode(route.arg_type, serialized_arg = stone_serializers.json_encode(route.arg_type,
request_arg) request_arg)
@ -421,6 +461,10 @@ class _DropboxTransport(object):
err = stone_serializers.json_compat_obj_decode( err = stone_serializers.json_compat_obj_decode(
AuthError_validator, r.json()['error']) AuthError_validator, r.json()['error'])
raise AuthError(request_id, err) raise AuthError(request_id, err)
elif r.status_code == HTTP_STATUS_INVALID_PATH_ROOT:
err = stone_serializers.json_compat_obj_decode(
PathRootError_validator, r.json()['error'])
raise PathRootError(request_id, err)
elif r.status_code == 429: elif r.status_code == 429:
err = None err = None
if r.headers.get('content-type') == 'application/json': if r.headers.get('content-type') == 'application/json':
@ -479,6 +523,28 @@ class _DropboxTransport(object):
for c in http_resp.iter_content(chunksize): for c in http_resp.iter_content(chunksize):
f.write(c) f.write(c)
def with_path_root(self, path_root):
"""
Creates a clone of the Dropbox instance with the Dropbox-API-Path-Root header
as the appropriate serialized instance of PathRoot.
For more information, see
https://www.dropbox.com/developers/reference/namespace-guide#pathrootmodes
:param PathRoot path_root: instance of PathRoot to serialize into the headers field
:return: A :class: `Dropbox`
:rtype: Dropbox
"""
if not isinstance(path_root, PathRoot):
raise ValueError("path_root must be an instance of PathRoot")
return self.clone(
headers={
PATH_ROOT_HEADER: stone_serializers.json_encode(PathRoot_validator, path_root)
}
)
class Dropbox(_DropboxTransport, DropboxBase): class Dropbox(_DropboxTransport, DropboxBase):
""" """
Use this class to make requests to the Dropbox API using a user's access Use this class to make requests to the Dropbox API using a user's access
@ -493,22 +559,50 @@ class DropboxTeam(_DropboxTransport, DropboxTeamBase):
token. Methods of this class are meant to act on the team, but there is token. Methods of this class are meant to act on the team, but there is
also an :meth:`as_user` method for assuming a team member's identity. also an :meth:`as_user` method for assuming a team member's identity.
""" """
def as_admin(self, team_member_id):
"""
Allows a team credential to assume the identity of an administrator on the team
and perform operations on any team-owned content.
:param str team_member_id: team member id of administrator to perform actions with
:return: A :class:`Dropbox` object that can be used to query on behalf
of this admin of the team.
:rtype: Dropbox
"""
return self._get_dropbox_client_with_select_header('Dropbox-API-Select-Admin',
team_member_id)
def as_user(self, team_member_id): def as_user(self, team_member_id):
""" """
Allows a team credential to assume the identity of a member of the Allows a team credential to assume the identity of a member of the
team. team.
:param str team_member_id: team member id of team member to perform actions with
:return: A :class:`Dropbox` object that can be used to query on behalf :return: A :class:`Dropbox` object that can be used to query on behalf
of this member of the team. of this member of the team.
:rtype: Dropbox :rtype: Dropbox
""" """
return self._get_dropbox_client_with_select_header('Dropbox-API-Select-User',
team_member_id)
def _get_dropbox_client_with_select_header(self, select_header_name, team_member_id):
"""
Get Dropbox client with modified headers
:param str select_header_name: Header name used to select users
:param str team_member_id: team member id of team member to perform actions with
:return: A :class:`Dropbox` object that can be used to query on behalf
of a member or admin of the team
:rtype: Dropbox
"""
new_headers = self._headers.copy() if self._headers else {} new_headers = self._headers.copy() if self._headers else {}
new_headers['Dropbox-API-Select-User'] = team_member_id new_headers[select_header_name] = team_member_id
return Dropbox( return Dropbox(
self._oauth2_access_token, self._oauth2_access_token,
max_retries_on_error=self._max_retries_on_error, max_retries_on_error=self._max_retries_on_error,
max_retries_on_rate_limit=self._max_retries_on_rate_limit, max_retries_on_rate_limit=self._max_retries_on_rate_limit,
timeout=self._timeout,
user_agent=self._raw_user_agent, user_agent=self._raw_user_agent,
session=self._session, session=self._session,
headers=new_headers, headers=new_headers,

View File

@ -46,6 +46,17 @@ class HttpError(DropboxException):
self.status_code, self.body) self.status_code, self.body)
class PathRootError(HttpError):
"""Error caused by an invalid path root."""
def __init__(self, request_id, error=None):
super(PathRootError, self).__init__(request_id, 422, None)
self.error = error
def __repr__(self):
return 'PathRootError({!r}, {!r})'.format(self.request_id, self.error)
class BadInputError(HttpError): class BadInputError(HttpError):
"""Errors due to bad input parameters to an API Operation.""" """Errors due to bad input parameters to an API Operation."""

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# @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
class PlatformType(bb.Union):
"""
Possible platforms on which a user may view content.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar seen_state.PlatformType.web: The content was viewed on the web.
:ivar seen_state.PlatformType.desktop: The content was viewed on a desktop
client.
:ivar seen_state.PlatformType.mobile_ios: The content was viewed on a mobile
iOS client.
:ivar seen_state.PlatformType.mobile_android: The content was viewed on a
mobile android client.
:ivar seen_state.PlatformType.api: The content was viewed from an API
client.
:ivar seen_state.PlatformType.unknown: The content was viewed on an unknown
platform.
:ivar seen_state.PlatformType.mobile: The content was viewed on a mobile
client. DEPRECATED: Use mobile_ios or mobile_android instead.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
web = None
# Attribute is overwritten below the class definition
desktop = None
# Attribute is overwritten below the class definition
mobile_ios = None
# Attribute is overwritten below the class definition
mobile_android = None
# Attribute is overwritten below the class definition
api = None
# Attribute is overwritten below the class definition
unknown = None
# Attribute is overwritten below the class definition
mobile = None
# Attribute is overwritten below the class definition
other = None
def is_web(self):
"""
Check if the union tag is ``web``.
:rtype: bool
"""
return self._tag == 'web'
def is_desktop(self):
"""
Check if the union tag is ``desktop``.
:rtype: bool
"""
return self._tag == 'desktop'
def is_mobile_ios(self):
"""
Check if the union tag is ``mobile_ios``.
:rtype: bool
"""
return self._tag == 'mobile_ios'
def is_mobile_android(self):
"""
Check if the union tag is ``mobile_android``.
:rtype: bool
"""
return self._tag == 'mobile_android'
def is_api(self):
"""
Check if the union tag is ``api``.
:rtype: bool
"""
return self._tag == 'api'
def is_unknown(self):
"""
Check if the union tag is ``unknown``.
:rtype: bool
"""
return self._tag == 'unknown'
def is_mobile(self):
"""
Check if the union tag is ``mobile``.
:rtype: bool
"""
return self._tag == 'mobile'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PlatformType, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'PlatformType(%r, %r)' % (self._tag, self._value)
PlatformType_validator = bv.Union(PlatformType)
PlatformType._web_validator = bv.Void()
PlatformType._desktop_validator = bv.Void()
PlatformType._mobile_ios_validator = bv.Void()
PlatformType._mobile_android_validator = bv.Void()
PlatformType._api_validator = bv.Void()
PlatformType._unknown_validator = bv.Void()
PlatformType._mobile_validator = bv.Void()
PlatformType._other_validator = bv.Void()
PlatformType._tagmap = {
'web': PlatformType._web_validator,
'desktop': PlatformType._desktop_validator,
'mobile_ios': PlatformType._mobile_ios_validator,
'mobile_android': PlatformType._mobile_android_validator,
'api': PlatformType._api_validator,
'unknown': PlatformType._unknown_validator,
'mobile': PlatformType._mobile_validator,
'other': PlatformType._other_validator,
}
PlatformType.web = PlatformType('web')
PlatformType.desktop = PlatformType('desktop')
PlatformType.mobile_ios = PlatformType('mobile_ios')
PlatformType.mobile_android = PlatformType('mobile_android')
PlatformType.api = PlatformType('api')
PlatformType.unknown = PlatformType('unknown')
PlatformType.mobile = PlatformType('mobile')
PlatformType.other = PlatformType('other')
ROUTES = {
}

View File

@ -1,10 +1,10 @@
import pkg_resources from . import pkg_resources
import os import os
import ssl import ssl
import requests import requests
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager from urllib3.poolmanager import PoolManager
API_DOMAIN = os.environ.get('DROPBOX_API_DOMAIN', API_DOMAIN = os.environ.get('DROPBOX_API_DOMAIN',
os.environ.get('DROPBOX_DOMAIN', '.dropboxapi.com')) os.environ.get('DROPBOX_DOMAIN', '.dropboxapi.com'))

File diff suppressed because it is too large Load Diff

View File

@ -8,9 +8,11 @@ than being added to a project.
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
import functools
try: try:
from . import stone_validators as bv from . import stone_validators as bv
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv # type: ignore import stone_validators as bv # type: ignore
@ -19,17 +21,34 @@ _MYPY = False
if _MYPY: if _MYPY:
import typing # noqa: F401 # pylint: disable=import-error,unused-import,useless-suppression import typing # noqa: F401 # pylint: disable=import-error,unused-import,useless-suppression
class AnnotationType(object):
# This is a base class for all annotation types.
pass
if _MYPY:
T = typing.TypeVar('T', bound=AnnotationType)
U = typing.TypeVar('U')
class Struct(object):
# This is a base class for all classes representing Stone structs.
def _process_custom_annotations(self, annotation_type, field_path, processor):
# type: (typing.Type[T], typing.Text, typing.Callable[[T, U], U]) -> None
pass
class Union(object): class Union(object):
# TODO(kelkabany): Possible optimization is to remove _value if a # TODO(kelkabany): Possible optimization is to remove _value if a
# union is composed of only symbols. # union is composed of only symbols.
__slots__ = ['_tag', '_value'] __slots__ = ['_tag', '_value']
_tagmap = {} # type: typing.Dict[typing.Text, bv.Validator] _tagmap = {} # type: typing.Dict[typing.Text, bv.Validator]
_permissioned_tagmaps = set() # type: typing.Set[typing.Text]
def __init__(self, tag, value=None): def __init__(self, tag, value=None):
# type: (typing.Text, typing.Optional[typing.Any]) -> None validator = None
assert tag in self._tagmap, 'Invalid tag %r.' % tag tagmap_names = ['_{}_tagmap'.format(map_name) for map_name in self._permissioned_tagmaps]
validator = self._tagmap[tag] for tagmap_name in ['_tagmap'] + tagmap_names:
if tag in getattr(self, tagmap_name):
validator = getattr(self, tagmap_name)[tag]
assert validator is not None, 'Invalid tag %r.' % tag
if isinstance(validator, bv.Void): if isinstance(validator, bv.Void):
assert value is None, 'Void type union member must have None value.' assert value is None, 'Void type union member must have None value.'
elif isinstance(validator, (bv.Struct, bv.Union)): elif isinstance(validator, (bv.Struct, bv.Union)):
@ -54,10 +73,40 @@ class Union(object):
def __hash__(self): def __hash__(self):
return hash((self._tag, self._value)) return hash((self._tag, self._value))
def _process_custom_annotations(self, annotation_type, field_path, processor):
# type: (typing.Type[T], typing.Text, typing.Callable[[T, U], U]) -> None
pass
@classmethod
def _is_tag_present(cls, tag, caller_permissions):
assert tag, 'tag value should not be None'
if tag in cls._tagmap:
return True
for extra_permission in caller_permissions.permissions:
tagmap_name = '_{}_tagmap'.format(extra_permission)
if hasattr(cls, tagmap_name) and tag in getattr(cls, tagmap_name):
return True
return False
@classmethod
def _get_val_data_type(cls, tag, caller_permissions):
assert tag, 'tag value should not be None'
for extra_permission in caller_permissions.permissions:
tagmap_name = '_{}_tagmap'.format(extra_permission)
if hasattr(cls, tagmap_name) and tag in getattr(cls, tagmap_name):
return getattr(cls, tagmap_name)[tag]
return cls._tagmap[tag]
class Route(object): class Route(object):
def __init__(self, name, deprecated, arg_type, result_type, error_type, attrs): def __init__(self, name, version, deprecated, arg_type, result_type, error_type, attrs):
self.name = name self.name = name
self.version = version
self.deprecated = deprecated self.deprecated = deprecated
self.arg_type = arg_type self.arg_type = arg_type
self.result_type = result_type self.result_type = result_type
@ -66,10 +115,38 @@ class Route(object):
self.attrs = attrs self.attrs = attrs
def __repr__(self): def __repr__(self):
return 'Route({!r}, {!r}, {!r}, {!r}, {!r}, {!r})'.format( return 'Route({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})'.format(
self.name, self.name,
self.version,
self.deprecated, self.deprecated,
self.arg_type, self.arg_type,
self.result_type, self.result_type,
self.error_type, self.error_type,
self.attrs) self.attrs)
# helper functions used when constructing custom annotation processors
# put this here so that every other file doesn't need to import functools
partially_apply = functools.partial
def make_struct_annotation_processor(annotation_type, processor):
def g(field_path, struct):
if struct is None:
return struct
struct._process_custom_annotations(annotation_type, field_path, processor)
return struct
return g
def make_list_annotation_processor(processor):
def g(field_path, list_):
if list_ is None:
return list_
return [processor('{}[{}]'.format(field_path, idx), x) for idx, x in enumerate(list_)]
return g
def make_map_value_annotation_processor(processor):
def g(field_path, map_):
if map_ is None:
return map_
return {k: processor('{}[{}]'.format(field_path, repr(k)), v) for k, v in map_.items()}
return g

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@ from __future__ import absolute_import, unicode_literals
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
import datetime import datetime
import hashlib
import math import math
import numbers import numbers
import re import re
@ -73,7 +74,10 @@ class ValidationError(Exception):
def generic_type_name(v): def generic_type_name(v):
"""Return a descriptive type name that isn't Python specific. For example, """Return a descriptive type name that isn't Python specific. For example,
an int value will return 'integer' rather than 'int'.""" an int value will return 'integer' rather than 'int'."""
if isinstance(v, numbers.Integral): if isinstance(v, bool):
# Must come before any numbers checks since booleans are integers too
return 'boolean'
elif isinstance(v, numbers.Integral):
# Must come before real numbers check since integrals are reals too # Must come before real numbers check since integrals are reals too
return 'integer' return 'integer'
elif isinstance(v, numbers.Real): elif isinstance(v, numbers.Real):
@ -455,6 +459,16 @@ class Struct(Composite):
self.validate_fields_only(val) self.validate_fields_only(val)
return val return val
def validate_with_permissions(self, val, caller_permissions):
"""
For a val to pass validation, val must be of the correct type and have
all required permissioned fields present. Should only be called
for callers with extra permissions.
"""
self.validate(val)
self.validate_fields_only_with_permissions(val, caller_permissions)
return val
def validate_fields_only(self, val): def validate_fields_only(self, val):
""" """
To pass field validation, no required field should be missing. To pass field validation, no required field should be missing.
@ -465,11 +479,27 @@ class Struct(Composite):
FIXME(kelkabany): Since the definition object does not maintain a list FIXME(kelkabany): Since the definition object does not maintain a list
of which fields are required, all fields are scanned. of which fields are required, all fields are scanned.
""" """
for field_name, _ in self.definition._all_fields_: for field_name in self.definition._all_field_names_:
if not hasattr(val, field_name): if not hasattr(val, field_name):
raise ValidationError("missing required field '%s'" % raise ValidationError("missing required field '%s'" %
field_name) field_name)
def validate_fields_only_with_permissions(self, val, caller_permissions):
"""
To pass field validation, no required field should be missing.
This method assumes that the contents of each field have already been
validated on assignment, so it's merely a presence check.
Should only be called for callers with extra permissions.
"""
self.validate_fields_only(val)
# check if type has been patched
for extra_permission in caller_permissions.permissions:
all_field_names = '_all_{}_field_names_'.format(extra_permission)
for field_name in getattr(self.definition, all_field_names, set()):
if not hasattr(val, field_name):
raise ValidationError("missing required field '%s'" % field_name)
def validate_type_only(self, val): def validate_type_only(self, val):
""" """
Use this when you only want to validate that the type of an object Use this when you only want to validate that the type of an object
@ -590,3 +620,54 @@ class Nullable(Validator):
def get_default(self): def get_default(self):
return None return None
class Redactor(object):
def __init__(self, regex):
"""
Args:
regex: What parts of the field to redact.
"""
self.regex = regex
@abstractmethod
def apply(self, val):
"""Redacts information from annotated field.
Returns: A redacted version of the string provided.
"""
pass
def _get_matches(self, val):
if not self.regex:
return None
try:
return re.search(self.regex, val)
except TypeError:
return None
class HashRedactor(Redactor):
def apply(self, val):
matches = self._get_matches(val)
val_to_hash = str(val) if isinstance(val, int) or isinstance(val, float) else val
try:
# add string literal to ensure unicode
hashed = hashlib.md5(val_to_hash.encode('utf-8')).hexdigest() + ''
except [AttributeError, ValueError]:
hashed = None
if matches:
blotted = '***'.join(matches.groups())
if hashed:
return '{} ({})'.format(hashed, blotted)
return blotted
return hashed
class BlotRedactor(Redactor):
def apply(self, val):
matches = self._get_matches(val)
if matches:
return '***'.join(matches.groups())
return '********'

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
@ -15,7 +16,7 @@ try:
from . import ( from . import (
common, common,
) )
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
import common import common
class GroupManagementType(bb.Union): class GroupManagementType(bb.Union):
@ -26,9 +27,12 @@ class GroupManagementType(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar user_managed: A group which is managed by selected users. :ivar team_common.GroupManagementType.user_managed: A group which is managed
:ivar company_managed: A group which is managed by team admins only. by selected users.
:ivar system_managed: A group which is managed automatically by Dropbox. :ivar team_common.GroupManagementType.company_managed: A group which is
managed by team admins only.
:ivar team_common.GroupManagementType.system_managed: A group which is
managed automatically by Dropbox.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -73,19 +77,24 @@ class GroupManagementType(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GroupManagementType, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GroupManagementType(%r, %r)' % (self._tag, self._value) return 'GroupManagementType(%r, %r)' % (self._tag, self._value)
GroupManagementType_validator = bv.Union(GroupManagementType) GroupManagementType_validator = bv.Union(GroupManagementType)
class GroupSummary(object): class GroupSummary(bb.Struct):
""" """
Information about a group. Information about a group.
:ivar group_external_id: External ID of group. This is an arbitrary ID that :ivar team_common.GroupSummary.group_external_id: External ID of group. This
an admin can attach to a group. is an arbitrary ID that an admin can attach to a group.
:ivar member_count: The number of members in the group. :ivar team_common.GroupSummary.member_count: The number of members in the
:ivar group_management_type: Who is allowed to manage the group. group.
:ivar team_common.GroupSummary.group_management_type: Who is allowed to
manage the group.
""" """
__slots__ = [ __slots__ = [
@ -204,7 +213,7 @@ class GroupSummary(object):
""" """
The number of members in the group. The number of members in the group.
:rtype: long :rtype: int
""" """
if self._member_count_present: if self._member_count_present:
return self._member_count_value return self._member_count_value
@ -248,6 +257,9 @@ class GroupSummary(object):
self._group_management_type_value = None self._group_management_type_value = None
self._group_management_type_present = False self._group_management_type_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GroupSummary, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GroupSummary(group_name={!r}, group_id={!r}, group_management_type={!r}, group_external_id={!r}, member_count={!r})'.format( return 'GroupSummary(group_name={!r}, group_id={!r}, group_management_type={!r}, group_external_id={!r}, member_count={!r})'.format(
self._group_name_value, self._group_name_value,
@ -267,9 +279,11 @@ class GroupType(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar team: A group to which team members are automatically added. :ivar team_common.GroupType.team: A group to which team members are
Applicable to `team folders <https://www.dropbox.com/help/986>`_ only. automatically added. Applicable to `team folders
:ivar user_managed: A group is created and managed by a user. <https://www.dropbox.com/help/986>`_ only.
:ivar team_common.GroupType.user_managed: A group is created and managed by
a user.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -304,17 +318,88 @@ class GroupType(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GroupType, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GroupType(%r, %r)' % (self._tag, self._value) return 'GroupType(%r, %r)' % (self._tag, self._value)
GroupType_validator = bv.Union(GroupType) GroupType_validator = bv.Union(GroupType)
class TimeRange(object): class MemberSpaceLimitType(bb.Union):
"""
The type of the space limit imposed on a team member.
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_common.MemberSpaceLimitType.off: The team member does not have
imposed space limit.
:ivar team_common.MemberSpaceLimitType.alert_only: The team member has soft
imposed space limit - the limit is used for display and for
notifications.
:ivar team_common.MemberSpaceLimitType.stop_sync: The team member has hard
imposed space limit - Dropbox file sync will stop after the limit is
reached.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
off = None
# Attribute is overwritten below the class definition
alert_only = None
# Attribute is overwritten below the class definition
stop_sync = None
# Attribute is overwritten below the class definition
other = None
def is_off(self):
"""
Check if the union tag is ``off``.
:rtype: bool
"""
return self._tag == 'off'
def is_alert_only(self):
"""
Check if the union tag is ``alert_only``.
:rtype: bool
"""
return self._tag == 'alert_only'
def is_stop_sync(self):
"""
Check if the union tag is ``stop_sync``.
:rtype: bool
"""
return self._tag == 'stop_sync'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(MemberSpaceLimitType, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'MemberSpaceLimitType(%r, %r)' % (self._tag, self._value)
MemberSpaceLimitType_validator = bv.Union(MemberSpaceLimitType)
class TimeRange(bb.Struct):
""" """
Time range. Time range.
:ivar start_time: Optional starting time (inclusive). :ivar team_common.TimeRange.start_time: Optional starting time (inclusive).
:ivar end_time: Optional ending time (exclusive). :ivar team_common.TimeRange.end_time: Optional ending time (exclusive).
""" """
__slots__ = [ __slots__ = [
@ -390,6 +475,9 @@ class TimeRange(object):
self._end_time_value = None self._end_time_value = None
self._end_time_present = False self._end_time_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TimeRange, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TimeRange(start_time={!r}, end_time={!r})'.format( return 'TimeRange(start_time={!r}, end_time={!r})'.format(
self._start_time_value, self._start_time_value,
@ -452,6 +540,22 @@ GroupType.team = GroupType('team')
GroupType.user_managed = GroupType('user_managed') GroupType.user_managed = GroupType('user_managed')
GroupType.other = GroupType('other') GroupType.other = GroupType('other')
MemberSpaceLimitType._off_validator = bv.Void()
MemberSpaceLimitType._alert_only_validator = bv.Void()
MemberSpaceLimitType._stop_sync_validator = bv.Void()
MemberSpaceLimitType._other_validator = bv.Void()
MemberSpaceLimitType._tagmap = {
'off': MemberSpaceLimitType._off_validator,
'alert_only': MemberSpaceLimitType._alert_only_validator,
'stop_sync': MemberSpaceLimitType._stop_sync_validator,
'other': MemberSpaceLimitType._other_validator,
}
MemberSpaceLimitType.off = MemberSpaceLimitType('off')
MemberSpaceLimitType.alert_only = MemberSpaceLimitType('alert_only')
MemberSpaceLimitType.stop_sync = MemberSpaceLimitType('stop_sync')
MemberSpaceLimitType.other = MemberSpaceLimitType('other')
TimeRange._start_time_validator = bv.Nullable(common.DropboxTimestamp_validator) TimeRange._start_time_validator = bv.Nullable(common.DropboxTimestamp_validator)
TimeRange._end_time_validator = bv.Nullable(common.DropboxTimestamp_validator) TimeRange._end_time_validator = bv.Nullable(common.DropboxTimestamp_validator)
TimeRange._all_field_names_ = set([ TimeRange._all_field_names_ = set([

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,78 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
import stone_base as bb import stone_base as bb
class CameraUploadsPolicyState(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.CameraUploadsPolicyState.disabled: Background camera
uploads are disabled.
:ivar team_policies.CameraUploadsPolicyState.enabled: Background camera
uploads are allowed.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
disabled = None
# Attribute is overwritten below the class definition
enabled = None
# Attribute is overwritten below the class definition
other = None
def is_disabled(self):
"""
Check if the union tag is ``disabled``.
:rtype: bool
"""
return self._tag == 'disabled'
def is_enabled(self):
"""
Check if the union tag is ``enabled``.
:rtype: bool
"""
return self._tag == 'enabled'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(CameraUploadsPolicyState, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'CameraUploadsPolicyState(%r, %r)' % (self._tag, self._value)
CameraUploadsPolicyState_validator = bv.Union(CameraUploadsPolicyState)
class EmmState(bb.Union): class EmmState(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar disabled: Emm token is disabled. :ivar team_policies.EmmState.disabled: Emm token is disabled.
:ivar optional: Emm token is optional. :ivar team_policies.EmmState.optional: Emm token is optional.
:ivar required: Emm token is required. :ivar team_policies.EmmState.required: Emm token is required.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -64,19 +117,64 @@ class EmmState(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(EmmState, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'EmmState(%r, %r)' % (self._tag, self._value) return 'EmmState(%r, %r)' % (self._tag, self._value)
EmmState_validator = bv.Union(EmmState) EmmState_validator = bv.Union(EmmState)
class GroupCreation(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.GroupCreation.admins_and_members: Team admins and
members can create groups.
:ivar team_policies.GroupCreation.admins_only: Only team admins can create
groups.
"""
_catch_all = None
# Attribute is overwritten below the class definition
admins_and_members = None
# Attribute is overwritten below the class definition
admins_only = None
def is_admins_and_members(self):
"""
Check if the union tag is ``admins_and_members``.
:rtype: bool
"""
return self._tag == 'admins_and_members'
def is_admins_only(self):
"""
Check if the union tag is ``admins_only``.
:rtype: bool
"""
return self._tag == 'admins_only'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GroupCreation, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'GroupCreation(%r, %r)' % (self._tag, self._value)
GroupCreation_validator = bv.Union(GroupCreation)
class OfficeAddInPolicy(bb.Union): class OfficeAddInPolicy(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar disabled: Office Add-In is disabled. :ivar team_policies.OfficeAddInPolicy.disabled: Office Add-In is disabled.
:ivar enabled: Office Add-In is enabled. :ivar team_policies.OfficeAddInPolicy.enabled: Office Add-In is enabled.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -111,20 +209,77 @@ class OfficeAddInPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(OfficeAddInPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'OfficeAddInPolicy(%r, %r)' % (self._tag, self._value) return 'OfficeAddInPolicy(%r, %r)' % (self._tag, self._value)
OfficeAddInPolicy_validator = bv.Union(OfficeAddInPolicy) OfficeAddInPolicy_validator = bv.Union(OfficeAddInPolicy)
class PaperDefaultFolderPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.PaperDefaultFolderPolicy.everyone_in_team: Everyone in
team will be the default option when creating a folder in Paper.
:ivar team_policies.PaperDefaultFolderPolicy.invite_only: Invite only will
be the default option when creating a folder in Paper.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
everyone_in_team = None
# Attribute is overwritten below the class definition
invite_only = None
# Attribute is overwritten below the class definition
other = None
def is_everyone_in_team(self):
"""
Check if the union tag is ``everyone_in_team``.
:rtype: bool
"""
return self._tag == 'everyone_in_team'
def is_invite_only(self):
"""
Check if the union tag is ``invite_only``.
:rtype: bool
"""
return self._tag == 'invite_only'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PaperDefaultFolderPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'PaperDefaultFolderPolicy(%r, %r)' % (self._tag, self._value)
PaperDefaultFolderPolicy_validator = bv.Union(PaperDefaultFolderPolicy)
class PaperDeploymentPolicy(bb.Union): class PaperDeploymentPolicy(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar full: All team members have access to Paper. :ivar team_policies.PaperDeploymentPolicy.full: All team members have access
:ivar partial: Only whitelisted team members can access Paper. To see which to Paper.
user is whitelisted, check 'is_paper_whitelisted' on 'account/info'. :ivar team_policies.PaperDeploymentPolicy.partial: Only whitelisted team
members can access Paper. To see which user is whitelisted, check
'is_paper_whitelisted' on 'account/info'.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -159,20 +314,75 @@ class PaperDeploymentPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PaperDeploymentPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PaperDeploymentPolicy(%r, %r)' % (self._tag, self._value) return 'PaperDeploymentPolicy(%r, %r)' % (self._tag, self._value)
PaperDeploymentPolicy_validator = bv.Union(PaperDeploymentPolicy) PaperDeploymentPolicy_validator = bv.Union(PaperDeploymentPolicy)
class PaperDesktopPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.PaperDesktopPolicy.disabled: Do not allow team members
to use Paper Desktop.
:ivar team_policies.PaperDesktopPolicy.enabled: Allow team members to use
Paper Desktop.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
disabled = None
# Attribute is overwritten below the class definition
enabled = None
# Attribute is overwritten below the class definition
other = None
def is_disabled(self):
"""
Check if the union tag is ``disabled``.
:rtype: bool
"""
return self._tag == 'disabled'
def is_enabled(self):
"""
Check if the union tag is ``enabled``.
:rtype: bool
"""
return self._tag == 'enabled'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PaperDesktopPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'PaperDesktopPolicy(%r, %r)' % (self._tag, self._value)
PaperDesktopPolicy_validator = bv.Union(PaperDesktopPolicy)
class PaperEnabledPolicy(bb.Union): class PaperEnabledPolicy(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar disabled: Paper is disabled. :ivar team_policies.PaperEnabledPolicy.disabled: Paper is disabled.
:ivar enabled: Paper is enabled. :ivar team_policies.PaperEnabledPolicy.enabled: Paper is enabled.
:ivar unspecified: Unspecified policy. :ivar team_policies.PaperEnabledPolicy.unspecified: Unspecified policy.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -217,6 +427,9 @@ class PaperEnabledPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PaperEnabledPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PaperEnabledPolicy(%r, %r)' % (self._tag, self._value) return 'PaperEnabledPolicy(%r, %r)' % (self._tag, self._value)
@ -228,12 +441,12 @@ class PasswordStrengthPolicy(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar minimal_requirements: User passwords will adhere to the minimal :ivar team_policies.PasswordStrengthPolicy.minimal_requirements: User
password strength policy. passwords will adhere to the minimal password strength policy.
:ivar moderate_password: User passwords will adhere to the moderate password :ivar team_policies.PasswordStrengthPolicy.moderate_password: User passwords
strength policy. will adhere to the moderate password strength policy.
:ivar strong_password: User passwords will adhere to the very strong :ivar team_policies.PasswordStrengthPolicy.strong_password: User passwords
password strength policy. will adhere to the very strong password strength policy.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -278,6 +491,9 @@ class PasswordStrengthPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(PasswordStrengthPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'PasswordStrengthPolicy(%r, %r)' % (self._tag, self._value) return 'PasswordStrengthPolicy(%r, %r)' % (self._tag, self._value)
@ -289,9 +505,11 @@ class RolloutMethod(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar unlink_all: Unlink all. :ivar team_policies.RolloutMethod.unlink_all: Unlink all.
:ivar unlink_most_inactive: Unlink devices with the most inactivity. :ivar team_policies.RolloutMethod.unlink_most_inactive: Unlink devices with
:ivar add_member_to_exceptions: Add member to Exceptions. the most inactivity.
:ivar team_policies.RolloutMethod.add_member_to_exceptions: Add member to
Exceptions.
""" """
_catch_all = None _catch_all = None
@ -326,6 +544,9 @@ class RolloutMethod(bb.Union):
""" """
return self._tag == 'add_member_to_exceptions' return self._tag == 'add_member_to_exceptions'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(RolloutMethod, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'RolloutMethod(%r, %r)' % (self._tag, self._value) return 'RolloutMethod(%r, %r)' % (self._tag, self._value)
@ -339,10 +560,11 @@ class SharedFolderJoinPolicy(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar from_team_only: Team members can only join folders shared by :ivar team_policies.SharedFolderJoinPolicy.from_team_only: Team members can
teammates. only join folders shared by teammates.
:ivar from_anyone: Team members can join any shared folder, including those :ivar team_policies.SharedFolderJoinPolicy.from_anyone: Team members can
shared by users outside the team. join any shared folder, including those shared by users outside the
team.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -377,6 +599,9 @@ class SharedFolderJoinPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SharedFolderJoinPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SharedFolderJoinPolicy(%r, %r)' % (self._tag, self._value) return 'SharedFolderJoinPolicy(%r, %r)' % (self._tag, self._value)
@ -390,9 +615,10 @@ class SharedFolderMemberPolicy(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar team: Only a teammate can be a member of a folder shared by a team :ivar team_policies.SharedFolderMemberPolicy.team: Only a teammate can be a
member. member of a folder shared by a team member.
:ivar anyone: Anyone can be a member of a folder shared by a team member. :ivar team_policies.SharedFolderMemberPolicy.anyone: Anyone can be a member
of a folder shared by a team member.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -427,6 +653,9 @@ class SharedFolderMemberPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SharedFolderMemberPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SharedFolderMemberPolicy(%r, %r)' % (self._tag, self._value) return 'SharedFolderMemberPolicy(%r, %r)' % (self._tag, self._value)
@ -441,14 +670,15 @@ class SharedLinkCreatePolicy(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar default_public: By default, anyone can access newly created shared :ivar team_policies.SharedLinkCreatePolicy.default_public: By default,
links. No login will be required to access the shared links unless anyone can access newly created shared links. No login will be required
overridden. to access the shared links unless overridden.
:ivar default_team_only: By default, only members of the same team can :ivar team_policies.SharedLinkCreatePolicy.default_team_only: By default,
access newly created shared links. Login will be required to access the only members of the same team can access newly created shared links.
shared links unless overridden. Login will be required to access the shared links unless overridden.
:ivar team_only: Only members of the same team can access all shared links. :ivar team_policies.SharedLinkCreatePolicy.team_only: Only members of the
Login will be required to access all shared links. same team can access all shared links. Login will be required to access
all shared links.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -493,23 +723,232 @@ class SharedLinkCreatePolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SharedLinkCreatePolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SharedLinkCreatePolicy(%r, %r)' % (self._tag, self._value) return 'SharedLinkCreatePolicy(%r, %r)' % (self._tag, self._value)
SharedLinkCreatePolicy_validator = bv.Union(SharedLinkCreatePolicy) SharedLinkCreatePolicy_validator = bv.Union(SharedLinkCreatePolicy)
class ShowcaseDownloadPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.ShowcaseDownloadPolicy.disabled: Do not allow files to
be downloaded from Showcases.
:ivar team_policies.ShowcaseDownloadPolicy.enabled: Allow files to be
downloaded from Showcases.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
disabled = None
# Attribute is overwritten below the class definition
enabled = None
# Attribute is overwritten below the class definition
other = None
def is_disabled(self):
"""
Check if the union tag is ``disabled``.
:rtype: bool
"""
return self._tag == 'disabled'
def is_enabled(self):
"""
Check if the union tag is ``enabled``.
:rtype: bool
"""
return self._tag == 'enabled'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(ShowcaseDownloadPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'ShowcaseDownloadPolicy(%r, %r)' % (self._tag, self._value)
ShowcaseDownloadPolicy_validator = bv.Union(ShowcaseDownloadPolicy)
class ShowcaseEnabledPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.ShowcaseEnabledPolicy.disabled: Showcase is disabled.
:ivar team_policies.ShowcaseEnabledPolicy.enabled: Showcase is enabled.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
disabled = None
# Attribute is overwritten below the class definition
enabled = None
# Attribute is overwritten below the class definition
other = None
def is_disabled(self):
"""
Check if the union tag is ``disabled``.
:rtype: bool
"""
return self._tag == 'disabled'
def is_enabled(self):
"""
Check if the union tag is ``enabled``.
:rtype: bool
"""
return self._tag == 'enabled'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(ShowcaseEnabledPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'ShowcaseEnabledPolicy(%r, %r)' % (self._tag, self._value)
ShowcaseEnabledPolicy_validator = bv.Union(ShowcaseEnabledPolicy)
class ShowcaseExternalSharingPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.ShowcaseExternalSharingPolicy.disabled: Do not allow
showcases to be shared with people not on the team.
:ivar team_policies.ShowcaseExternalSharingPolicy.enabled: Allow showcases
to be shared with people not on the team.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
disabled = None
# Attribute is overwritten below the class definition
enabled = None
# Attribute is overwritten below the class definition
other = None
def is_disabled(self):
"""
Check if the union tag is ``disabled``.
:rtype: bool
"""
return self._tag == 'disabled'
def is_enabled(self):
"""
Check if the union tag is ``enabled``.
:rtype: bool
"""
return self._tag == 'enabled'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(ShowcaseExternalSharingPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'ShowcaseExternalSharingPolicy(%r, %r)' % (self._tag, self._value)
ShowcaseExternalSharingPolicy_validator = bv.Union(ShowcaseExternalSharingPolicy)
class SmartSyncPolicy(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.SmartSyncPolicy.local: The specified content will be
synced as local files by default.
:ivar team_policies.SmartSyncPolicy.on_demand: The specified content will be
synced as on-demand files by default.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
local = None
# Attribute is overwritten below the class definition
on_demand = None
# Attribute is overwritten below the class definition
other = None
def is_local(self):
"""
Check if the union tag is ``local``.
:rtype: bool
"""
return self._tag == 'local'
def is_on_demand(self):
"""
Check if the union tag is ``on_demand``.
:rtype: bool
"""
return self._tag == 'on_demand'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SmartSyncPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'SmartSyncPolicy(%r, %r)' % (self._tag, self._value)
SmartSyncPolicy_validator = bv.Union(SmartSyncPolicy)
class SsoPolicy(bb.Union): class SsoPolicy(bb.Union):
""" """
This class acts as a tagged union. Only one of the ``is_*`` methods will This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar disabled: Users will be able to sign in with their Dropbox :ivar team_policies.SsoPolicy.disabled: Users will be able to sign in with
credentials. their Dropbox credentials.
:ivar optional: Users will be able to sign in with either their Dropbox or :ivar team_policies.SsoPolicy.optional: Users will be able to sign in with
single sign-on credentials. either their Dropbox or single sign-on credentials.
:ivar required: Users will be required to sign in with their single sign-on :ivar team_policies.SsoPolicy.required: Users will be required to sign in
credentials. with their single sign-on credentials.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -554,24 +993,28 @@ class SsoPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SsoPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SsoPolicy(%r, %r)' % (self._tag, self._value) return 'SsoPolicy(%r, %r)' % (self._tag, self._value)
SsoPolicy_validator = bv.Union(SsoPolicy) SsoPolicy_validator = bv.Union(SsoPolicy)
class TeamMemberPolicies(object): class TeamMemberPolicies(bb.Struct):
""" """
Policies governing team members. Policies governing team members.
:ivar sharing: Policies governing sharing. :ivar team_policies.TeamMemberPolicies.sharing: Policies governing sharing.
:ivar emm_state: This describes the Enterprise Mobility Management (EMM) :ivar team_policies.TeamMemberPolicies.emm_state: This describes the
state for this team. This information can be used to understand if an Enterprise Mobility Management (EMM) state for this team. This
organization is integrating with a third-party EMM vendor to further information can be used to understand if an organization is integrating
manage and apply restrictions upon the team's Dropbox usage on mobile with a third-party EMM vendor to further manage and apply restrictions
devices. This is a new feature and in the future we'll be adding more upon the team's Dropbox usage on mobile devices. This is a new feature
new fields and additional documentation. and in the future we'll be adding more new fields and additional
:ivar office_addin: The admin policy around the Dropbox Office Add-In for documentation.
this team. :ivar team_policies.TeamMemberPolicies.office_addin: The admin policy around
the Dropbox Office Add-In for this team.
""" """
__slots__ = [ __slots__ = [
@ -676,6 +1119,9 @@ class TeamMemberPolicies(object):
self._office_addin_value = None self._office_addin_value = None
self._office_addin_present = False self._office_addin_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TeamMemberPolicies, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TeamMemberPolicies(sharing={!r}, emm_state={!r}, office_addin={!r})'.format( return 'TeamMemberPolicies(sharing={!r}, emm_state={!r}, office_addin={!r})'.format(
self._sharing_value, self._sharing_value,
@ -685,15 +1131,16 @@ class TeamMemberPolicies(object):
TeamMemberPolicies_validator = bv.Struct(TeamMemberPolicies) TeamMemberPolicies_validator = bv.Struct(TeamMemberPolicies)
class TeamSharingPolicies(object): class TeamSharingPolicies(bb.Struct):
""" """
Policies governing sharing within and outside of the team. Policies governing sharing within and outside of the team.
:ivar shared_folder_member_policy: Who can join folders shared by team :ivar team_policies.TeamSharingPolicies.shared_folder_member_policy: Who can
members. join folders shared by team members.
:ivar shared_folder_join_policy: Which shared folders team members can join. :ivar team_policies.TeamSharingPolicies.shared_folder_join_policy: Which
:ivar shared_link_create_policy: Who can view shared links owned by team shared folders team members can join.
members. :ivar team_policies.TeamSharingPolicies.shared_link_create_policy: Who can
view shared links owned by team members.
""" """
__slots__ = [ __slots__ = [
@ -793,6 +1240,9 @@ class TeamSharingPolicies(object):
self._shared_link_create_policy_value = None self._shared_link_create_policy_value = None
self._shared_link_create_policy_present = False self._shared_link_create_policy_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TeamSharingPolicies, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TeamSharingPolicies(shared_folder_member_policy={!r}, shared_folder_join_policy={!r}, shared_link_create_policy={!r})'.format( return 'TeamSharingPolicies(shared_folder_member_policy={!r}, shared_folder_join_policy={!r}, shared_link_create_policy={!r})'.format(
self._shared_folder_member_policy_value, self._shared_folder_member_policy_value,
@ -808,8 +1258,10 @@ class TwoStepVerificationPolicy(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar require_tfa_enable: Enabled require two factor authorization. :ivar team_policies.TwoStepVerificationPolicy.require_tfa_enable: Enabled
:ivar require_tfa_disable: Disabled require two factor authorization. require two factor authorization.
:ivar team_policies.TwoStepVerificationPolicy.require_tfa_disable: Disabled
require two factor authorization.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -844,11 +1296,79 @@ class TwoStepVerificationPolicy(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TwoStepVerificationPolicy, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TwoStepVerificationPolicy(%r, %r)' % (self._tag, self._value) return 'TwoStepVerificationPolicy(%r, %r)' % (self._tag, self._value)
TwoStepVerificationPolicy_validator = bv.Union(TwoStepVerificationPolicy) TwoStepVerificationPolicy_validator = bv.Union(TwoStepVerificationPolicy)
class TwoStepVerificationState(bb.Union):
"""
This class acts as a tagged union. Only one of the ``is_*`` methods will
return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method.
:ivar team_policies.TwoStepVerificationState.required: Enabled require two
factor authorization.
:ivar team_policies.TwoStepVerificationState.optional: Optional require two
factor authorization.
"""
_catch_all = 'other'
# Attribute is overwritten below the class definition
required = None
# Attribute is overwritten below the class definition
optional = None
# Attribute is overwritten below the class definition
other = None
def is_required(self):
"""
Check if the union tag is ``required``.
:rtype: bool
"""
return self._tag == 'required'
def is_optional(self):
"""
Check if the union tag is ``optional``.
:rtype: bool
"""
return self._tag == 'optional'
def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TwoStepVerificationState, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self):
return 'TwoStepVerificationState(%r, %r)' % (self._tag, self._value)
TwoStepVerificationState_validator = bv.Union(TwoStepVerificationState)
CameraUploadsPolicyState._disabled_validator = bv.Void()
CameraUploadsPolicyState._enabled_validator = bv.Void()
CameraUploadsPolicyState._other_validator = bv.Void()
CameraUploadsPolicyState._tagmap = {
'disabled': CameraUploadsPolicyState._disabled_validator,
'enabled': CameraUploadsPolicyState._enabled_validator,
'other': CameraUploadsPolicyState._other_validator,
}
CameraUploadsPolicyState.disabled = CameraUploadsPolicyState('disabled')
CameraUploadsPolicyState.enabled = CameraUploadsPolicyState('enabled')
CameraUploadsPolicyState.other = CameraUploadsPolicyState('other')
EmmState._disabled_validator = bv.Void() EmmState._disabled_validator = bv.Void()
EmmState._optional_validator = bv.Void() EmmState._optional_validator = bv.Void()
EmmState._required_validator = bv.Void() EmmState._required_validator = bv.Void()
@ -865,6 +1385,16 @@ EmmState.optional = EmmState('optional')
EmmState.required = EmmState('required') EmmState.required = EmmState('required')
EmmState.other = EmmState('other') EmmState.other = EmmState('other')
GroupCreation._admins_and_members_validator = bv.Void()
GroupCreation._admins_only_validator = bv.Void()
GroupCreation._tagmap = {
'admins_and_members': GroupCreation._admins_and_members_validator,
'admins_only': GroupCreation._admins_only_validator,
}
GroupCreation.admins_and_members = GroupCreation('admins_and_members')
GroupCreation.admins_only = GroupCreation('admins_only')
OfficeAddInPolicy._disabled_validator = bv.Void() OfficeAddInPolicy._disabled_validator = bv.Void()
OfficeAddInPolicy._enabled_validator = bv.Void() OfficeAddInPolicy._enabled_validator = bv.Void()
OfficeAddInPolicy._other_validator = bv.Void() OfficeAddInPolicy._other_validator = bv.Void()
@ -878,6 +1408,19 @@ OfficeAddInPolicy.disabled = OfficeAddInPolicy('disabled')
OfficeAddInPolicy.enabled = OfficeAddInPolicy('enabled') OfficeAddInPolicy.enabled = OfficeAddInPolicy('enabled')
OfficeAddInPolicy.other = OfficeAddInPolicy('other') OfficeAddInPolicy.other = OfficeAddInPolicy('other')
PaperDefaultFolderPolicy._everyone_in_team_validator = bv.Void()
PaperDefaultFolderPolicy._invite_only_validator = bv.Void()
PaperDefaultFolderPolicy._other_validator = bv.Void()
PaperDefaultFolderPolicy._tagmap = {
'everyone_in_team': PaperDefaultFolderPolicy._everyone_in_team_validator,
'invite_only': PaperDefaultFolderPolicy._invite_only_validator,
'other': PaperDefaultFolderPolicy._other_validator,
}
PaperDefaultFolderPolicy.everyone_in_team = PaperDefaultFolderPolicy('everyone_in_team')
PaperDefaultFolderPolicy.invite_only = PaperDefaultFolderPolicy('invite_only')
PaperDefaultFolderPolicy.other = PaperDefaultFolderPolicy('other')
PaperDeploymentPolicy._full_validator = bv.Void() PaperDeploymentPolicy._full_validator = bv.Void()
PaperDeploymentPolicy._partial_validator = bv.Void() PaperDeploymentPolicy._partial_validator = bv.Void()
PaperDeploymentPolicy._other_validator = bv.Void() PaperDeploymentPolicy._other_validator = bv.Void()
@ -891,6 +1434,19 @@ PaperDeploymentPolicy.full = PaperDeploymentPolicy('full')
PaperDeploymentPolicy.partial = PaperDeploymentPolicy('partial') PaperDeploymentPolicy.partial = PaperDeploymentPolicy('partial')
PaperDeploymentPolicy.other = PaperDeploymentPolicy('other') PaperDeploymentPolicy.other = PaperDeploymentPolicy('other')
PaperDesktopPolicy._disabled_validator = bv.Void()
PaperDesktopPolicy._enabled_validator = bv.Void()
PaperDesktopPolicy._other_validator = bv.Void()
PaperDesktopPolicy._tagmap = {
'disabled': PaperDesktopPolicy._disabled_validator,
'enabled': PaperDesktopPolicy._enabled_validator,
'other': PaperDesktopPolicy._other_validator,
}
PaperDesktopPolicy.disabled = PaperDesktopPolicy('disabled')
PaperDesktopPolicy.enabled = PaperDesktopPolicy('enabled')
PaperDesktopPolicy.other = PaperDesktopPolicy('other')
PaperEnabledPolicy._disabled_validator = bv.Void() PaperEnabledPolicy._disabled_validator = bv.Void()
PaperEnabledPolicy._enabled_validator = bv.Void() PaperEnabledPolicy._enabled_validator = bv.Void()
PaperEnabledPolicy._unspecified_validator = bv.Void() PaperEnabledPolicy._unspecified_validator = bv.Void()
@ -978,6 +1534,58 @@ SharedLinkCreatePolicy.default_team_only = SharedLinkCreatePolicy('default_team_
SharedLinkCreatePolicy.team_only = SharedLinkCreatePolicy('team_only') SharedLinkCreatePolicy.team_only = SharedLinkCreatePolicy('team_only')
SharedLinkCreatePolicy.other = SharedLinkCreatePolicy('other') SharedLinkCreatePolicy.other = SharedLinkCreatePolicy('other')
ShowcaseDownloadPolicy._disabled_validator = bv.Void()
ShowcaseDownloadPolicy._enabled_validator = bv.Void()
ShowcaseDownloadPolicy._other_validator = bv.Void()
ShowcaseDownloadPolicy._tagmap = {
'disabled': ShowcaseDownloadPolicy._disabled_validator,
'enabled': ShowcaseDownloadPolicy._enabled_validator,
'other': ShowcaseDownloadPolicy._other_validator,
}
ShowcaseDownloadPolicy.disabled = ShowcaseDownloadPolicy('disabled')
ShowcaseDownloadPolicy.enabled = ShowcaseDownloadPolicy('enabled')
ShowcaseDownloadPolicy.other = ShowcaseDownloadPolicy('other')
ShowcaseEnabledPolicy._disabled_validator = bv.Void()
ShowcaseEnabledPolicy._enabled_validator = bv.Void()
ShowcaseEnabledPolicy._other_validator = bv.Void()
ShowcaseEnabledPolicy._tagmap = {
'disabled': ShowcaseEnabledPolicy._disabled_validator,
'enabled': ShowcaseEnabledPolicy._enabled_validator,
'other': ShowcaseEnabledPolicy._other_validator,
}
ShowcaseEnabledPolicy.disabled = ShowcaseEnabledPolicy('disabled')
ShowcaseEnabledPolicy.enabled = ShowcaseEnabledPolicy('enabled')
ShowcaseEnabledPolicy.other = ShowcaseEnabledPolicy('other')
ShowcaseExternalSharingPolicy._disabled_validator = bv.Void()
ShowcaseExternalSharingPolicy._enabled_validator = bv.Void()
ShowcaseExternalSharingPolicy._other_validator = bv.Void()
ShowcaseExternalSharingPolicy._tagmap = {
'disabled': ShowcaseExternalSharingPolicy._disabled_validator,
'enabled': ShowcaseExternalSharingPolicy._enabled_validator,
'other': ShowcaseExternalSharingPolicy._other_validator,
}
ShowcaseExternalSharingPolicy.disabled = ShowcaseExternalSharingPolicy('disabled')
ShowcaseExternalSharingPolicy.enabled = ShowcaseExternalSharingPolicy('enabled')
ShowcaseExternalSharingPolicy.other = ShowcaseExternalSharingPolicy('other')
SmartSyncPolicy._local_validator = bv.Void()
SmartSyncPolicy._on_demand_validator = bv.Void()
SmartSyncPolicy._other_validator = bv.Void()
SmartSyncPolicy._tagmap = {
'local': SmartSyncPolicy._local_validator,
'on_demand': SmartSyncPolicy._on_demand_validator,
'other': SmartSyncPolicy._other_validator,
}
SmartSyncPolicy.local = SmartSyncPolicy('local')
SmartSyncPolicy.on_demand = SmartSyncPolicy('on_demand')
SmartSyncPolicy.other = SmartSyncPolicy('other')
SsoPolicy._disabled_validator = bv.Void() SsoPolicy._disabled_validator = bv.Void()
SsoPolicy._optional_validator = bv.Void() SsoPolicy._optional_validator = bv.Void()
SsoPolicy._required_validator = bv.Void() SsoPolicy._required_validator = bv.Void()
@ -1035,6 +1643,19 @@ TwoStepVerificationPolicy.require_tfa_enable = TwoStepVerificationPolicy('requir
TwoStepVerificationPolicy.require_tfa_disable = TwoStepVerificationPolicy('require_tfa_disable') TwoStepVerificationPolicy.require_tfa_disable = TwoStepVerificationPolicy('require_tfa_disable')
TwoStepVerificationPolicy.other = TwoStepVerificationPolicy('other') TwoStepVerificationPolicy.other = TwoStepVerificationPolicy('other')
TwoStepVerificationState._required_validator = bv.Void()
TwoStepVerificationState._optional_validator = bv.Void()
TwoStepVerificationState._other_validator = bv.Void()
TwoStepVerificationState._tagmap = {
'required': TwoStepVerificationState._required_validator,
'optional': TwoStepVerificationState._optional_validator,
'other': TwoStepVerificationState._other_validator,
}
TwoStepVerificationState.required = TwoStepVerificationState('required')
TwoStepVerificationState.optional = TwoStepVerificationState('optional')
TwoStepVerificationState.other = TwoStepVerificationState('other')
ROUTES = { ROUTES = {
} }

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
""" """
@ -9,7 +10,7 @@ This namespace contains endpoints and data types for user management.
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
@ -17,27 +18,32 @@ except (SystemError, ValueError):
try: try:
from . import ( from . import (
common,
team_common,
team_policies, team_policies,
users_common, users_common,
) )
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
import common
import team_common
import team_policies import team_policies
import users_common import users_common
class Account(object): class Account(bb.Struct):
""" """
The amount of detail revealed about an account depends on the user being The amount of detail revealed about an account depends on the user being
queried and the user making the query. queried and the user making the query.
:ivar account_id: The user's unique Dropbox ID. :ivar users.Account.account_id: The user's unique Dropbox ID.
:ivar name: Details of a user's name. :ivar users.Account.name: Details of a user's name.
:ivar email: The user's e-mail address. Do not rely on this without checking :ivar users.Account.email: The user's e-mail address. Do not rely on this
the ``email_verified`` field. Even then, it's possible that the user has without checking the ``email_verified`` field. Even then, it's possible
since lost access to their e-mail. that the user has since lost access to their e-mail.
:ivar email_verified: Whether the user has verified their e-mail address. :ivar users.Account.email_verified: Whether the user has verified their
:ivar profile_photo_url: URL for the photo representing the user, if one is e-mail address.
set. :ivar users.Account.profile_photo_url: URL for the photo representing the
:ivar disabled: Whether the user has been disabled. user, if one is set.
:ivar users.Account.disabled: Whether the user has been disabled.
""" """
__slots__ = [ __slots__ = [
@ -232,6 +238,9 @@ class Account(object):
self._disabled_value = None self._disabled_value = None
self._disabled_present = False self._disabled_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(Account, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'Account(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, profile_photo_url={!r})'.format( return 'Account(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, profile_photo_url={!r})'.format(
self._account_id_value, self._account_id_value,
@ -248,11 +257,12 @@ class BasicAccount(Account):
""" """
Basic information about any account. Basic information about any account.
:ivar is_teammate: Whether this user is a teammate of the current user. If :ivar users.BasicAccount.is_teammate: Whether this user is a teammate of the
this account is the current user's account, then this will be ``True``. current user. If this account is the current user's account, then this
:ivar team_member_id: The user's unique team member id. This field will only will be ``True``.
be present if the user is part of a team and ``is_teammate`` is :ivar users.BasicAccount.team_member_id: The user's unique team member id.
``True``. This field will only be present if the user is part of a team and
``is_teammate`` is ``True``.
""" """
__slots__ = [ __slots__ = [
@ -339,6 +349,9 @@ class BasicAccount(Account):
self._team_member_id_value = None self._team_member_id_value = None
self._team_member_id_present = False self._team_member_id_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(BasicAccount, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'BasicAccount(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, is_teammate={!r}, profile_photo_url={!r}, team_member_id={!r})'.format( return 'BasicAccount(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, is_teammate={!r}, profile_photo_url={!r}, team_member_id={!r})'.format(
self._account_id_value, self._account_id_value,
@ -357,21 +370,23 @@ class FullAccount(Account):
""" """
Detailed information about the current user's account. Detailed information about the current user's account.
:ivar country: The user's two-letter country code, if available. Country :ivar users.FullAccount.country: The user's two-letter country code, if
codes are based on `ISO 3166-1 available. Country codes are based on `ISO 3166-1
<http://en.wikipedia.org/wiki/ISO_3166-1>`_. <http://en.wikipedia.org/wiki/ISO_3166-1>`_.
:ivar locale: The language that the user specified. Locale tags will be :ivar users.FullAccount.locale: The language that the user specified. Locale
`IETF language tags <http://en.wikipedia.org/wiki/IETF_language_tag>`_. tags will be `IETF language tags
:ivar referral_link: The user's `referral link <http://en.wikipedia.org/wiki/IETF_language_tag>`_.
:ivar users.FullAccount.referral_link: The user's `referral link
<https://www.dropbox.com/referrals>`_. <https://www.dropbox.com/referrals>`_.
:ivar team: If this account is a member of a team, information about that :ivar users.FullAccount.team: If this account is a member of a team,
team. information about that team.
:ivar team_member_id: This account's unique team member id. This field will :ivar users.FullAccount.team_member_id: This account's unique team member
only be present if ``team`` is present. id. This field will only be present if ``team`` is present.
:ivar is_paired: Whether the user has a personal and work account. If the :ivar users.FullAccount.is_paired: Whether the user has a personal and work
current account is personal, then ``team`` will always be None, but account. If the current account is personal, then ``team`` will always
``is_paired`` will indicate if a work account is linked. be None, but ``is_paired`` will indicate if a work account is linked.
:ivar account_type: What type of account this user has. :ivar users.FullAccount.account_type: What type of account this user has.
:ivar users.FullAccount.root_info: The root info for this account.
""" """
__slots__ = [ __slots__ = [
@ -389,6 +404,8 @@ class FullAccount(Account):
'_is_paired_present', '_is_paired_present',
'_account_type_value', '_account_type_value',
'_account_type_present', '_account_type_present',
'_root_info_value',
'_root_info_present',
] ]
_has_required_fields = True _has_required_fields = True
@ -403,6 +420,7 @@ class FullAccount(Account):
referral_link=None, referral_link=None,
is_paired=None, is_paired=None,
account_type=None, account_type=None,
root_info=None,
profile_photo_url=None, profile_photo_url=None,
country=None, country=None,
team=None, team=None,
@ -427,6 +445,8 @@ class FullAccount(Account):
self._is_paired_present = False self._is_paired_present = False
self._account_type_value = None self._account_type_value = None
self._account_type_present = False self._account_type_present = False
self._root_info_value = None
self._root_info_present = False
if country is not None: if country is not None:
self.country = country self.country = country
if locale is not None: if locale is not None:
@ -441,6 +461,8 @@ class FullAccount(Account):
self.is_paired = is_paired self.is_paired = is_paired
if account_type is not None: if account_type is not None:
self.account_type = account_type self.account_type = account_type
if root_info is not None:
self.root_info = root_info
@property @property
def country(self): def country(self):
@ -599,7 +621,7 @@ class FullAccount(Account):
""" """
What type of account this user has. What type of account this user has.
:rtype: users_common.AccountType_validator :rtype: users_common.AccountType
""" """
if self._account_type_present: if self._account_type_present:
return self._account_type_value return self._account_type_value
@ -617,8 +639,34 @@ class FullAccount(Account):
self._account_type_value = None self._account_type_value = None
self._account_type_present = False self._account_type_present = False
@property
def root_info(self):
"""
The root info for this account.
:rtype: common.RootInfo
"""
if self._root_info_present:
return self._root_info_value
else:
raise AttributeError("missing required field 'root_info'")
@root_info.setter
def root_info(self, val):
self._root_info_validator.validate_type_only(val)
self._root_info_value = val
self._root_info_present = True
@root_info.deleter
def root_info(self):
self._root_info_value = None
self._root_info_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(FullAccount, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'FullAccount(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, locale={!r}, referral_link={!r}, is_paired={!r}, account_type={!r}, profile_photo_url={!r}, country={!r}, team={!r}, team_member_id={!r})'.format( return 'FullAccount(account_id={!r}, name={!r}, email={!r}, email_verified={!r}, disabled={!r}, locale={!r}, referral_link={!r}, is_paired={!r}, account_type={!r}, root_info={!r}, profile_photo_url={!r}, country={!r}, team={!r}, team_member_id={!r})'.format(
self._account_id_value, self._account_id_value,
self._name_value, self._name_value,
self._email_value, self._email_value,
@ -628,6 +676,7 @@ class FullAccount(Account):
self._referral_link_value, self._referral_link_value,
self._is_paired_value, self._is_paired_value,
self._account_type_value, self._account_type_value,
self._root_info_value,
self._profile_photo_url_value, self._profile_photo_url_value,
self._country_value, self._country_value,
self._team_value, self._team_value,
@ -636,12 +685,12 @@ class FullAccount(Account):
FullAccount_validator = bv.Struct(FullAccount) FullAccount_validator = bv.Struct(FullAccount)
class Team(object): class Team(bb.Struct):
""" """
Information about a team. Information about a team.
:ivar id: The team's unique ID. :ivar users.Team.id: The team's unique ID.
:ivar name: The name of the team. :ivar users.Team.name: The name of the team.
""" """
__slots__ = [ __slots__ = [
@ -711,6 +760,9 @@ class Team(object):
self._name_value = None self._name_value = None
self._name_present = False self._name_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(Team, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'Team(id={!r}, name={!r})'.format( return 'Team(id={!r}, name={!r})'.format(
self._id_value, self._id_value,
@ -723,9 +775,9 @@ class FullTeam(Team):
""" """
Detailed information about a team. Detailed information about a team.
:ivar sharing_policies: Team policies governing sharing. :ivar users.FullTeam.sharing_policies: Team policies governing sharing.
:ivar office_addin_policy: Team policy governing the use of the Office :ivar users.FullTeam.office_addin_policy: Team policy governing the use of
Add-In. the Office Add-In.
""" """
__slots__ = [ __slots__ = [
@ -758,7 +810,7 @@ class FullTeam(Team):
""" """
Team policies governing sharing. Team policies governing sharing.
:rtype: team_policies.TeamSharingPolicies_validator :rtype: team_policies.TeamSharingPolicies
""" """
if self._sharing_policies_present: if self._sharing_policies_present:
return self._sharing_policies_value return self._sharing_policies_value
@ -781,7 +833,7 @@ class FullTeam(Team):
""" """
Team policy governing the use of the Office Add-In. Team policy governing the use of the Office Add-In.
:rtype: team_policies.OfficeAddInPolicy_validator :rtype: team_policies.OfficeAddInPolicy
""" """
if self._office_addin_policy_present: if self._office_addin_policy_present:
return self._office_addin_policy_value return self._office_addin_policy_value
@ -799,6 +851,9 @@ class FullTeam(Team):
self._office_addin_policy_value = None self._office_addin_policy_value = None
self._office_addin_policy_present = False self._office_addin_policy_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(FullTeam, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'FullTeam(id={!r}, name={!r}, sharing_policies={!r}, office_addin_policy={!r})'.format( return 'FullTeam(id={!r}, name={!r}, sharing_policies={!r}, office_addin_policy={!r})'.format(
self._id_value, self._id_value,
@ -809,9 +864,9 @@ class FullTeam(Team):
FullTeam_validator = bv.Struct(FullTeam) FullTeam_validator = bv.Struct(FullTeam)
class GetAccountArg(object): class GetAccountArg(bb.Struct):
""" """
:ivar account_id: A user's account identifier. :ivar users.GetAccountArg.account_id: A user's account identifier.
""" """
__slots__ = [ __slots__ = [
@ -851,6 +906,9 @@ class GetAccountArg(object):
self._account_id_value = None self._account_id_value = None
self._account_id_present = False self._account_id_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GetAccountArg, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GetAccountArg(account_id={!r})'.format( return 'GetAccountArg(account_id={!r})'.format(
self._account_id_value, self._account_id_value,
@ -858,10 +916,10 @@ class GetAccountArg(object):
GetAccountArg_validator = bv.Struct(GetAccountArg) GetAccountArg_validator = bv.Struct(GetAccountArg)
class GetAccountBatchArg(object): class GetAccountBatchArg(bb.Struct):
""" """
:ivar account_ids: List of user account identifiers. Should not contain any :ivar users.GetAccountBatchArg.account_ids: List of user account
duplicate account IDs. identifiers. Should not contain any duplicate account IDs.
""" """
__slots__ = [ __slots__ = [
@ -902,6 +960,9 @@ class GetAccountBatchArg(object):
self._account_ids_value = None self._account_ids_value = None
self._account_ids_present = False self._account_ids_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GetAccountBatchArg, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GetAccountBatchArg(account_ids={!r})'.format( return 'GetAccountBatchArg(account_ids={!r})'.format(
self._account_ids_value, self._account_ids_value,
@ -915,8 +976,9 @@ class GetAccountBatchError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar str no_account: The value is an account ID specified in :ivar str users.GetAccountBatchError.no_account: The value is an account ID
:field:`GetAccountBatchArg.account_ids` that does not exist. specified in :field:`GetAccountBatchArg.account_ids` that does not
exist.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -963,6 +1025,9 @@ class GetAccountBatchError(bb.Union):
raise AttributeError("tag 'no_account' not set") raise AttributeError("tag 'no_account' not set")
return self._value return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GetAccountBatchError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GetAccountBatchError(%r, %r)' % (self._tag, self._value) return 'GetAccountBatchError(%r, %r)' % (self._tag, self._value)
@ -974,7 +1039,8 @@ class GetAccountError(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar no_account: The specified ``GetAccountArg.account_id`` does not exist. :ivar users.GetAccountError.no_account: The specified
``GetAccountArg.account_id`` does not exist.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -999,14 +1065,18 @@ class GetAccountError(bb.Union):
""" """
return self._tag == 'other' return self._tag == 'other'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(GetAccountError, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'GetAccountError(%r, %r)' % (self._tag, self._value) return 'GetAccountError(%r, %r)' % (self._tag, self._value)
GetAccountError_validator = bv.Union(GetAccountError) GetAccountError_validator = bv.Union(GetAccountError)
class IndividualSpaceAllocation(object): class IndividualSpaceAllocation(bb.Struct):
""" """
:ivar allocated: The total space allocated to the user's account (bytes). :ivar users.IndividualSpaceAllocation.allocated: The total space allocated
to the user's account (bytes).
""" """
__slots__ = [ __slots__ = [
@ -1028,7 +1098,7 @@ class IndividualSpaceAllocation(object):
""" """
The total space allocated to the user's account (bytes). The total space allocated to the user's account (bytes).
:rtype: long :rtype: int
""" """
if self._allocated_present: if self._allocated_present:
return self._allocated_value return self._allocated_value
@ -1046,6 +1116,9 @@ class IndividualSpaceAllocation(object):
self._allocated_value = None self._allocated_value = None
self._allocated_present = False self._allocated_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(IndividualSpaceAllocation, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'IndividualSpaceAllocation(allocated={!r})'.format( return 'IndividualSpaceAllocation(allocated={!r})'.format(
self._allocated_value, self._allocated_value,
@ -1053,19 +1126,19 @@ class IndividualSpaceAllocation(object):
IndividualSpaceAllocation_validator = bv.Struct(IndividualSpaceAllocation) IndividualSpaceAllocation_validator = bv.Struct(IndividualSpaceAllocation)
class Name(object): class Name(bb.Struct):
""" """
Representations for a person's name to assist with internationalization. Representations for a person's name to assist with internationalization.
:ivar given_name: Also known as a first name. :ivar users.Name.given_name: Also known as a first name.
:ivar surname: Also known as a last name or family name. :ivar users.Name.surname: Also known as a last name or family name.
:ivar familiar_name: Locale-dependent name. In the US, a person's familiar :ivar users.Name.familiar_name: Locale-dependent name. In the US, a person's
name is their ``given_name``, but elsewhere, it could be any combination familiar name is their ``given_name``, but elsewhere, it could be any
of a person's ``given_name`` and ``surname``. combination of a person's ``given_name`` and ``surname``.
:ivar display_name: A name that can be used directly to represent the name :ivar users.Name.display_name: A name that can be used directly to represent
of a user's Dropbox account. the name of a user's Dropbox account.
:ivar abbreviated_name: An abbreviated form of the person's name. Their :ivar users.Name.abbreviated_name: An abbreviated form of the person's name.
initials in most locales. Their initials in most locales.
""" """
__slots__ = [ __slots__ = [
@ -1229,6 +1302,9 @@ class Name(object):
self._abbreviated_name_value = None self._abbreviated_name_value = None
self._abbreviated_name_present = False self._abbreviated_name_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(Name, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'Name(given_name={!r}, surname={!r}, familiar_name={!r}, display_name={!r}, abbreviated_name={!r})'.format( return 'Name(given_name={!r}, surname={!r}, familiar_name={!r}, display_name={!r}, abbreviated_name={!r})'.format(
self._given_name_value, self._given_name_value,
@ -1248,10 +1324,10 @@ class SpaceAllocation(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar IndividualSpaceAllocation individual: The user's space allocation :ivar IndividualSpaceAllocation SpaceAllocation.individual: The user's space
applies only to their individual account. allocation applies only to their individual account.
:ivar TeamSpaceAllocation team: The user shares space with other members of :ivar TeamSpaceAllocation SpaceAllocation.team: The user shares space with
their team. other members of their team.
""" """
_catch_all = 'other' _catch_all = 'other'
@ -1328,17 +1404,20 @@ class SpaceAllocation(bb.Union):
raise AttributeError("tag 'team' not set") raise AttributeError("tag 'team' not set")
return self._value return self._value
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SpaceAllocation, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SpaceAllocation(%r, %r)' % (self._tag, self._value) return 'SpaceAllocation(%r, %r)' % (self._tag, self._value)
SpaceAllocation_validator = bv.Union(SpaceAllocation) SpaceAllocation_validator = bv.Union(SpaceAllocation)
class SpaceUsage(object): class SpaceUsage(bb.Struct):
""" """
Information about a user's space usage and quota. Information about a user's space usage and quota.
:ivar used: The user's total space usage (bytes). :ivar users.SpaceUsage.used: The user's total space usage (bytes).
:ivar allocation: The user's space allocation. :ivar users.SpaceUsage.allocation: The user's space allocation.
""" """
__slots__ = [ __slots__ = [
@ -1367,7 +1446,7 @@ class SpaceUsage(object):
""" """
The user's total space usage (bytes). The user's total space usage (bytes).
:rtype: long :rtype: int
""" """
if self._used_present: if self._used_present:
return self._used_value return self._used_value
@ -1408,6 +1487,9 @@ class SpaceUsage(object):
self._allocation_value = None self._allocation_value = None
self._allocation_present = False self._allocation_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(SpaceUsage, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'SpaceUsage(used={!r}, allocation={!r})'.format( return 'SpaceUsage(used={!r}, allocation={!r})'.format(
self._used_value, self._used_value,
@ -1416,10 +1498,18 @@ class SpaceUsage(object):
SpaceUsage_validator = bv.Struct(SpaceUsage) SpaceUsage_validator = bv.Struct(SpaceUsage)
class TeamSpaceAllocation(object): class TeamSpaceAllocation(bb.Struct):
""" """
:ivar used: The total space currently used by the user's team (bytes). :ivar users.TeamSpaceAllocation.used: The total space currently used by the
:ivar allocated: The total space allocated to the user's team (bytes). user's team (bytes).
:ivar users.TeamSpaceAllocation.allocated: The total space allocated to the
user's team (bytes).
:ivar users.TeamSpaceAllocation.user_within_team_space_allocated: The total
space allocated to the user within its team allocated space (0 means
that no restriction is imposed on the user's quota within its team).
:ivar users.TeamSpaceAllocation.user_within_team_space_limit_type: The type
of the space limit imposed on the team member (off, alert_only,
stop_sync).
""" """
__slots__ = [ __slots__ = [
@ -1427,28 +1517,42 @@ class TeamSpaceAllocation(object):
'_used_present', '_used_present',
'_allocated_value', '_allocated_value',
'_allocated_present', '_allocated_present',
'_user_within_team_space_allocated_value',
'_user_within_team_space_allocated_present',
'_user_within_team_space_limit_type_value',
'_user_within_team_space_limit_type_present',
] ]
_has_required_fields = True _has_required_fields = True
def __init__(self, def __init__(self,
used=None, used=None,
allocated=None): allocated=None,
user_within_team_space_allocated=None,
user_within_team_space_limit_type=None):
self._used_value = None self._used_value = None
self._used_present = False self._used_present = False
self._allocated_value = None self._allocated_value = None
self._allocated_present = False self._allocated_present = False
self._user_within_team_space_allocated_value = None
self._user_within_team_space_allocated_present = False
self._user_within_team_space_limit_type_value = None
self._user_within_team_space_limit_type_present = False
if used is not None: if used is not None:
self.used = used self.used = used
if allocated is not None: if allocated is not None:
self.allocated = allocated self.allocated = allocated
if user_within_team_space_allocated is not None:
self.user_within_team_space_allocated = user_within_team_space_allocated
if user_within_team_space_limit_type is not None:
self.user_within_team_space_limit_type = user_within_team_space_limit_type
@property @property
def used(self): def used(self):
""" """
The total space currently used by the user's team (bytes). The total space currently used by the user's team (bytes).
:rtype: long :rtype: int
""" """
if self._used_present: if self._used_present:
return self._used_value return self._used_value
@ -1471,7 +1575,7 @@ class TeamSpaceAllocation(object):
""" """
The total space allocated to the user's team (bytes). The total space allocated to the user's team (bytes).
:rtype: long :rtype: int
""" """
if self._allocated_present: if self._allocated_present:
return self._allocated_value return self._allocated_value
@ -1489,10 +1593,64 @@ class TeamSpaceAllocation(object):
self._allocated_value = None self._allocated_value = None
self._allocated_present = False self._allocated_present = False
@property
def user_within_team_space_allocated(self):
"""
The total space allocated to the user within its team allocated space (0
means that no restriction is imposed on the user's quota within its
team).
:rtype: int
"""
if self._user_within_team_space_allocated_present:
return self._user_within_team_space_allocated_value
else:
raise AttributeError("missing required field 'user_within_team_space_allocated'")
@user_within_team_space_allocated.setter
def user_within_team_space_allocated(self, val):
val = self._user_within_team_space_allocated_validator.validate(val)
self._user_within_team_space_allocated_value = val
self._user_within_team_space_allocated_present = True
@user_within_team_space_allocated.deleter
def user_within_team_space_allocated(self):
self._user_within_team_space_allocated_value = None
self._user_within_team_space_allocated_present = False
@property
def user_within_team_space_limit_type(self):
"""
The type of the space limit imposed on the team member (off, alert_only,
stop_sync).
:rtype: team_common.MemberSpaceLimitType
"""
if self._user_within_team_space_limit_type_present:
return self._user_within_team_space_limit_type_value
else:
raise AttributeError("missing required field 'user_within_team_space_limit_type'")
@user_within_team_space_limit_type.setter
def user_within_team_space_limit_type(self, val):
self._user_within_team_space_limit_type_validator.validate_type_only(val)
self._user_within_team_space_limit_type_value = val
self._user_within_team_space_limit_type_present = True
@user_within_team_space_limit_type.deleter
def user_within_team_space_limit_type(self):
self._user_within_team_space_limit_type_value = None
self._user_within_team_space_limit_type_present = False
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(TeamSpaceAllocation, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'TeamSpaceAllocation(used={!r}, allocated={!r})'.format( return 'TeamSpaceAllocation(used={!r}, allocated={!r}, user_within_team_space_allocated={!r}, user_within_team_space_limit_type={!r})'.format(
self._used_value, self._used_value,
self._allocated_value, self._allocated_value,
self._user_within_team_space_allocated_value,
self._user_within_team_space_limit_type_value,
) )
TeamSpaceAllocation_validator = bv.Struct(TeamSpaceAllocation) TeamSpaceAllocation_validator = bv.Struct(TeamSpaceAllocation)
@ -1539,6 +1697,7 @@ FullAccount._team_validator = bv.Nullable(FullTeam_validator)
FullAccount._team_member_id_validator = bv.Nullable(bv.String()) FullAccount._team_member_id_validator = bv.Nullable(bv.String())
FullAccount._is_paired_validator = bv.Boolean() FullAccount._is_paired_validator = bv.Boolean()
FullAccount._account_type_validator = users_common.AccountType_validator FullAccount._account_type_validator = users_common.AccountType_validator
FullAccount._root_info_validator = common.RootInfo_validator
FullAccount._all_field_names_ = Account._all_field_names_.union(set([ FullAccount._all_field_names_ = Account._all_field_names_.union(set([
'country', 'country',
'locale', 'locale',
@ -1547,6 +1706,7 @@ FullAccount._all_field_names_ = Account._all_field_names_.union(set([
'team_member_id', 'team_member_id',
'is_paired', 'is_paired',
'account_type', 'account_type',
'root_info',
])) ]))
FullAccount._all_fields_ = Account._all_fields_ + [ FullAccount._all_fields_ = Account._all_fields_ + [
('country', FullAccount._country_validator), ('country', FullAccount._country_validator),
@ -1556,6 +1716,7 @@ FullAccount._all_fields_ = Account._all_fields_ + [
('team_member_id', FullAccount._team_member_id_validator), ('team_member_id', FullAccount._team_member_id_validator),
('is_paired', FullAccount._is_paired_validator), ('is_paired', FullAccount._is_paired_validator),
('account_type', FullAccount._account_type_validator), ('account_type', FullAccount._account_type_validator),
('root_info', FullAccount._root_info_validator),
] ]
Team._id_validator = bv.String() Team._id_validator = bv.String()
@ -1655,17 +1816,24 @@ SpaceUsage._all_fields_ = [
TeamSpaceAllocation._used_validator = bv.UInt64() TeamSpaceAllocation._used_validator = bv.UInt64()
TeamSpaceAllocation._allocated_validator = bv.UInt64() TeamSpaceAllocation._allocated_validator = bv.UInt64()
TeamSpaceAllocation._user_within_team_space_allocated_validator = bv.UInt64()
TeamSpaceAllocation._user_within_team_space_limit_type_validator = team_common.MemberSpaceLimitType_validator
TeamSpaceAllocation._all_field_names_ = set([ TeamSpaceAllocation._all_field_names_ = set([
'used', 'used',
'allocated', 'allocated',
'user_within_team_space_allocated',
'user_within_team_space_limit_type',
]) ])
TeamSpaceAllocation._all_fields_ = [ TeamSpaceAllocation._all_fields_ = [
('used', TeamSpaceAllocation._used_validator), ('used', TeamSpaceAllocation._used_validator),
('allocated', TeamSpaceAllocation._allocated_validator), ('allocated', TeamSpaceAllocation._allocated_validator),
('user_within_team_space_allocated', TeamSpaceAllocation._user_within_team_space_allocated_validator),
('user_within_team_space_limit_type', TeamSpaceAllocation._user_within_team_space_limit_type_validator),
] ]
get_account = bb.Route( get_account = bb.Route(
'get_account', 'get_account',
1,
False, False,
GetAccountArg_validator, GetAccountArg_validator,
BasicAccount_validator, BasicAccount_validator,
@ -1675,6 +1843,7 @@ get_account = bb.Route(
) )
get_account_batch = bb.Route( get_account_batch = bb.Route(
'get_account_batch', 'get_account_batch',
1,
False, False,
GetAccountBatchArg_validator, GetAccountBatchArg_validator,
GetAccountBatchResult_validator, GetAccountBatchResult_validator,
@ -1684,6 +1853,7 @@ get_account_batch = bb.Route(
) )
get_current_account = bb.Route( get_current_account = bb.Route(
'get_current_account', 'get_current_account',
1,
False, False,
bv.Void(), bv.Void(),
FullAccount_validator, FullAccount_validator,
@ -1693,6 +1863,7 @@ get_current_account = bb.Route(
) )
get_space_usage = bb.Route( get_space_usage = bb.Route(
'get_space_usage', 'get_space_usage',
1,
False, False,
bv.Void(), bv.Void(),
SpaceUsage_validator, SpaceUsage_validator,

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify. # Auto-generated by Stone, do not modify.
# @generated
# flake8: noqa # flake8: noqa
# pylint: skip-file # pylint: skip-file
""" """
@ -9,7 +10,7 @@ This namespace contains common data types used within the users namespace.
try: try:
from . import stone_validators as bv from . import stone_validators as bv
from . import stone_base as bb from . import stone_base as bb
except (SystemError, ValueError): except (ImportError, SystemError, ValueError):
# Catch errors raised when importing a relative module when not in a package. # Catch errors raised when importing a relative module when not in a package.
# This makes testing this file directly (outside of a package) easier. # This makes testing this file directly (outside of a package) easier.
import stone_validators as bv import stone_validators as bv
@ -23,9 +24,9 @@ class AccountType(bb.Union):
return true. To get the associated value of a tag (if one exists), use the return true. To get the associated value of a tag (if one exists), use the
corresponding ``get_*`` method. corresponding ``get_*`` method.
:ivar basic: The basic account type. :ivar users_common.AccountType.basic: The basic account type.
:ivar pro: The Dropbox Pro account type. :ivar users_common.AccountType.pro: The Dropbox Pro account type.
:ivar business: The Dropbox Business account type. :ivar users_common.AccountType.business: The Dropbox Business account type.
""" """
_catch_all = None _catch_all = None
@ -60,6 +61,9 @@ class AccountType(bb.Union):
""" """
return self._tag == 'business' return self._tag == 'business'
def _process_custom_annotations(self, annotation_type, field_path, processor):
super(AccountType, self)._process_custom_annotations(annotation_type, field_path, processor)
def __repr__(self): def __repr__(self):
return 'AccountType(%r, %r)' % (self._tag, self._value) return 'AccountType(%r, %r)' % (self._tag, self._value)