Skip to content

Commit

Permalink
Added support for Business API.
Browse files Browse the repository at this point in the history
  • Loading branch information
braincore committed Jan 28, 2016
1 parent 9f83c61 commit 7b9869f
Show file tree
Hide file tree
Showing 17 changed files with 25,772 additions and 8,789 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
# built documents.
#
# The short X.Y version.
version = '4.0.1'
version = '5.0'
# The full version, including alpha/beta/rc tags.
release = '4.0.1'
release = '5.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
16 changes: 9 additions & 7 deletions docs/moduledoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ SDK Documentation
:members:
:undoc-members:

:mod:`dropbox.base` -- Base
============================================
.. autoclass:: dropbox.base.DropboxBase
:members:
:show-inheritance:
:undoc-members:

:mod:`dropbox.dropbox` -- Dropbox
============================================
.. automodule:: dropbox.dropbox
:members:
:show-inheritance:
:inherited-members:
:special-members: __init__
:undoc-members:

Expand All @@ -38,6 +32,14 @@ SDK Documentation
:special-members: __init__
:undoc-members:

:mod:`dropbox.team` -- Team
============================================
.. automodule:: dropbox.team
:members:
:show-inheritance:
:special-members: __init__
:undoc-members:

:mod:`dropbox.users` -- Users
============================================
.. automodule:: dropbox.users
Expand Down
2 changes: 1 addition & 1 deletion dropbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import

from .dropbox import __version__
from .dropbox import Dropbox
from .dropbox import Dropbox, DropboxTeam, create_session
from .oauth import DropboxOAuth2Flow, DropboxOAuth2FlowNoRedirect

# Compatibility with the deprecated v1 client.
Expand Down
84 changes: 84 additions & 0 deletions dropbox/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Auto-generated by BabelAPI, do not modify.
try:
from . import babel_validators as bv
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 babel_validators as bv

class AuthError(object):
"""
Errors occurred during authentication.
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_access_token: The access token is invalid.
:ivar invalid_select_user: The user specified in 'Dropbox-API-Select-User'
is no longer on the team.
:ivar other: An unspecified error.
"""

__slots__ = ['_tag', '_value']

_catch_all = 'other'
# Attribute is overwritten below the class definition
invalid_access_token = None
# Attribute is overwritten below the class definition
invalid_select_user = None
# Attribute is overwritten below the class definition
other = None

def __init__(self, tag, value=None):
assert tag in self._tagmap, 'Invalid tag %r.' % tag
validator = self._tagmap[tag]
if isinstance(validator, bv.Void):
assert value is None, 'Void type union member must have None value.'
elif isinstance(validator, (bv.Struct, bv.Union)):
validator.validate_type_only(value)
else:
validator.validate(value)
self._tag = tag
self._value = value

def is_invalid_access_token(self):
"""
Check if the union tag is ``invalid_access_token``.
:rtype: bool
"""
return self._tag == 'invalid_access_token'

def is_invalid_select_user(self):
"""
Check if the union tag is ``invalid_select_user``.
:rtype: bool
"""
return self._tag == 'invalid_select_user'

def is_other(self):
"""
Check if the union tag is ``other``.
:rtype: bool
"""
return self._tag == 'other'

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

AuthError._invalid_access_token_validator = bv.Void()
AuthError._invalid_select_user_validator = bv.Void()
AuthError._other_validator = bv.Void()
AuthError._tagmap = {
'invalid_access_token': AuthError._invalid_access_token_validator,
'invalid_select_user': AuthError._invalid_select_user_validator,
'other': AuthError._other_validator,
}

AuthError.invalid_access_token = AuthError('invalid_access_token')
AuthError.invalid_select_user = AuthError('invalid_select_user')
AuthError.other = AuthError('other')

2 changes: 1 addition & 1 deletion dropbox/babel_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __init__(self, min_length=None, max_length=None, pattern=None):

if pattern:
try:
self.pattern_re = re.compile(r"\A" + pattern + r"\Z")
self.pattern_re = re.compile(r"\A(?:" + pattern + r")\Z")
except re.error as e:
raise AssertionError('Regex {!r} failed: {}'.format(
pattern, e.args[0]))
Expand Down
Loading

0 comments on commit 7b9869f

Please sign in to comment.