diff --git a/docs/conf.py b/docs/conf.py index f14a9d1d..969f6949 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,9 +59,9 @@ # built documents. # # The short X.Y version. -version = '6.0' +version = '6.1' # The full version, including alpha/beta/rc tags. -release = '6.0' +release = '6.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/dropbox/async.py b/dropbox/async.py index 54c06477..7a64d923 100644 --- a/dropbox/async.py +++ b/dropbox/async.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. try: from . import babel_validators as bv @@ -313,7 +314,8 @@ def is_other(self): def __repr__(self): return 'PollError(%r, %r)' % (self._tag, self._value) -LaunchResultBase._async_job_id_validator = bv.String(min_length=1) +AsyncJobId_validator = bv.String(min_length=1) +LaunchResultBase._async_job_id_validator = AsyncJobId_validator LaunchResultBase._tagmap = { 'async_job_id': LaunchResultBase._async_job_id_validator, } @@ -326,7 +328,7 @@ def __repr__(self): LaunchEmptyResult.complete = LaunchEmptyResult('complete') -PollArg._async_job_id_validator = bv.String(min_length=1) +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)] diff --git a/dropbox/auth.py b/dropbox/auth.py index 50e3ff84..bfe86c8c 100644 --- a/dropbox/auth.py +++ b/dropbox/auth.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. try: from . import babel_validators as bv diff --git a/dropbox/babel_serializers.py b/dropbox/babel_serializers.py index 75e2b40c..fb9896c4 100644 --- a/dropbox/babel_serializers.py +++ b/dropbox/babel_serializers.py @@ -14,6 +14,7 @@ import base64 import collections import datetime +import functools import json import six @@ -24,15 +25,19 @@ # This makes testing this file directly (outside of a package) easier. import babel_validators as bv + # -------------------------------------------------------------- # JSON Encoder -def json_encode(data_type, obj, old_style=False): +def json_encode(data_type, obj, alias_validators=None, old_style=False): """Encodes an object into JSON based on its type. Args: data_type (Validator): Validator for obj. obj (object): Object to be serialized. + alias_validators (Optional[Mapping[bv.Validator, Callable[[], None]]]): + Custom validation functions. These must raise bv.ValidationError on + failure. Returns: str: JSON-encoded object. @@ -75,9 +80,14 @@ def json_encode(data_type, obj, old_style=False): > JsonEncoder.encode(um) "{'update': {'path': 'a/b/c', 'rev': '1234'}}" """ - return json.dumps(json_compat_obj_encode(data_type, obj, old_style)) + return json.dumps( + json_compat_obj_encode( + data_type, obj, alias_validators, old_style)) + -def json_compat_obj_encode(data_type, obj, old_style=False): +def json_compat_obj_encode( + data_type, obj, alias_validators=None, old_style=False, + for_msgpack=False): """Encodes an object into a JSON-compatible dict based on its type. Args: @@ -95,52 +105,73 @@ def json_compat_obj_encode(data_type, obj, old_style=False): data_type.validate_type_only(obj) else: data_type.validate(obj) - return _json_compat_obj_encode_helper(data_type, obj, old_style) + return _json_compat_obj_encode_helper( + data_type, obj, alias_validators, old_style, for_msgpack) + -def _json_compat_obj_encode_helper(data_type, obj, old_style): +def _json_compat_obj_encode_helper( + data_type, obj, alias_validators, old_style, for_msgpack): """ See json_encode() for argument descriptions. """ if isinstance(data_type, bv.List): - return _encode_list(data_type, obj, old_style=old_style) + return _encode_list( + data_type, obj, alias_validators, old_style=old_style, + for_msgpack=for_msgpack) elif isinstance(data_type, bv.Nullable): - return _encode_nullable(data_type, obj, old_style=old_style) + return _encode_nullable( + data_type, obj, alias_validators, old_style=old_style, + for_msgpack=for_msgpack) elif isinstance(data_type, bv.Primitive): - return _make_json_friendly(data_type, obj) + return _make_json_friendly( + data_type, obj, alias_validators, for_msgpack=for_msgpack) elif isinstance(data_type, bv.StructTree): - return _encode_struct_tree(data_type, obj, old_style=old_style) + return _encode_struct_tree( + data_type, obj, alias_validators, old_style=old_style, + for_msgpack=for_msgpack) elif isinstance(data_type, bv.Struct): - return _encode_struct(data_type, obj, old_style=old_style) + return _encode_struct( + data_type, obj, alias_validators, old_style=old_style, + for_msgpack=for_msgpack) elif isinstance(data_type, bv.Union): if old_style: - return _encode_union_old(data_type, obj) + return _encode_union_old( + data_type, obj, alias_validators, for_msgpack=for_msgpack) else: - return _encode_union(data_type, obj) + return _encode_union( + data_type, obj, alias_validators, for_msgpack=for_msgpack) else: raise AssertionError('Unsupported data type %r' % type(data_type).__name__) -def _encode_list(data_type, obj, old_style): + +def _encode_list(data_type, obj, alias_validators, old_style, for_msgpack): """ The data_type argument must be a List. See json_encode() for argument descriptions. """ # Because Lists are mutable, we always validate them during serialization. obj = data_type.validate(obj) - return [_json_compat_obj_encode_helper(data_type.item_validator, item, old_style) - for item in obj] + return [ + _json_compat_obj_encode_helper( + data_type.item_validator, item, alias_validators, old_style, for_msgpack) + for item in obj + ] + -def _encode_nullable(data_type, obj, old_style): +def _encode_nullable(data_type, obj, alias_validators, old_style, for_msgpack): """ The data_type argument must be a Nullable. See json_encode() for argument descriptions. """ if obj is not None: - return _json_compat_obj_encode_helper(data_type.validator, obj, old_style) + return _json_compat_obj_encode_helper( + data_type.validator, obj, alias_validators, old_style, for_msgpack) else: return None -def _encode_struct(data_type, obj, old_style): + +def _encode_struct(data_type, obj, alias_validators, old_style, for_msgpack): """ The data_type argument must be a Struct or StructTree. See json_encode() for argument descriptions. @@ -159,13 +190,15 @@ def _encode_struct(data_type, obj, old_style): # fields as null, even if there is a default. try: d[field_name] = _json_compat_obj_encode_helper( - field_data_type, val, old_style) + field_data_type, val, alias_validators, old_style, + for_msgpack) except bv.ValidationError as e: e.add_parent(field_name) raise return d -def _encode_union(data_type, obj): + +def _encode_union(data_type, obj, alias_validators, for_msgpack): """ The data_type argument must be a Union. See json_encode() for argument descriptions. @@ -180,7 +213,8 @@ def _encode_union(data_type, obj): else: try: encoded_val = _json_compat_obj_encode_helper( - field_data_type, obj._value, False) + field_data_type, obj._value, alias_validators, False, + for_msgpack) except bv.ValidationError as e: e.add_parent(obj._tag) raise @@ -200,7 +234,8 @@ def _encode_union(data_type, obj): ('.tag', obj._tag), (obj._tag, encoded_val)]) -def _encode_union_old(data_type, obj): + +def _encode_union_old(data_type, obj, alias_validators, for_msgpack): """ The data_type argument must be a Union. See json_encode() for argument descriptions. @@ -218,14 +253,17 @@ def _encode_union_old(data_type, obj): else: try: encoded_val = _json_compat_obj_encode_helper( - field_data_type, obj._value, old_style=True) + field_data_type, obj._value, alias_validators, True, + for_msgpack) except bv.ValidationError as e: e.add_parent(obj._tag) raise else: return {obj._tag: encoded_val} -def _encode_struct_tree(data_type, obj, old_style): + +def _encode_struct_tree( + data_type, obj, alias_validators, old_style, for_msgpack): """ Args: data_type (StructTree) @@ -244,23 +282,34 @@ def _encode_struct_tree(data_type, obj, old_style): 'Cannot serialize type %r because it enumerates subtypes.' % subtype.definition) if old_style: - return {tags[0]: _encode_struct(subtype, obj, old_style)} + return { + tags[0]: + _encode_struct( + subtype, obj, alias_validators, old_style, for_msgpack) + } d = collections.OrderedDict() d['.tag'] = tags[0] - d.update(_encode_struct(subtype, obj, old_style)) + d.update( + _encode_struct(subtype, obj, alias_validators, old_style, for_msgpack)) return d -def _make_json_friendly(data_type, val): + +def _make_json_friendly(data_type, val, alias_validators, for_msgpack): """ Convert a primitive type to a Python type that can be serialized by the json package. """ + if alias_validators is not None and data_type in alias_validators: + alias_validators[data_type](val) if isinstance(data_type, bv.Void): return None elif isinstance(data_type, bv.Timestamp): return val.strftime(data_type.format) - elif isinstance(data_type, bv.Binary): - return base64.b64encode(val).decode('ascii') + elif isinstance(data_type, bv.Bytes): + if for_msgpack: + return val + else: + return base64.b64encode(val).decode('ascii') elif isinstance(data_type, bv.Integer) and isinstance(val, bool): # A bool is a subclass of an int so it passes Integer validation. But, # we want the bool to be encoded as an Integer (1/0) rather than T/F. @@ -268,15 +317,21 @@ def _make_json_friendly(data_type, val): else: return val + # -------------------------------------------------------------- # JSON Decoder -def json_decode(data_type, serialized_obj, strict=True, old_style=False): +def json_decode( + data_type, serialized_obj, alias_validators=None, strict=True, + old_style=False): """Performs the reverse operation of json_encode. Args: data_type (Validator): Validator for serialized_obj. serialized_obj (str): The JSON string to deserialize. + alias_validators (Optional[Mapping[bv.Validator, Callable[[], None]]]): + Custom validation functions. These must raise bv.ValidationError on + failure. strict (bool): If strict, then unknown struct fields will raise an error, and unknown union variants will raise an error even if a catch all field is specified. strict should only be used by a @@ -286,8 +341,8 @@ def json_decode(data_type, serialized_obj, strict=True, old_style=False): Returns: The returned object depends on the input data_type. - - Binary -> bytes - Boolean -> bool + - Bytes -> bytes - Float -> float - Integer -> long - List -> list @@ -302,9 +357,13 @@ def json_decode(data_type, serialized_obj, strict=True, old_style=False): except ValueError: raise bv.ValidationError('could not decode input as JSON') else: - return json_compat_obj_decode(data_type, deserialized_obj, strict, old_style) + return json_compat_obj_decode( + data_type, deserialized_obj, alias_validators, strict, old_style) + -def json_compat_obj_decode(data_type, obj, strict=True, old_style=False): +def json_compat_obj_decode( + data_type, obj, alias_validators=None, strict=True, old_style=False, + for_msgpack=False): """ Decodes a JSON-compatible object based on its data type into a representative Python object. @@ -320,38 +379,55 @@ def json_compat_obj_decode(data_type, obj, strict=True, old_style=False): See json_decode(). """ if isinstance(data_type, bv.Primitive): - return _make_babel_friendly(data_type, obj, strict, True) + return _make_babel_friendly( + data_type, obj, alias_validators, strict, True, for_msgpack) else: - return _json_compat_obj_decode_helper(data_type, obj, strict, old_style) + return _json_compat_obj_decode_helper( + data_type, obj, alias_validators, strict, old_style, for_msgpack) -def _json_compat_obj_decode_helper(data_type, obj, strict, old_style): + +def _json_compat_obj_decode_helper( + data_type, obj, alias_validators, strict, old_style, for_msgpack): """ See json_compat_obj_decode() for argument descriptions. """ if isinstance(data_type, bv.StructTree): - return _decode_struct_tree(data_type, obj, strict) + return _decode_struct_tree( + data_type, obj, alias_validators, strict, for_msgpack) elif isinstance(data_type, bv.Struct): - return _decode_struct(data_type, obj, strict, old_style) + return _decode_struct( + data_type, obj, alias_validators, strict, old_style, for_msgpack) elif isinstance(data_type, bv.Union): if old_style: - return _decode_union_old(data_type, obj, strict) + return _decode_union_old( + data_type, obj, alias_validators, strict, for_msgpack) else: - return _decode_union(data_type, obj, strict) + return _decode_union( + data_type, obj, alias_validators, strict, for_msgpack) elif isinstance(data_type, bv.List): - return _decode_list(data_type, obj, strict, old_style) + return _decode_list( + data_type, obj, alias_validators, strict, old_style, for_msgpack) elif isinstance(data_type, bv.Nullable): - return _decode_nullable(data_type, obj, strict, old_style) + return _decode_nullable( + data_type, obj, alias_validators, strict, old_style, for_msgpack) elif isinstance(data_type, bv.Primitive): - return _make_babel_friendly(data_type, obj, strict, False) + # Set validate to false because validation will be done by the + # containing struct or union when the field is assigned. + return _make_babel_friendly( + data_type, obj, alias_validators, strict, False, for_msgpack) else: raise AssertionError('Cannot handle type %r.' % data_type) -def _decode_struct(data_type, obj, strict, old_style): + +def _decode_struct( + data_type, obj, alias_validators, strict, old_style, for_msgpack): """ The data_type argument must be a Struct. See json_compat_obj_decode() for argument descriptions. """ - if not isinstance(obj, dict): + if obj is None and data_type.has_default(): + return data_type.get_default() + elif not isinstance(obj, dict): raise bv.ValidationError('expected object, got %s' % bv.generic_type_name(obj)) if strict: @@ -360,13 +436,16 @@ def _decode_struct(data_type, obj, strict, old_style): not key.startswith('.tag')): raise bv.ValidationError("unknown field '%s'" % key) ins = data_type.definition() - _decode_struct_fields(ins, data_type.definition._all_fields_, obj, strict, - old_style) + _decode_struct_fields( + ins, data_type.definition._all_fields_, obj, alias_validators, strict, + old_style, for_msgpack) # Check that all required fields have been set. data_type.validate_fields_only(ins) return ins -def _decode_struct_fields(ins, fields, obj, strict, old_style): + +def _decode_struct_fields( + ins, fields, obj, alias_validators, strict, old_style, for_msgpack): """ Args: ins: An instance of the class representing the data type being decoded. @@ -382,13 +461,17 @@ def _decode_struct_fields(ins, fields, obj, strict, old_style): if name in obj: try: v = _json_compat_obj_decode_helper( - field_data_type, obj[name], strict, old_style) + field_data_type, obj[name], alias_validators, strict, + old_style, for_msgpack) setattr(ins, name, v) except bv.ValidationError as e: e.add_parent(name) raise + elif field_data_type.has_default(): + setattr(ins, name, field_data_type.get_default()) + -def _decode_union(data_type, obj, strict): +def _decode_union(data_type, obj, alias_validators, strict, for_msgpack): """ The data_type argument must be a Union. See json_compat_obj_decode() for argument descriptions. @@ -403,19 +486,24 @@ def _decode_union(data_type, obj, strict): if not isinstance(val_data_type, (bv.Void, bv.Nullable)): raise bv.ValidationError( "expected object for '%s', got symbol" % tag) + if tag == data_type.definition._catch_all: + raise bv.ValidationError( + "unexpected use of the catch-all tag '%s'" % tag) else: if not strict and data_type.definition._catch_all: tag = data_type.definition._catch_all else: raise bv.ValidationError("unknown tag '%s'" % tag) elif isinstance(obj, dict): - tag, val = _decode_union_dict(data_type, obj, strict) + tag, val = _decode_union_dict( + data_type, obj, alias_validators, strict, for_msgpack) else: raise bv.ValidationError("expected string or object, got %s" % bv.generic_type_name(obj)) return data_type.definition(tag, val) -def _decode_union_dict(data_type, obj, strict): + +def _decode_union_dict(data_type, obj, alias_validators, strict, for_msgpack): if '.tag' not in obj: raise bv.ValidationError("missing '.tag' key") tag = obj['.tag'] @@ -428,6 +516,9 @@ def _decode_union_dict(data_type, obj, strict): return data_type.definition._catch_all, None else: raise bv.ValidationError("unknown tag '%s'" % tag) + if tag == data_type.definition._catch_all: + raise bv.ValidationError( + "unexpected use of the catch-all tag '%s'" % tag) val_data_type = data_type.definition._tagmap[tag] if isinstance(val_data_type, bv.Nullable): @@ -451,7 +542,7 @@ def _decode_union_dict(data_type, obj, strict): raw_val = obj[tag] try: val = _json_compat_obj_decode_helper( - val_data_type, raw_val, strict, False) + val_data_type, raw_val, alias_validators, strict, False, for_msgpack) except bv.ValidationError as e: e.add_parent(tag) raise @@ -472,7 +563,8 @@ def _decode_union_dict(data_type, obj, strict): raw_val = obj try: val = _json_compat_obj_decode_helper( - val_data_type, raw_val, strict, False) + val_data_type, raw_val, alias_validators, strict, False, + for_msgpack) except bv.ValidationError as e: e.add_parent(tag) raise @@ -480,7 +572,8 @@ def _decode_union_dict(data_type, obj, strict): assert False, type(val_data_type) return tag, val -def _decode_union_old(data_type, obj, strict): + +def _decode_union_old(data_type, obj, alias_validators, strict, for_msgpack): """ The data_type argument must be a Union. See json_compat_obj_decode() for argument descriptions. @@ -522,7 +615,8 @@ def _decode_union_old(data_type, obj, strict): else: try: val = _json_compat_obj_decode_helper( - val_data_type, raw_val, strict, old_style=True) + val_data_type, raw_val, alias_validators, strict, True, + for_msgpack) except bv.ValidationError as e: e.add_parent(tag) raise @@ -536,13 +630,16 @@ def _decode_union_old(data_type, obj, strict): bv.generic_type_name(obj)) return data_type.definition(tag, val) -def _decode_struct_tree(data_type, obj, strict): + +def _decode_struct_tree(data_type, obj, alias_validators, strict, for_msgpack): """ The data_type argument must be a StructTree. See json_compat_obj_decode() for argument descriptions. """ subtype = _determine_struct_tree_subtype(data_type, obj, strict) - return _decode_struct(subtype, obj, strict, False) + return _decode_struct( + subtype, obj, alias_validators, strict, False, for_msgpack) + def _determine_struct_tree_subtype(data_type, obj, strict): """ @@ -579,7 +676,9 @@ def _determine_struct_tree_subtype(data_type, obj, strict): "unknown subtype '%s' and '%s' is not a catch-all" % ('.'.join(full_tags_tuple), data_type.definition.__name__)) -def _decode_list(data_type, obj, strict, old_style): + +def _decode_list( + data_type, obj, alias_validators, strict, old_style, for_msgpack): """ The data_type argument must be a List. See json_compat_obj_decode() for argument descriptions. @@ -587,36 +686,52 @@ def _decode_list(data_type, obj, strict, old_style): if not isinstance(obj, list): raise bv.ValidationError( 'expected list, got %s' % bv.generic_type_name(obj)) - return [_json_compat_obj_decode_helper(data_type.item_validator, - item, strict, old_style) - for item in obj] + return [ + _json_compat_obj_decode_helper( + data_type.item_validator, item, alias_validators, strict, + old_style, for_msgpack) + for item in obj] -def _decode_nullable(data_type, obj, strict, old_style): + +def _decode_nullable( + data_type, obj, alias_validators, strict, old_style, for_msgpack): """ The data_type argument must be a Nullable. See json_compat_obj_decode() for argument descriptions. """ if obj is not None: - return _json_compat_obj_decode_helper(data_type.validator, obj, strict, - old_style) + return _json_compat_obj_decode_helper( + data_type.validator, obj, alias_validators, strict, old_style, + for_msgpack) else: return None -def _make_babel_friendly(data_type, val, strict, validate): + +def _make_babel_friendly( + data_type, val, alias_validators, strict, validate, for_msgpack): """ Convert a Python object to a type that will pass validation by its validator. + + Validation by ``alias_validators`` is performed even if ``validate`` is + false. """ if isinstance(data_type, bv.Timestamp): try: - return datetime.datetime.strptime(val, data_type.format) + ret = datetime.datetime.strptime(val, data_type.format) except ValueError as e: raise bv.ValidationError(e.args[0]) - elif isinstance(data_type, bv.Binary): - try: - return base64.b64decode(val) - except TypeError: - raise bv.ValidationError('invalid base64-encoded binary') + elif isinstance(data_type, bv.Bytes): + if for_msgpack: + if isinstance(val, six.text_type): + ret = val.encode('utf-8') + else: + ret = val + else: + try: + ret = base64.b64decode(val) + except TypeError: + raise bv.ValidationError('invalid base64-encoded bytes') elif isinstance(data_type, bv.Void): if strict and val is not None: raise bv.ValidationError("expected null, got value") @@ -624,4 +739,33 @@ def _make_babel_friendly(data_type, val, strict, validate): else: if validate: data_type.validate(val) - return val + ret = val + if alias_validators is not None and data_type in alias_validators: + alias_validators[data_type](ret) + return ret + +try: + import msgpack +except ImportError: + pass +else: + msgpack_compat_obj_encode = functools.partial(json_compat_obj_encode, + for_msgpack=True) + + def msgpack_encode(data_type, obj): + return msgpack.dumps( + msgpack_compat_obj_encode(data_type, obj), encoding='utf-8') + + msgpack_compat_obj_decode = functools.partial(json_compat_obj_decode, + for_msgpack=True) + + def msgpack_decode( + data_type, serialized_obj, alias_validators=None, strict=True): + # We decode everything as utf-8 because we want all object keys to be + # unicode. Otherwise, we need to do a lot more refactoring to make + # json/msgpack share the same code. We expect byte arrays to fail + # decoding, but when they don't, we have to convert them to bytes. + deserialized_obj = msgpack.loads( + serialized_obj, encoding='utf-8', unicode_errors='ignore') + return msgpack_compat_obj_decode( + data_type, deserialized_obj, alias_validators, strict) diff --git a/dropbox/babel_validators.py b/dropbox/babel_validators.py index 41d106aa..d12fc226 100644 --- a/dropbox/babel_validators.py +++ b/dropbox/babel_validators.py @@ -24,6 +24,7 @@ else: _binary_types = (bytes, buffer) + class ValidationError(Exception): """Raised when a value doesn't pass validation by its validator.""" @@ -63,6 +64,7 @@ def __repr__(self): # Not a perfect repr, but includes the error location information. return 'ValidationError(%r)' % str(self) + def generic_type_name(v): """Return a descriptive type name that isn't Python specific. For example, an int value will return 'integer' rather than 'int'.""" @@ -80,6 +82,7 @@ def generic_type_name(v): else: return type(v).__name__ + class Validator(object): """All primitive and composite data types should be a subclass of this.""" __metaclass__ = ABCMeta @@ -99,10 +102,12 @@ def has_default(self): def get_default(self): raise AssertionError('No default available.') + class Primitive(Validator): """A basic type that is defined by Babel.""" pass + class Boolean(Primitive): def validate(self, val): @@ -110,6 +115,7 @@ def validate(self, val): raise ValidationError('%r is not a valid boolean' % val) return val + class Integer(Primitive): """ Do not use this class directly. Extend it and specify a 'minimum' and @@ -150,22 +156,27 @@ def validate(self, val): def __repr__(self): return '%s()' % self.__class__.__name__ + class Int32(Integer): minimum = -2**31 maximum = 2**31 - 1 + class UInt32(Integer): minimum = 0 maximum = 2**32 - 1 + class Int64(Integer): minimum = -2**63 maximum = 2**63 - 1 + class UInt64(Integer): minimum = 0 maximum = 2**64 - 1 + class Real(Primitive): """ Do not use this class directly. Extend it and optionally set a 'minimum' @@ -231,14 +242,17 @@ def validate(self, val): def __repr__(self): return '%s()' % self.__class__.__name__ + class Float32(Real): # Maximum and minimums from the IEEE 754-1985 standard minimum = -3.40282 * 10**38 maximum = 3.40282 * 10**38 + class Float64(Real): pass + class String(Primitive): """Represents a unicode string.""" @@ -296,7 +310,8 @@ def validate(self, val): % (val, self.pattern)) return val -class Binary(Primitive): + +class Bytes(Primitive): def __init__(self, min_length=None, max_length=None): if min_length is not None: @@ -315,7 +330,7 @@ def __init__(self, min_length=None, max_length=None): def validate(self, val): if not isinstance(val, _binary_types): - raise ValidationError("expected binary type, got %s" + raise ValidationError("expected bytes type, got %s" % generic_type_name(val)) elif self.max_length is not None and len(val) > self.max_length: raise ValidationError("'%s' must have at most %d bytes, got %d" @@ -325,6 +340,7 @@ def validate(self, val): % (val, self.min_length, len(val))) return val + class Timestamp(Primitive): """Note that while a format is specified, it isn't used in validation since a native Python datetime object is preferred. The format, however, @@ -446,6 +462,7 @@ def get_default(self): assert not self.definition._has_required_fields, 'No default available.' return self.definition() + class StructTree(Struct): """Validator for structs with enumerated subtypes. @@ -456,6 +473,7 @@ class StructTree(Struct): def __init__(self, definition): super(StructTree, self).__init__(definition) + class Union(Composite): def __init__(self, definition): @@ -498,6 +516,7 @@ def validate_type_only(self, val): raise ValidationError('expected type %s or subtype, got %s' % (self.definition.__name__, generic_type_name(val))) + class Void(Primitive): def validate(self, val): @@ -511,6 +530,7 @@ def has_default(self): def get_default(self): return None + class Nullable(Validator): def __init__(self, validator): diff --git a/dropbox/base.py b/dropbox/base.py index b77d3da1..c024cdd3 100644 --- a/dropbox/base.py +++ b/dropbox/base.py @@ -82,7 +82,10 @@ def files_delete(self, path): """ Delete the file or folder at a given path. If the path is a folder, all - its contents will be deleted too. + its contents will be deleted too. A successful response indicates that + the file or folder was deleted. The returned metadata will be the + corresponding :class:`FileMetadata` or :class:`FolderMetadata` for the + item at time of deletion, and not a :class:`DeletedMetadata` object. :param str path: Path in the user's Dropbox to delete. :rtype: :class:`dropbox.files.Metadata` @@ -483,7 +486,8 @@ def files_list_folder_longpoll(self, `_. :param str cursor: A cursor as returned by :meth:`list_folder` or - :meth:`list_folder_continue` + :meth:`list_folder_continue`. Cursors retrieved by setting + ``ListFolderArg.include_media_info`` to ``True`` are not supported. :param long timeout: A timeout in seconds. The request will block for at most this length of time, plus up to 90 seconds of random jitter added to avoid the thundering herd problem. Care should be taken @@ -997,8 +1001,7 @@ def sharing_get_folder_metadata(self, and is subject to minor but possibly backwards-incompatible changes. :param str shared_folder_id: The ID for the shared folder. - :param Nullable actions: Folder actions to query. This field is - optional. + :param Nullable actions: Folder actions to query. :rtype: :class:`dropbox.sharing.SharedFolderMetadata` :raises: :class:`dropbox.exceptions.ApiError` @@ -1173,10 +1176,6 @@ def sharing_list_folder_members(self, and is subject to minor but possibly backwards-incompatible changes. :param str shared_folder_id: The ID for the shared folder. - :param Nullable actions: Member actions to query. This field is - optional. - :param long limit: The maximum number of results that include members, - groups and invitees to return per request. :rtype: :class:`dropbox.sharing.SharedFolderMembers` :raises: :class:`dropbox.exceptions.ApiError` @@ -1237,8 +1236,7 @@ def sharing_list_folders(self, backwards-incompatible changes. :param long limit: The maximum number of results to return per request. - :param Nullable actions: Folder actions to query. This field is - optional. + :param Nullable actions: Folder actions to query. :rtype: :class:`dropbox.sharing.ListFoldersResult` """ arg = sharing.ListFoldersArgs(limit, @@ -1259,12 +1257,14 @@ def sharing_list_folders_continue(self, cursor): """ Once a cursor has been retrieved from :meth:`list_folders`, use this to - paginate through all shared folders. Apps must have full Dropbox access - to use this endpoint. Warning: This endpoint is in beta and is subject - to minor but possibly backwards-incompatible changes. + paginate through all shared folders. The cursor must come from a + previous call to :meth:`list_folders` or :meth:`list_folders_continue`. + Apps must have full Dropbox access to use this endpoint. Warning: This + endpoint is in beta and is subject to minor but possibly + backwards-incompatible changes. - :param str cursor: The cursor returned by your last call to - :meth:`list_folders` or :meth:`list_folders_continue`. + :param str cursor: The cursor returned by the previous API call + specified in the endpoint description. :rtype: :class:`dropbox.sharing.ListFoldersResult` :raises: :class:`dropbox.exceptions.ApiError` @@ -1292,8 +1292,7 @@ def sharing_list_mountable_folders(self, unmount. Apps must have full Dropbox access to use this endpoint. :param long limit: The maximum number of results to return per request. - :param Nullable actions: Folder actions to query. This field is - optional. + :param Nullable actions: Folder actions to query. :rtype: :class:`dropbox.sharing.ListFoldersResult` """ arg = sharing.ListFoldersArgs(limit, @@ -1314,11 +1313,13 @@ def sharing_list_mountable_folders_continue(self, cursor): """ Once a cursor has been retrieved from :meth:`list_mountable_folders`, - use this to paginate through all mountable shared folders. Apps must - have full Dropbox access to use this endpoint. + use this to paginate through all mountable shared folders. The cursor + must come from a previous call to :meth:`list_mountable_folders` or + :meth:`list_mountable_folders_continue`. Apps must have full Dropbox + access to use this endpoint. - :param str cursor: The cursor returned by your last call to - :meth:`list_folders` or :meth:`list_folders_continue`. + :param str cursor: The cursor returned by the previous API call + specified in the endpoint description. :rtype: :class:`dropbox.sharing.ListFoldersResult` :raises: :class:`dropbox.exceptions.ApiError` @@ -1553,13 +1554,15 @@ def sharing_share_folder(self, :param str path: The path to the folder to share. If it does not exist, then a new one is created. - :param member_policy: Who can be a member of this shared folder. + :param member_policy: Who can be a member of this shared folder. Only + applicable if the current user is on a team. :type member_policy: :class:`dropbox.sharing.MemberPolicy` :param acl_update_policy: Who can add and remove members of this shared folder. :type acl_update_policy: :class:`dropbox.sharing.AclUpdatePolicy` :param shared_link_policy: The policy to apply to shared links created - for content inside this shared folder. + for content inside this shared folder. The current user must be on + a team to set this policy to ``SharedLinkPolicy.members``. :type shared_link_policy: :class:`dropbox.sharing.SharedLinkPolicy` :param bool force_async: Whether to force the share to happen asynchronously. @@ -1591,9 +1594,10 @@ def sharing_transfer_folder(self, to_dropbox_id): """ Transfer ownership of a shared folder to a member of the shared folder. - Apps must have full Dropbox access to use this endpoint. Warning: This - endpoint is in beta and is subject to minor but possibly - backwards-incompatible changes. + User must have ``AccessLevel.owner`` access to the shared folder to + perform a transfer. Apps must have full Dropbox access to use this + endpoint. Warning: This endpoint is in beta and is subject to minor but + possibly backwards-incompatible changes. :param str shared_folder_id: The ID for the shared folder. :param str to_dropbox_id: A account or team member ID to transfer @@ -1648,7 +1652,7 @@ def sharing_unmount_folder(self, def sharing_unshare_folder(self, shared_folder_id, - leave_a_copy): + leave_a_copy=False): """ Allows a shared folder owner to unshare the folder. You'll need to call :meth:`check_job_status` to determine if the action has completed @@ -1725,17 +1729,20 @@ def sharing_update_folder_policy(self, acl_update_policy=None, shared_link_policy=None): """ - Update the sharing policies for a shared folder. Apps must have full - Dropbox access to use this endpoint. Warning: This endpoint is in beta - and is subject to minor but possibly backwards-incompatible changes. + Update the sharing policies for a shared folder. User must have + ``AccessLevel.owner`` access to the shared folder to update its + policies. Apps must have full Dropbox access to use this endpoint. + Warning: This endpoint is in beta and is subject to minor but possibly + backwards-incompatible changes. :param str shared_folder_id: The ID for the shared folder. :param Nullable member_policy: Who can be a member of this shared - folder. Only set this if the current user is on a team. + folder. Only applicable if the current user is on a team. :param Nullable acl_update_policy: Who can add and remove members of this shared folder. :param Nullable shared_link_policy: The policy to apply to shared links - created for content inside this shared folder. + created for content inside this shared folder. The current user must + be on a team to set this policy to ``SharedLinkPolicy.members``. :rtype: :class:`dropbox.sharing.SharedFolderMetadata` :raises: :class:`dropbox.exceptions.ApiError` diff --git a/dropbox/common.py b/dropbox/common.py new file mode 100644 index 00000000..b2d689e2 --- /dev/null +++ b/dropbox/common.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# 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 + +Date_validator = bv.Timestamp(u'%Y-%m-%d') +DisplayName_validator = bv.String(min_length=1, pattern=u'[^/:?*<>"|]*') +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}$") +NamePart_validator = bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*') +SharedFolderId_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') diff --git a/dropbox/dropbox.py b/dropbox/dropbox.py index 2a7eca88..ea77e668 100644 --- a/dropbox/dropbox.py +++ b/dropbox/dropbox.py @@ -5,7 +5,7 @@ ] # TODO(kelkabany): We need to auto populate this as done in the v1 SDK. -__version__ = '6.0' +__version__ = '6.1' import contextlib import json diff --git a/dropbox/files.py b/dropbox/files.py index ce7e7dca..602bcedd 100644 --- a/dropbox/files.py +++ b/dropbox/files.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. """ This namespace contains endpoints and data types for basic file operations. @@ -10,6 +11,15 @@ # This makes testing this file directly (outside of a package) easier. import babel_validators as bv +try: + from . import ( + common, + users, + ) +except (SystemError, ValueError): + import common + import users + class CommitInfo(object): """ :ivar path: Path in the user's Dropbox to save the file. @@ -2112,7 +2122,9 @@ def __repr__(self): class ListFolderLongpollArg(object): """ - :ivar cursor: A cursor as returned by list_folder or list_folder/continue + :ivar cursor: A cursor as returned by list_folder or list_folder/continue. + Cursors retrieved by setting ``ListFolderArg.include_media_info`` to + ``True`` are not supported. :ivar timeout: A timeout in seconds. The request will block for at most this length of time, plus up to 90 seconds of random jitter added to avoid the thundering herd problem. Care should be taken when using this @@ -2144,7 +2156,9 @@ def __init__(self, @property def cursor(self): """ - A cursor as returned by list_folder or list_folder/continue + A cursor as returned by list_folder or list_folder/continue. Cursors + retrieved by setting ``ListFolderArg.include_media_info`` to ``True`` + are not supported. :rtype: str """ @@ -2718,7 +2732,7 @@ def malformed_path(cls, val): Create an instance of this class set to the ``malformed_path`` tag with value ``val``. - :param str val: + :param Optional[str] val: :rtype: LookupError """ return cls('malformed_path', val) @@ -2775,7 +2789,7 @@ def get_malformed_path(self): """ Only call this if :meth:`is_malformed_path` is true. - :rtype: str + :rtype: Optional[str] """ if not self.is_malformed_path(): raise AttributeError("tag 'malformed_path' not set") @@ -5320,7 +5334,7 @@ def malformed_path(cls, val): Create an instance of this class set to the ``malformed_path`` tag with value ``val``. - :param str val: + :param Optional[str] val: :rtype: WriteError """ return cls('malformed_path', val) @@ -5388,7 +5402,7 @@ def get_malformed_path(self): """ Only call this if :meth:`is_malformed_path` is true. - :rtype: str + :rtype: Optional[str] """ if not self.is_malformed_path(): raise AttributeError("tag 'malformed_path' not set") @@ -5510,10 +5524,18 @@ def get_update(self): def __repr__(self): return 'WriteMode(%r, %r)' % (self._tag, self._value) -CommitInfo._path_validator = bv.String(pattern=u'/.*') +Id_validator = bv.String(min_length=1) +ListFolderCursor_validator = bv.String(min_length=1) +MalformedPathError_validator = bv.Nullable(bv.String()) +Path_validator = bv.String(pattern=u'/.*') +PathOrId_validator = bv.String(pattern=u'(/|id:).*') +PathR_validator = bv.String(pattern=u'(/.*)?') +ReadPath_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') +Rev_validator = bv.String(min_length=9, pattern=u'[0-9a-f]+') +CommitInfo._path_validator = Path_validator CommitInfo._mode_validator = bv.Union(WriteMode) CommitInfo._autorename_validator = bv.Boolean() -CommitInfo._client_modified_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +CommitInfo._client_modified_validator = bv.Nullable(common.DropboxTimestamp_validator) CommitInfo._mute_validator = bv.Boolean() CommitInfo._all_field_names_ = set([ 'path', @@ -5530,7 +5552,7 @@ def __repr__(self): ('mute', CommitInfo._mute_validator), ] -CreateFolderArg._path_validator = bv.String(pattern=u'/.*') +CreateFolderArg._path_validator = Path_validator CreateFolderArg._all_field_names_ = set(['path']) CreateFolderArg._all_fields_ = [('path', CreateFolderArg._path_validator)] @@ -5539,7 +5561,7 @@ def __repr__(self): 'path': CreateFolderError._path_validator, } -DeleteArg._path_validator = bv.String(pattern=u'/.*') +DeleteArg._path_validator = Path_validator DeleteArg._all_field_names_ = set(['path']) DeleteArg._all_fields_ = [('path', DeleteArg._path_validator)] @@ -5557,7 +5579,7 @@ def __repr__(self): Metadata._name_validator = bv.String() Metadata._path_lower_validator = bv.String() Metadata._path_display_validator = bv.String() -Metadata._parent_shared_folder_id_validator = bv.Nullable(bv.String(pattern=u'[-_0-9a-zA-Z:]+')) +Metadata._parent_shared_folder_id_validator = bv.Nullable(common.SharedFolderId_validator) Metadata._field_names_ = set([ 'name', 'path_lower', @@ -5601,8 +5623,8 @@ def __repr__(self): ('width', Dimensions._width_validator), ] -DownloadArg._path_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') -DownloadArg._rev_validator = bv.Nullable(bv.String(min_length=9, pattern=u'[0-9a-f]+')) +DownloadArg._path_validator = ReadPath_validator +DownloadArg._rev_validator = bv.Nullable(Rev_validator) DownloadArg._all_field_names_ = set([ 'path', 'rev', @@ -5621,10 +5643,10 @@ def __repr__(self): DownloadError.other = DownloadError('other') -FileMetadata._id_validator = bv.String(min_length=1) -FileMetadata._client_modified_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ') -FileMetadata._server_modified_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ') -FileMetadata._rev_validator = bv.String(min_length=9, pattern=u'[0-9a-f]+') +FileMetadata._id_validator = Id_validator +FileMetadata._client_modified_validator = common.DropboxTimestamp_validator +FileMetadata._server_modified_validator = common.DropboxTimestamp_validator +FileMetadata._rev_validator = Rev_validator FileMetadata._size_validator = bv.UInt64() FileMetadata._media_info_validator = bv.Nullable(bv.Union(MediaInfo)) FileMetadata._sharing_info_validator = bv.Nullable(bv.Struct(FileSharingInfo)) @@ -5653,8 +5675,8 @@ def __repr__(self): SharingInfo._all_field_names_ = set(['read_only']) SharingInfo._all_fields_ = [('read_only', SharingInfo._read_only_validator)] -FileSharingInfo._parent_shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') -FileSharingInfo._modified_by_validator = bv.Nullable(bv.String(min_length=40, max_length=40)) +FileSharingInfo._parent_shared_folder_id_validator = common.SharedFolderId_validator +FileSharingInfo._modified_by_validator = bv.Nullable(users.AccountId_validator) FileSharingInfo._all_field_names_ = SharingInfo._all_field_names_.union(set([ 'parent_shared_folder_id', 'modified_by', @@ -5664,8 +5686,8 @@ def __repr__(self): ('modified_by', FileSharingInfo._modified_by_validator), ] -FolderMetadata._id_validator = bv.String(min_length=1) -FolderMetadata._shared_folder_id_validator = bv.Nullable(bv.String(pattern=u'[-_0-9a-zA-Z:]+')) +FolderMetadata._id_validator = Id_validator +FolderMetadata._shared_folder_id_validator = bv.Nullable(common.SharedFolderId_validator) FolderMetadata._sharing_info_validator = bv.Nullable(bv.Struct(FolderSharingInfo)) FolderMetadata._field_names_ = set([ 'id', @@ -5680,8 +5702,8 @@ def __repr__(self): ] FolderMetadata._all_fields_ = Metadata._all_fields_ + FolderMetadata._fields_ -FolderSharingInfo._parent_shared_folder_id_validator = bv.Nullable(bv.String(pattern=u'[-_0-9a-zA-Z:]+')) -FolderSharingInfo._shared_folder_id_validator = bv.Nullable(bv.String(pattern=u'[-_0-9a-zA-Z:]+')) +FolderSharingInfo._parent_shared_folder_id_validator = bv.Nullable(common.SharedFolderId_validator) +FolderSharingInfo._shared_folder_id_validator = bv.Nullable(common.SharedFolderId_validator) FolderSharingInfo._all_field_names_ = SharingInfo._all_field_names_.union(set([ 'parent_shared_folder_id', 'shared_folder_id', @@ -5691,7 +5713,7 @@ def __repr__(self): ('shared_folder_id', FolderSharingInfo._shared_folder_id_validator), ] -GetMetadataArg._path_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') +GetMetadataArg._path_validator = ReadPath_validator GetMetadataArg._include_media_info_validator = bv.Boolean() GetMetadataArg._all_field_names_ = set([ 'path', @@ -5718,7 +5740,7 @@ def __repr__(self): ('longitude', GpsCoordinates._longitude_validator), ] -ListFolderArg._path_validator = bv.String(pattern=u'(/.*)?') +ListFolderArg._path_validator = PathR_validator ListFolderArg._recursive_validator = bv.Boolean() ListFolderArg._include_media_info_validator = bv.Boolean() ListFolderArg._include_deleted_validator = bv.Boolean() @@ -5735,7 +5757,7 @@ def __repr__(self): ('include_deleted', ListFolderArg._include_deleted_validator), ] -ListFolderContinueArg._cursor_validator = bv.String(min_length=1) +ListFolderContinueArg._cursor_validator = ListFolderCursor_validator ListFolderContinueArg._all_field_names_ = set(['cursor']) ListFolderContinueArg._all_fields_ = [('cursor', ListFolderContinueArg._cursor_validator)] @@ -5760,11 +5782,11 @@ def __repr__(self): ListFolderError.other = ListFolderError('other') -ListFolderGetLatestCursorResult._cursor_validator = bv.String(min_length=1) +ListFolderGetLatestCursorResult._cursor_validator = ListFolderCursor_validator ListFolderGetLatestCursorResult._all_field_names_ = set(['cursor']) ListFolderGetLatestCursorResult._all_fields_ = [('cursor', ListFolderGetLatestCursorResult._cursor_validator)] -ListFolderLongpollArg._cursor_validator = bv.String(min_length=1) +ListFolderLongpollArg._cursor_validator = ListFolderCursor_validator ListFolderLongpollArg._timeout_validator = bv.UInt64(min_value=30, max_value=480) ListFolderLongpollArg._all_field_names_ = set([ 'cursor', @@ -5797,7 +5819,7 @@ def __repr__(self): ] ListFolderResult._entries_validator = bv.List(bv.StructTree(Metadata)) -ListFolderResult._cursor_validator = bv.String(min_length=1) +ListFolderResult._cursor_validator = ListFolderCursor_validator ListFolderResult._has_more_validator = bv.Boolean() ListFolderResult._all_field_names_ = set([ 'entries', @@ -5810,7 +5832,7 @@ def __repr__(self): ('has_more', ListFolderResult._has_more_validator), ] -ListRevisionsArg._path_validator = bv.String(pattern=u'/.*') +ListRevisionsArg._path_validator = Path_validator ListRevisionsArg._limit_validator = bv.UInt64(min_value=1, max_value=100) ListRevisionsArg._all_field_names_ = set([ 'path', @@ -5841,7 +5863,7 @@ def __repr__(self): ('entries', ListRevisionsResult._entries_validator), ] -LookupError._malformed_path_validator = bv.Nullable(bv.String()) +LookupError._malformed_path_validator = MalformedPathError_validator LookupError._not_found_validator = bv.Void() LookupError._not_file_validator = bv.Void() LookupError._not_folder_validator = bv.Void() @@ -5873,7 +5895,7 @@ def __repr__(self): MediaMetadata._dimensions_validator = bv.Nullable(bv.Struct(Dimensions)) MediaMetadata._location_validator = bv.Nullable(bv.Struct(GpsCoordinates)) -MediaMetadata._time_taken_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +MediaMetadata._time_taken_validator = bv.Nullable(common.DropboxTimestamp_validator) MediaMetadata._field_names_ = set([ 'dimensions', 'location', @@ -5902,8 +5924,8 @@ def __repr__(self): PhotoMetadata._fields_ = [] PhotoMetadata._all_fields_ = MediaMetadata._all_fields_ + PhotoMetadata._fields_ -PreviewArg._path_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') -PreviewArg._rev_validator = bv.Nullable(bv.String(min_length=9, pattern=u'[0-9a-f]+')) +PreviewArg._path_validator = ReadPath_validator +PreviewArg._rev_validator = bv.Nullable(Rev_validator) PreviewArg._all_field_names_ = set([ 'path', 'rev', @@ -5928,8 +5950,8 @@ def __repr__(self): PreviewError.unsupported_extension = PreviewError('unsupported_extension') PreviewError.unsupported_content = PreviewError('unsupported_content') -RelocationArg._from_path_validator = bv.String(pattern=u'/.*') -RelocationArg._to_path_validator = bv.String(pattern=u'/.*') +RelocationArg._from_path_validator = Path_validator +RelocationArg._to_path_validator = Path_validator RelocationArg._all_field_names_ = set([ 'from_path', 'to_path', @@ -5964,8 +5986,8 @@ def __repr__(self): RelocationError.too_many_files = RelocationError('too_many_files') RelocationError.other = RelocationError('other') -RestoreArg._path_validator = bv.String(pattern=u'/.*') -RestoreArg._rev_validator = bv.String(min_length=9, pattern=u'[0-9a-f]+') +RestoreArg._path_validator = Path_validator +RestoreArg._rev_validator = Rev_validator RestoreArg._all_field_names_ = set([ 'path', 'rev', @@ -5989,7 +6011,7 @@ def __repr__(self): RestoreError.invalid_revision = RestoreError('invalid_revision') RestoreError.other = RestoreError('other') -SearchArg._path_validator = bv.String(pattern=u'(/.*)?') +SearchArg._path_validator = PathR_validator SearchArg._query_validator = bv.String() SearchArg._start_validator = bv.UInt64() SearchArg._max_results_validator = bv.UInt64(min_value=1, max_value=1000) @@ -6069,7 +6091,7 @@ def __repr__(self): ('start', SearchResult._start_validator), ] -ThumbnailArg._path_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') +ThumbnailArg._path_validator = ReadPath_validator ThumbnailArg._format_validator = bv.Union(ThumbnailFormat) ThumbnailArg._size_validator = bv.Union(ThumbnailSize) ThumbnailArg._all_field_names_ = set([ @@ -6225,7 +6247,7 @@ def __repr__(self): WriteConflictError.file_ancestor = WriteConflictError('file_ancestor') WriteConflictError.other = WriteConflictError('other') -WriteError._malformed_path_validator = bv.Nullable(bv.String()) +WriteError._malformed_path_validator = MalformedPathError_validator WriteError._conflict_validator = bv.Union(WriteConflictError) WriteError._no_write_permission_validator = bv.Void() WriteError._insufficient_space_validator = bv.Void() @@ -6247,7 +6269,7 @@ def __repr__(self): WriteMode._add_validator = bv.Void() WriteMode._overwrite_validator = bv.Void() -WriteMode._update_validator = bv.String(min_length=9, pattern=u'[0-9a-f]+') +WriteMode._update_validator = Rev_validator WriteMode._tagmap = { 'add': WriteMode._add_validator, 'overwrite': WriteMode._overwrite_validator, diff --git a/dropbox/rest.py b/dropbox/rest.py index 7ad8dd46..0e921daf 100644 --- a/dropbox/rest.py +++ b/dropbox/rest.py @@ -31,7 +31,7 @@ else: url_encode = urllib.urlencode -SDK_VERSION = "6.0" +SDK_VERSION = "6.1" TRUSTED_CERT_FILE = pkg_resources.resource_filename(__name__, 'trusted-certs.crt') diff --git a/dropbox/sharing.py b/dropbox/sharing.py index 4dce1143..70d3e1d3 100644 --- a/dropbox/sharing.py +++ b/dropbox/sharing.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. """ This namespace contains endpoints and data types for creating and managing shared links and shared folders. @@ -13,12 +14,14 @@ try: from . import ( async, + common, files, team, users, ) except (SystemError, ValueError): import async + import common import files import team import users @@ -1087,7 +1090,7 @@ def path(cls, val): Create an instance of this class set to the ``path`` tag with value ``val``. - :param files.LookupError val: + :param files.LookupError_validator val: :rtype: CreateSharedLinkError """ return cls('path', val) @@ -1112,7 +1115,7 @@ def get_path(self): """ Only call this if :meth:`is_path` is true. - :rtype: files.LookupError + :rtype: files.LookupError_validator """ if not self.is_path(): raise AttributeError("tag 'path' not set") @@ -1244,7 +1247,7 @@ def path(cls, val): Create an instance of this class set to the ``path`` tag with value ``val``. - :param files.LookupError val: + :param files.LookupError_validator val: :rtype: CreateSharedLinkWithSettingsError """ return cls('path', val) @@ -1304,7 +1307,7 @@ def get_path(self): """ Only call this if :meth:`is_path` is true. - :rtype: files.LookupError + :rtype: files.LookupError_validator """ if not self.is_path(): raise AttributeError("tag 'path' not set") @@ -1591,7 +1594,7 @@ def content_owner_team_info(self): present if the content's owner is a team member and the content's owner team is different from the link's owner team. - :rtype: users.Team + :rtype: users.Team_validator """ if self._content_owner_team_info_present: return self._content_owner_team_info_value @@ -1603,7 +1606,7 @@ def content_owner_team_info(self, val): if val is None: del self.content_owner_team_info return - self._content_owner_team_info_validator.validate_type_only(val) + val = self._content_owner_team_info_validator.validate(val) self._content_owner_team_info_value = val self._content_owner_team_info_present = True @@ -1971,7 +1974,7 @@ class FolderPermission(object): :ivar action: The action that the user may wish to take on the folder. :ivar allow: True if the user is allowed to take the action. :ivar reason: The reason why the user is denied the permission. Not present - if the action is allowed + if the action is allowed, or if no reason is available. """ __slots__ = [ @@ -2052,7 +2055,7 @@ def allow(self): def reason(self): """ The reason why the user is denied the permission. Not present if the - action is allowed + action is allowed, or if no reason is available. :rtype: PermissionDeniedReason """ @@ -2086,8 +2089,15 @@ class FolderPolicy(object): """ A set of policies governing membership and privileges for a shared folder. - :ivar member_policy: Who can be a member of this shared folder. Only set if - the user is a member of a team. + :ivar member_policy: Who can be a member of this shared folder, as set on + the folder itself. The effective policy may differ from this value if + the team-wide policy is more restrictive. Present only if the folder is + owned by a team. + :ivar resolved_member_policy: Who can be a member of this shared folder, + taking into account both the folder and the team-wide policy. This value + may differ from that of member_policy if the team-wide policy is more + restrictive than the folder policy. Present only if the folder is owned + by a team. :ivar acl_update_policy: Who can add and remove members from this shared folder. :ivar shared_link_policy: Who links can be shared with. @@ -2096,6 +2106,8 @@ class FolderPolicy(object): __slots__ = [ '_member_policy_value', '_member_policy_present', + '_resolved_member_policy_value', + '_resolved_member_policy_present', '_acl_update_policy_value', '_acl_update_policy_present', '_shared_link_policy_value', @@ -2107,15 +2119,20 @@ class FolderPolicy(object): def __init__(self, acl_update_policy=None, shared_link_policy=None, - member_policy=None): + member_policy=None, + resolved_member_policy=None): self._member_policy_value = None self._member_policy_present = False + self._resolved_member_policy_value = None + self._resolved_member_policy_present = False self._acl_update_policy_value = None self._acl_update_policy_present = False self._shared_link_policy_value = None self._shared_link_policy_present = False if member_policy is not None: self.member_policy = member_policy + if resolved_member_policy is not None: + self.resolved_member_policy = resolved_member_policy if acl_update_policy is not None: self.acl_update_policy = acl_update_policy if shared_link_policy is not None: @@ -2124,8 +2141,9 @@ def __init__(self, @property def member_policy(self): """ - Who can be a member of this shared folder. Only set if the user is a - member of a team. + Who can be a member of this shared folder, as set on the folder itself. + The effective policy may differ from this value if the team-wide policy + is more restrictive. Present only if the folder is owned by a team. :rtype: MemberPolicy """ @@ -2148,6 +2166,35 @@ def member_policy(self): self._member_policy_value = None self._member_policy_present = False + @property + def resolved_member_policy(self): + """ + Who can be a member of this shared folder, taking into account both the + folder and the team-wide policy. This value may differ from that of + member_policy if the team-wide policy is more restrictive than the + folder policy. Present only if the folder is owned by a team. + + :rtype: MemberPolicy + """ + if self._resolved_member_policy_present: + return self._resolved_member_policy_value + else: + return None + + @resolved_member_policy.setter + def resolved_member_policy(self, val): + if val is None: + del self.resolved_member_policy + return + self._resolved_member_policy_validator.validate_type_only(val) + self._resolved_member_policy_value = val + self._resolved_member_policy_present = True + + @resolved_member_policy.deleter + def resolved_member_policy(self): + self._resolved_member_policy_value = None + self._resolved_member_policy_present = False + @property def acl_update_policy(self): """ @@ -2195,16 +2242,17 @@ def shared_link_policy(self): self._shared_link_policy_present = False def __repr__(self): - return 'FolderPolicy(acl_update_policy={!r}, shared_link_policy={!r}, member_policy={!r})'.format( + return 'FolderPolicy(acl_update_policy={!r}, shared_link_policy={!r}, member_policy={!r}, resolved_member_policy={!r})'.format( self._acl_update_policy_value, self._shared_link_policy_value, self._member_policy_value, + self._resolved_member_policy_value, ) class GetMetadataArgs(object): """ :ivar shared_folder_id: The ID for the shared folder. - :ivar actions: Folder actions to query. This field is optional. + :ivar actions: Folder actions to query. """ __slots__ = [ @@ -2254,7 +2302,7 @@ def shared_folder_id(self): @property def actions(self): """ - Folder actions to query. This field is optional. + Folder actions to query. :rtype: list of [FolderAction] """ @@ -2585,7 +2633,7 @@ def path(cls, val): Create an instance of this class set to the ``path`` tag with value ``val``. - :param str val: + :param Optional[str] val: :rtype: GetSharedLinksError """ return cls('path', val) @@ -2610,7 +2658,7 @@ def get_path(self): """ Only call this if :meth:`is_path` is true. - :rtype: str + :rtype: Optional[str] """ if not self.is_path(): raise AttributeError("tag 'path' not set") @@ -2671,10 +2719,13 @@ class GroupInfo(team.GroupSummary): The information about a group. Groups is a way to manage a list of users who need same access permission to the shared folder. + :ivar group_type: The type of group. :ivar same_team: If the group is owned by the current user's team. """ __slots__ = [ + '_group_type_value', + '_group_type_present', '_same_team_value', '_same_team_present', ] @@ -2685,17 +2736,45 @@ def __init__(self, group_name=None, group_id=None, member_count=None, + group_type=None, same_team=None, group_external_id=None): super(GroupInfo, self).__init__(group_name, group_id, member_count, group_external_id) + self._group_type_value = None + self._group_type_present = False self._same_team_value = None self._same_team_present = False + if group_type is not None: + self.group_type = group_type if same_team is not None: self.same_team = same_team + @property + def group_type(self): + """ + The type of group. + + :rtype: team.GroupType_validator + """ + if self._group_type_present: + return self._group_type_value + else: + raise AttributeError("missing required field 'group_type'") + + @group_type.setter + def group_type(self, val): + self._group_type_validator.validate_type_only(val) + self._group_type_value = val + self._group_type_present = True + + @group_type.deleter + def group_type(self): + self._group_type_value = None + self._group_type_present = False + @property def same_team(self): """ @@ -2720,10 +2799,11 @@ def same_team(self): self._same_team_present = False def __repr__(self): - return 'GroupInfo(group_name={!r}, group_id={!r}, member_count={!r}, same_team={!r}, group_external_id={!r})'.format( + return 'GroupInfo(group_name={!r}, group_id={!r}, member_count={!r}, group_type={!r}, same_team={!r}, group_external_id={!r})'.format( self._group_name_value, self._group_id_value, self._member_count_value, + self._group_type_value, self._same_team_value, self._group_external_id_value, ) @@ -3421,69 +3501,38 @@ def __repr__(self): self._revoke_failure_reason_value, ) -class ListFolderMembersArgs(object): +class ListFolderMembersCursorArg(object): """ - :ivar shared_folder_id: The ID for the shared folder. - :ivar actions: Member actions to query. This field is optional. + :ivar actions: Member actions to query. :ivar limit: The maximum number of results that include members, groups and invitees to return per request. """ __slots__ = [ - '_shared_folder_id_value', - '_shared_folder_id_present', '_actions_value', '_actions_present', '_limit_value', '_limit_present', ] - _has_required_fields = True + _has_required_fields = False def __init__(self, - shared_folder_id=None, actions=None, limit=None): - self._shared_folder_id_value = None - self._shared_folder_id_present = False self._actions_value = None self._actions_present = False self._limit_value = None self._limit_present = False - if shared_folder_id is not None: - self.shared_folder_id = shared_folder_id if actions is not None: self.actions = actions if limit is not None: self.limit = limit - @property - def shared_folder_id(self): - """ - The ID for the shared folder. - - :rtype: str - """ - if self._shared_folder_id_present: - return self._shared_folder_id_value - else: - raise AttributeError("missing required field 'shared_folder_id'") - - @shared_folder_id.setter - def shared_folder_id(self, val): - val = self._shared_folder_id_validator.validate(val) - self._shared_folder_id_value = val - self._shared_folder_id_present = True - - @shared_folder_id.deleter - def shared_folder_id(self): - self._shared_folder_id_value = None - self._shared_folder_id_present = False - @property def actions(self): """ - Member actions to query. This field is optional. + Member actions to query. :rtype: list of [MemberAction] """ @@ -3530,6 +3579,58 @@ def limit(self): self._limit_value = None self._limit_present = False + def __repr__(self): + return 'ListFolderMembersCursorArg(actions={!r}, limit={!r})'.format( + self._actions_value, + self._limit_value, + ) + +class ListFolderMembersArgs(ListFolderMembersCursorArg): + """ + :ivar shared_folder_id: The ID for the shared folder. + """ + + __slots__ = [ + '_shared_folder_id_value', + '_shared_folder_id_present', + ] + + _has_required_fields = True + + def __init__(self, + shared_folder_id=None, + actions=None, + limit=None): + super(ListFolderMembersArgs, self).__init__(actions, + limit) + self._shared_folder_id_value = None + self._shared_folder_id_present = False + if shared_folder_id is not None: + self.shared_folder_id = shared_folder_id + + @property + def shared_folder_id(self): + """ + The ID for the shared folder. + + :rtype: str + """ + if self._shared_folder_id_present: + return self._shared_folder_id_value + else: + raise AttributeError("missing required field 'shared_folder_id'") + + @shared_folder_id.setter + def shared_folder_id(self, val): + val = self._shared_folder_id_validator.validate(val) + self._shared_folder_id_value = val + self._shared_folder_id_present = True + + @shared_folder_id.deleter + def shared_folder_id(self): + self._shared_folder_id_value = None + self._shared_folder_id_present = False + def __repr__(self): return 'ListFolderMembersArgs(shared_folder_id={!r}, actions={!r}, limit={!r})'.format( self._shared_folder_id_value, @@ -3666,7 +3767,7 @@ def __repr__(self): class ListFoldersArgs(object): """ :ivar limit: The maximum number of results to return per request. - :ivar actions: Folder actions to query. This field is optional. + :ivar actions: Folder actions to query. """ __slots__ = [ @@ -3716,7 +3817,7 @@ def limit(self): @property def actions(self): """ - Folder actions to query. This field is optional. + Folder actions to query. :rtype: list of [FolderAction] """ @@ -3747,8 +3848,8 @@ def __repr__(self): class ListFoldersContinueArg(object): """ - :ivar cursor: The cursor returned by your last call to list_folders or - list_folders/continue. + :ivar cursor: The cursor returned by the previous API call specified in the + endpoint description. """ __slots__ = [ @@ -3768,8 +3869,8 @@ def __init__(self, @property def cursor(self): """ - The cursor returned by your last call to list_folders or - list_folders/continue. + The cursor returned by the previous API call specified in the endpoint + description. :rtype: str """ @@ -3844,14 +3945,16 @@ def __repr__(self): class ListFoldersResult(object): """ - Result for list_folders. Unmounted shared folders can be identified by the + Result for list_folders or list_mountable_folders, depending on which + endpoint was requested. Unmounted shared folders can be identified by the absence of ``SharedFolderMetadata.path_lower``. :ivar entries: List of all shared folders the authenticated user has access to. :ivar cursor: Present if there are additional shared folders that have not - been returned yet. Pass the cursor into list_folders/continue to list - additional folders. + been returned yet. Pass the cursor into the corresponding continue + endpoint (either list_folders/continue or + list_mountable_folders/continue) to list additional folders. """ __slots__ = [ @@ -3902,8 +4005,9 @@ def entries(self): def cursor(self): """ Present if there are additional shared folders that have not been - returned yet. Pass the cursor into list_folders/continue to list - additional folders. + returned yet. Pass the cursor into the corresponding continue endpoint + (either list_folders/continue or list_mountable_folders/continue) to + list additional folders. :rtype: str """ @@ -4088,7 +4192,7 @@ def path(cls, val): Create an instance of this class set to the ``path`` tag with value ``val``. - :param files.LookupError val: + :param files.LookupError_validator val: :rtype: ListSharedLinksError """ return cls('path', val) @@ -4121,7 +4225,7 @@ def get_path(self): """ Only call this if :meth:`is_path` is true. - :rtype: files.LookupError + :rtype: files.LookupError_validator """ if not self.is_path(): raise AttributeError("tag 'path' not set") @@ -4825,6 +4929,9 @@ class MountFolderError(object): :ivar already_mounted: The shared folder is already mounted. :ivar no_permission: The current user does not have permission to perform this action. + :ivar not_mountable: The shared folder is not mountable. One example where + this can occur is when the shared folder belongs within a team folder in + the user's Dropbox. """ __slots__ = ['_tag', '_value'] @@ -4839,6 +4946,8 @@ class MountFolderError(object): # Attribute is overwritten below the class definition no_permission = None # Attribute is overwritten below the class definition + not_mountable = None + # Attribute is overwritten below the class definition other = None def __init__(self, tag, value=None): @@ -4904,6 +5013,14 @@ def is_no_permission(self): """ return self._tag == 'no_permission' + def is_not_mountable(self): + """ + Check if the union tag is ``not_mountable``. + + :rtype: bool + """ + return self._tag == 'not_mountable' + def is_other(self): """ Check if the union tag is ``other``. @@ -5799,11 +5916,13 @@ class ShareFolderArg(object): """ :ivar path: The path to the folder to share. If it does not exist, then a new one is created. - :ivar member_policy: Who can be a member of this shared folder. + :ivar member_policy: Who can be a member of this shared folder. Only + applicable if the current user is on a team. :ivar acl_update_policy: Who can add and remove members of this shared folder. :ivar shared_link_policy: The policy to apply to shared links created for - content inside this shared folder. + content inside this shared folder. The current user must be on a team + to set this policy to ``SharedLinkPolicy.members``. :ivar force_async: Whether to force the share to happen asynchronously. """ @@ -5876,7 +5995,8 @@ def path(self): @property def member_policy(self): """ - Who can be a member of this shared folder. + Who can be a member of this shared folder. Only applicable if the + current user is on a team. :rtype: MemberPolicy """ @@ -5923,7 +6043,8 @@ def acl_update_policy(self): def shared_link_policy(self): """ The policy to apply to shared links created for content inside this - shared folder. + shared folder. The current user must be on a team to set this policy to + ``SharedLinkPolicy.members``. :rtype: SharedLinkPolicy """ @@ -6659,6 +6780,11 @@ class SharedFolderMetadataBase(object): :ivar permissions: Actions the current user may perform on the folder and its contents. The set of permissions corresponds to the FolderActions in the request. + :ivar owner_team: The team that owns the folder. This field is not present + if the folder is not owned by a team. + :ivar parent_shared_folder_id: The ID of the parent shared folder. This + field is present only if the folder is contained within another shared + folder. """ __slots__ = [ @@ -6670,6 +6796,10 @@ class SharedFolderMetadataBase(object): '_policy_present', '_permissions_value', '_permissions_present', + '_owner_team_value', + '_owner_team_present', + '_parent_shared_folder_id_value', + '_parent_shared_folder_id_present', ] _has_required_fields = True @@ -6678,7 +6808,9 @@ def __init__(self, access_type=None, is_team_folder=None, policy=None, - permissions=None): + permissions=None, + owner_team=None, + parent_shared_folder_id=None): self._access_type_value = None self._access_type_present = False self._is_team_folder_value = None @@ -6687,6 +6819,10 @@ def __init__(self, self._policy_present = False self._permissions_value = None self._permissions_present = False + self._owner_team_value = None + self._owner_team_present = False + self._parent_shared_folder_id_value = None + self._parent_shared_folder_id_present = False if access_type is not None: self.access_type = access_type if is_team_folder is not None: @@ -6695,6 +6831,10 @@ def __init__(self, self.policy = policy if permissions is not None: self.permissions = permissions + if owner_team is not None: + self.owner_team = owner_team + if parent_shared_folder_id is not None: + self.parent_shared_folder_id = parent_shared_folder_id @property def access_type(self): @@ -6793,12 +6933,68 @@ def permissions(self): self._permissions_value = None self._permissions_present = False + @property + def owner_team(self): + """ + The team that owns the folder. This field is not present if the folder + is not owned by a team. + + :rtype: users.Team_validator + """ + if self._owner_team_present: + return self._owner_team_value + else: + return None + + @owner_team.setter + def owner_team(self, val): + if val is None: + del self.owner_team + return + self._owner_team_validator.validate_type_only(val) + self._owner_team_value = val + self._owner_team_present = True + + @owner_team.deleter + def owner_team(self): + self._owner_team_value = None + self._owner_team_present = False + + @property + def parent_shared_folder_id(self): + """ + The ID of the parent shared folder. This field is present only if the + folder is contained within another shared folder. + + :rtype: str + """ + if self._parent_shared_folder_id_present: + return self._parent_shared_folder_id_value + else: + return None + + @parent_shared_folder_id.setter + def parent_shared_folder_id(self, val): + if val is None: + del self.parent_shared_folder_id + return + val = self._parent_shared_folder_id_validator.validate(val) + self._parent_shared_folder_id_value = val + self._parent_shared_folder_id_present = True + + @parent_shared_folder_id.deleter + def parent_shared_folder_id(self): + self._parent_shared_folder_id_value = None + self._parent_shared_folder_id_present = False + def __repr__(self): - return 'SharedFolderMetadataBase(access_type={!r}, is_team_folder={!r}, policy={!r}, permissions={!r})'.format( + return 'SharedFolderMetadataBase(access_type={!r}, is_team_folder={!r}, policy={!r}, permissions={!r}, owner_team={!r}, parent_shared_folder_id={!r})'.format( self._access_type_value, self._is_team_folder_value, self._policy_value, self._permissions_value, + self._owner_team_value, + self._parent_shared_folder_id_value, ) class SharedFolderMetadata(SharedFolderMetadataBase): @@ -6829,11 +7025,15 @@ def __init__(self, name=None, shared_folder_id=None, permissions=None, + owner_team=None, + parent_shared_folder_id=None, path_lower=None): super(SharedFolderMetadata, self).__init__(access_type, is_team_folder, policy, - permissions) + permissions, + owner_team, + parent_shared_folder_id) self._path_lower_value = None self._path_lower_present = False self._name_value = None @@ -6921,13 +7121,15 @@ def shared_folder_id(self): self._shared_folder_id_present = False def __repr__(self): - return 'SharedFolderMetadata(access_type={!r}, is_team_folder={!r}, policy={!r}, name={!r}, shared_folder_id={!r}, permissions={!r}, path_lower={!r})'.format( + return 'SharedFolderMetadata(access_type={!r}, is_team_folder={!r}, policy={!r}, name={!r}, shared_folder_id={!r}, permissions={!r}, owner_team={!r}, parent_shared_folder_id={!r}, path_lower={!r})'.format( self._access_type_value, self._is_team_folder_value, self._policy_value, self._name_value, self._shared_folder_id_value, self._permissions_value, + self._owner_team_value, + self._parent_shared_folder_id_value, self._path_lower_value, ) @@ -7309,7 +7511,7 @@ def team_info(self): """ Information about the member's team - :rtype: users.Team + :rtype: users.Team_validator """ if self._team_info_present: return self._team_info_value @@ -7318,7 +7520,7 @@ def team_info(self): @team_info.setter def team_info(self, val): - self._team_info_validator.validate_type_only(val) + val = self._team_info_validator.validate(val) self._team_info_value = val self._team_info_present = True @@ -7654,6 +7856,9 @@ class UnmountFolderError(object): :ivar no_permission: The current user does not have permission to perform this action. + :ivar not_unmountable: The shared folder can't be unmounted. One example + where this can occur is when the shared folder's parent folder is also a + shared folder that resides in the current user's Dropbox. """ __slots__ = ['_tag', '_value'] @@ -7662,6 +7867,8 @@ class UnmountFolderError(object): # Attribute is overwritten below the class definition no_permission = None # Attribute is overwritten below the class definition + not_unmountable = None + # Attribute is overwritten below the class definition other = None def __init__(self, tag, value=None): @@ -7703,6 +7910,14 @@ def is_no_permission(self): """ return self._tag == 'no_permission' + def is_not_unmountable(self): + """ + Check if the union tag is ``not_unmountable``. + + :rtype: bool + """ + return self._tag == 'not_unmountable' + def is_other(self): """ Check if the union tag is ``other``. @@ -7789,7 +8004,7 @@ def leave_a_copy(self): if self._leave_a_copy_present: return self._leave_a_copy_value else: - raise AttributeError("missing required field 'leave_a_copy'") + return False @leave_a_copy.setter def leave_a_copy(self, val): @@ -8138,12 +8353,13 @@ class UpdateFolderPolicyArg(object): If any of the policy's are unset, then they retain their current setting. :ivar shared_folder_id: The ID for the shared folder. - :ivar member_policy: Who can be a member of this shared folder. Only set - this if the current user is on a team. + :ivar member_policy: Who can be a member of this shared folder. Only + applicable if the current user is on a team. :ivar acl_update_policy: Who can add and remove members of this shared folder. :ivar shared_link_policy: The policy to apply to shared links created for - content inside this shared folder. + content inside this shared folder. The current user must be on a team to + set this policy to ``SharedLinkPolicy.members``. """ __slots__ = [ @@ -8207,8 +8423,8 @@ def shared_folder_id(self): @property def member_policy(self): """ - Who can be a member of this shared folder. Only set this if the current - user is on a team. + Who can be a member of this shared folder. Only applicable if the + current user is on a team. :rtype: MemberPolicy """ @@ -8261,7 +8477,8 @@ def acl_update_policy(self): def shared_link_policy(self): """ The policy to apply to shared links created for content inside this - shared folder. + shared folder. The current user must be on a team to set this policy to + ``SharedLinkPolicy.members``. :rtype: SharedLinkPolicy """ @@ -8676,6 +8893,15 @@ def is_other(self): def __repr__(self): return 'Visibility(%r, %r)' % (self._tag, self._value) +DropboxId_validator = bv.String(min_length=1) +GetSharedLinkFileArg_validator = bv.Struct(GetSharedLinkMetadataArg) +GetSharedLinkFileArg = GetSharedLinkMetadataArg +Id_validator = files.Id_validator +Path_validator = files.Path_validator +ReadPath_validator = files.ReadPath_validator +Rev_validator = files.Rev_validator +TeamInfo_validator = bv.Struct(users.Team) +TeamInfo = users.Team AccessLevel._owner_validator = bv.Void() AccessLevel._editor_validator = bv.Void() AccessLevel._viewer_validator = bv.Void() @@ -8705,7 +8931,7 @@ def __repr__(self): AclUpdatePolicy.editors = AclUpdatePolicy('editors') AclUpdatePolicy.other = AclUpdatePolicy('other') -AddFolderMemberArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +AddFolderMemberArg._shared_folder_id_validator = common.SharedFolderId_validator AddFolderMemberArg._members_validator = bv.List(bv.Struct(AddMember)) AddFolderMemberArg._quiet_validator = bv.Boolean() AddFolderMemberArg._custom_message_validator = bv.Nullable(bv.String(min_length=1)) @@ -8766,9 +8992,9 @@ def __repr__(self): ('access_level', AddMember._access_level_validator), ] -AddMemberSelectorError._invalid_dropbox_id_validator = bv.String(min_length=1) -AddMemberSelectorError._invalid_email_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}$") -AddMemberSelectorError._unverified_dropbox_id_validator = bv.String(min_length=1) +AddMemberSelectorError._invalid_dropbox_id_validator = DropboxId_validator +AddMemberSelectorError._invalid_email_validator = common.EmailAddress_validator +AddMemberSelectorError._unverified_dropbox_id_validator = DropboxId_validator AddMemberSelectorError._group_deleted_validator = bv.Void() AddMemberSelectorError._group_not_on_team_validator = bv.Void() AddMemberSelectorError._other_validator = bv.Void() @@ -8787,7 +9013,7 @@ def __repr__(self): LinkMetadata._url_validator = bv.String() LinkMetadata._visibility_validator = bv.Union(Visibility) -LinkMetadata._expires_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +LinkMetadata._expires_validator = bv.Nullable(common.DropboxTimestamp_validator) LinkMetadata._field_names_ = set([ 'url', 'visibility', @@ -8839,7 +9065,7 @@ def __repr__(self): CreateSharedLinkError.other = CreateSharedLinkError('other') -CreateSharedLinkWithSettingsArg._path_validator = bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})') +CreateSharedLinkWithSettingsArg._path_validator = ReadPath_validator CreateSharedLinkWithSettingsArg._settings_validator = bv.Nullable(bv.Struct(SharedLinkSettings)) CreateSharedLinkWithSettingsArg._all_field_names_ = set([ 'path', @@ -8868,13 +9094,13 @@ def __repr__(self): CreateSharedLinkWithSettingsError.access_denied = CreateSharedLinkWithSettingsError('access_denied') SharedLinkMetadata._url_validator = bv.String() -SharedLinkMetadata._id_validator = bv.Nullable(bv.String(min_length=1)) +SharedLinkMetadata._id_validator = bv.Nullable(Id_validator) SharedLinkMetadata._name_validator = bv.String() -SharedLinkMetadata._expires_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +SharedLinkMetadata._expires_validator = bv.Nullable(common.DropboxTimestamp_validator) SharedLinkMetadata._path_lower_validator = bv.Nullable(bv.String()) SharedLinkMetadata._link_permissions_validator = bv.Struct(LinkPermissions) SharedLinkMetadata._team_member_info_validator = bv.Nullable(bv.Struct(TeamMemberInfo)) -SharedLinkMetadata._content_owner_team_info_validator = bv.Nullable(bv.Struct(users.Team)) +SharedLinkMetadata._content_owner_team_info_validator = bv.Nullable(TeamInfo_validator) SharedLinkMetadata._field_names_ = set([ 'url', 'id', @@ -8908,9 +9134,9 @@ def __repr__(self): } SharedLinkMetadata._is_catch_all_ = True -FileLinkMetadata._client_modified_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ') -FileLinkMetadata._server_modified_validator = bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ') -FileLinkMetadata._rev_validator = bv.String(min_length=9, pattern=u'[0-9a-f]+') +FileLinkMetadata._client_modified_validator = common.DropboxTimestamp_validator +FileLinkMetadata._server_modified_validator = common.DropboxTimestamp_validator +FileLinkMetadata._rev_validator = Rev_validator FileLinkMetadata._size_validator = bv.UInt64() FileLinkMetadata._field_names_ = set([ 'client_modified', @@ -8975,20 +9201,23 @@ def __repr__(self): ] FolderPolicy._member_policy_validator = bv.Nullable(bv.Union(MemberPolicy)) +FolderPolicy._resolved_member_policy_validator = bv.Nullable(bv.Union(MemberPolicy)) FolderPolicy._acl_update_policy_validator = bv.Union(AclUpdatePolicy) FolderPolicy._shared_link_policy_validator = bv.Union(SharedLinkPolicy) FolderPolicy._all_field_names_ = set([ 'member_policy', + 'resolved_member_policy', 'acl_update_policy', 'shared_link_policy', ]) FolderPolicy._all_fields_ = [ ('member_policy', FolderPolicy._member_policy_validator), + ('resolved_member_policy', FolderPolicy._resolved_member_policy_validator), ('acl_update_policy', FolderPolicy._acl_update_policy_validator), ('shared_link_policy', FolderPolicy._shared_link_policy_validator), ] -GetMetadataArgs._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +GetMetadataArgs._shared_folder_id_validator = common.SharedFolderId_validator GetMetadataArgs._actions_validator = bv.Nullable(bv.List(bv.Union(FolderAction))) GetMetadataArgs._all_field_names_ = set([ 'shared_folder_id', @@ -9021,7 +9250,7 @@ def __repr__(self): GetSharedLinkFileError.shared_link_is_directory = GetSharedLinkFileError('shared_link_is_directory') GetSharedLinkMetadataArg._url_validator = bv.String() -GetSharedLinkMetadataArg._path_validator = bv.Nullable(bv.String(pattern=u'/.*')) +GetSharedLinkMetadataArg._path_validator = bv.Nullable(Path_validator) GetSharedLinkMetadataArg._link_password_validator = bv.Nullable(bv.String()) GetSharedLinkMetadataArg._all_field_names_ = set([ 'url', @@ -9038,7 +9267,7 @@ def __repr__(self): GetSharedLinksArg._all_field_names_ = set(['path']) GetSharedLinksArg._all_fields_ = [('path', GetSharedLinksArg._path_validator)] -GetSharedLinksError._path_validator = bv.Nullable(bv.String()) +GetSharedLinksError._path_validator = files.MalformedPathError_validator GetSharedLinksError._other_validator = bv.Void() GetSharedLinksError._tagmap = { 'path': GetSharedLinksError._path_validator, @@ -9051,9 +9280,16 @@ def __repr__(self): GetSharedLinksResult._all_field_names_ = set(['links']) GetSharedLinksResult._all_fields_ = [('links', GetSharedLinksResult._links_validator)] +GroupInfo._group_type_validator = bv.Union(team.GroupType) GroupInfo._same_team_validator = bv.Boolean() -GroupInfo._all_field_names_ = team.GroupSummary._all_field_names_.union(set(['same_team'])) -GroupInfo._all_fields_ = team.GroupSummary._all_fields_ + [('same_team', GroupInfo._same_team_validator)] +GroupInfo._all_field_names_ = team.GroupSummary._all_field_names_.union(set([ + 'group_type', + 'same_team', +])) +GroupInfo._all_fields_ = team.GroupSummary._all_fields_ + [ + ('group_type', GroupInfo._group_type_validator), + ('same_team', GroupInfo._same_team_validator), +] MembershipInfo._access_type_validator = bv.Union(AccessLevel) MembershipInfo._permissions_validator = bv.Nullable(bv.List(bv.Struct(MemberPermission))) @@ -9076,7 +9312,7 @@ def __repr__(self): GroupMembershipInfo._all_field_names_ = MembershipInfo._all_field_names_.union(set(['group'])) GroupMembershipInfo._all_fields_ = MembershipInfo._all_fields_ + [('group', GroupMembershipInfo._group_validator)] -InviteeInfo._email_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}$") +InviteeInfo._email_validator = common.EmailAddress_validator InviteeInfo._other_validator = bv.Void() InviteeInfo._tagmap = { 'email': InviteeInfo._email_validator, @@ -9127,20 +9363,21 @@ def __repr__(self): ('revoke_failure_reason', LinkPermissions._revoke_failure_reason_validator), ] -ListFolderMembersArgs._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') -ListFolderMembersArgs._actions_validator = bv.Nullable(bv.List(bv.Union(MemberAction))) -ListFolderMembersArgs._limit_validator = bv.UInt32(min_value=1, max_value=1000) -ListFolderMembersArgs._all_field_names_ = set([ - 'shared_folder_id', +ListFolderMembersCursorArg._actions_validator = bv.Nullable(bv.List(bv.Union(MemberAction))) +ListFolderMembersCursorArg._limit_validator = bv.UInt32(min_value=1, max_value=1000) +ListFolderMembersCursorArg._all_field_names_ = set([ 'actions', 'limit', ]) -ListFolderMembersArgs._all_fields_ = [ - ('shared_folder_id', ListFolderMembersArgs._shared_folder_id_validator), - ('actions', ListFolderMembersArgs._actions_validator), - ('limit', ListFolderMembersArgs._limit_validator), +ListFolderMembersCursorArg._all_fields_ = [ + ('actions', ListFolderMembersCursorArg._actions_validator), + ('limit', ListFolderMembersCursorArg._limit_validator), ] +ListFolderMembersArgs._shared_folder_id_validator = common.SharedFolderId_validator +ListFolderMembersArgs._all_field_names_ = ListFolderMembersCursorArg._all_field_names_.union(set(['shared_folder_id'])) +ListFolderMembersArgs._all_fields_ = ListFolderMembersCursorArg._all_fields_ + [('shared_folder_id', ListFolderMembersArgs._shared_folder_id_validator)] + ListFolderMembersContinueArg._cursor_validator = bv.String() ListFolderMembersContinueArg._all_field_names_ = set(['cursor']) ListFolderMembersContinueArg._all_fields_ = [('cursor', ListFolderMembersContinueArg._cursor_validator)] @@ -9193,7 +9430,7 @@ def __repr__(self): ('cursor', ListFoldersResult._cursor_validator), ] -ListSharedLinksArg._path_validator = bv.Nullable(bv.String(pattern=u'((/|id:).*)|(rev:[0-9a-f]{9,})')) +ListSharedLinksArg._path_validator = bv.Nullable(ReadPath_validator) ListSharedLinksArg._cursor_validator = bv.Nullable(bv.String()) ListSharedLinksArg._direct_only_validator = bv.Nullable(bv.Boolean()) ListSharedLinksArg._all_field_names_ = set([ @@ -9279,8 +9516,8 @@ def __repr__(self): MemberPolicy.anyone = MemberPolicy('anyone') MemberPolicy.other = MemberPolicy('other') -MemberSelector._dropbox_id_validator = bv.String(min_length=1) -MemberSelector._email_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}$") +MemberSelector._dropbox_id_validator = DropboxId_validator +MemberSelector._email_validator = common.EmailAddress_validator MemberSelector._other_validator = bv.Void() MemberSelector._tagmap = { 'dropbox_id': MemberSelector._dropbox_id_validator, @@ -9311,7 +9548,7 @@ def __repr__(self): ModifySharedLinkSettingsError.email_not_verified = ModifySharedLinkSettingsError('email_not_verified') -MountFolderArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +MountFolderArg._shared_folder_id_validator = common.SharedFolderId_validator MountFolderArg._all_field_names_ = set(['shared_folder_id']) MountFolderArg._all_fields_ = [('shared_folder_id', MountFolderArg._shared_folder_id_validator)] @@ -9320,6 +9557,7 @@ def __repr__(self): MountFolderError._insufficient_quota_validator = bv.Void() MountFolderError._already_mounted_validator = bv.Void() MountFolderError._no_permission_validator = bv.Void() +MountFolderError._not_mountable_validator = bv.Void() MountFolderError._other_validator = bv.Void() MountFolderError._tagmap = { 'access_error': MountFolderError._access_error_validator, @@ -9327,6 +9565,7 @@ def __repr__(self): 'insufficient_quota': MountFolderError._insufficient_quota_validator, 'already_mounted': MountFolderError._already_mounted_validator, 'no_permission': MountFolderError._no_permission_validator, + 'not_mountable': MountFolderError._not_mountable_validator, 'other': MountFolderError._other_validator, } @@ -9334,6 +9573,7 @@ def __repr__(self): MountFolderError.insufficient_quota = MountFolderError('insufficient_quota') MountFolderError.already_mounted = MountFolderError('already_mounted') MountFolderError.no_permission = MountFolderError('no_permission') +MountFolderError.not_mountable = MountFolderError('not_mountable') MountFolderError.other = MountFolderError('other') PathLinkMetadata._path_validator = bv.String() @@ -9377,7 +9617,7 @@ def __repr__(self): PermissionDeniedReason.target_not_active = PermissionDeniedReason('target_not_active') PermissionDeniedReason.other = PermissionDeniedReason('other') -RelinquishFolderMembershipArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +RelinquishFolderMembershipArg._shared_folder_id_validator = common.SharedFolderId_validator RelinquishFolderMembershipArg._all_field_names_ = set(['shared_folder_id']) RelinquishFolderMembershipArg._all_fields_ = [('shared_folder_id', RelinquishFolderMembershipArg._shared_folder_id_validator)] @@ -9405,7 +9645,7 @@ def __repr__(self): RelinquishFolderMembershipError.no_permission = RelinquishFolderMembershipError('no_permission') RelinquishFolderMembershipError.other = RelinquishFolderMembershipError('other') -RemoveFolderMemberArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +RemoveFolderMemberArg._shared_folder_id_validator = common.SharedFolderId_validator RemoveFolderMemberArg._member_validator = bv.Union(MemberSelector) RemoveFolderMemberArg._leave_a_copy_validator = bv.Boolean() RemoveFolderMemberArg._all_field_names_ = set([ @@ -9481,7 +9721,7 @@ def __repr__(self): RevokeSharedLinkError.shared_link_malformed = RevokeSharedLinkError('shared_link_malformed') -ShareFolderArg._path_validator = bv.String(pattern=u'/.*') +ShareFolderArg._path_validator = files.Path_validator ShareFolderArg._member_policy_validator = bv.Union(MemberPolicy) ShareFolderArg._acl_update_policy_validator = bv.Union(AclUpdatePolicy) ShareFolderArg._shared_link_policy_validator = bv.Union(SharedLinkPolicy) @@ -9617,22 +9857,28 @@ def __repr__(self): SharedFolderMetadataBase._is_team_folder_validator = bv.Boolean() SharedFolderMetadataBase._policy_validator = bv.Struct(FolderPolicy) SharedFolderMetadataBase._permissions_validator = bv.Nullable(bv.List(bv.Struct(FolderPermission))) +SharedFolderMetadataBase._owner_team_validator = bv.Nullable(bv.Struct(users.Team)) +SharedFolderMetadataBase._parent_shared_folder_id_validator = bv.Nullable(common.SharedFolderId_validator) SharedFolderMetadataBase._all_field_names_ = set([ 'access_type', 'is_team_folder', 'policy', 'permissions', + 'owner_team', + 'parent_shared_folder_id', ]) SharedFolderMetadataBase._all_fields_ = [ ('access_type', SharedFolderMetadataBase._access_type_validator), ('is_team_folder', SharedFolderMetadataBase._is_team_folder_validator), ('policy', SharedFolderMetadataBase._policy_validator), ('permissions', SharedFolderMetadataBase._permissions_validator), + ('owner_team', SharedFolderMetadataBase._owner_team_validator), + ('parent_shared_folder_id', SharedFolderMetadataBase._parent_shared_folder_id_validator), ] SharedFolderMetadata._path_lower_validator = bv.Nullable(bv.String()) SharedFolderMetadata._name_validator = bv.String() -SharedFolderMetadata._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +SharedFolderMetadata._shared_folder_id_validator = common.SharedFolderId_validator SharedFolderMetadata._all_field_names_ = SharedFolderMetadataBase._all_field_names_.union(set([ 'path_lower', 'name', @@ -9681,7 +9927,7 @@ def __repr__(self): SharedLinkSettings._requested_visibility_validator = bv.Nullable(bv.Union(RequestedVisibility)) SharedLinkSettings._link_password_validator = bv.Nullable(bv.String()) -SharedLinkSettings._expires_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +SharedLinkSettings._expires_validator = bv.Nullable(common.DropboxTimestamp_validator) SharedLinkSettings._all_field_names_ = set([ 'requested_visibility', 'link_password', @@ -9703,7 +9949,7 @@ def __repr__(self): SharedLinkSettingsError.invalid_settings = SharedLinkSettingsError('invalid_settings') SharedLinkSettingsError.not_authorized = SharedLinkSettingsError('not_authorized') -TeamMemberInfo._team_info_validator = bv.Struct(users.Team) +TeamMemberInfo._team_info_validator = TeamInfo_validator TeamMemberInfo._display_name_validator = bv.String() TeamMemberInfo._member_id_validator = bv.Nullable(bv.String()) TeamMemberInfo._all_field_names_ = set([ @@ -9717,8 +9963,8 @@ def __repr__(self): ('member_id', TeamMemberInfo._member_id_validator), ] -TransferFolderArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') -TransferFolderArg._to_dropbox_id_validator = bv.String(min_length=1) +TransferFolderArg._shared_folder_id_validator = common.SharedFolderId_validator +TransferFolderArg._to_dropbox_id_validator = DropboxId_validator TransferFolderArg._all_field_names_ = set([ 'shared_folder_id', 'to_dropbox_id', @@ -9755,23 +10001,26 @@ def __repr__(self): TransferFolderError.no_permission = TransferFolderError('no_permission') TransferFolderError.other = TransferFolderError('other') -UnmountFolderArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +UnmountFolderArg._shared_folder_id_validator = common.SharedFolderId_validator UnmountFolderArg._all_field_names_ = set(['shared_folder_id']) UnmountFolderArg._all_fields_ = [('shared_folder_id', UnmountFolderArg._shared_folder_id_validator)] UnmountFolderError._access_error_validator = bv.Union(SharedFolderAccessError) UnmountFolderError._no_permission_validator = bv.Void() +UnmountFolderError._not_unmountable_validator = bv.Void() UnmountFolderError._other_validator = bv.Void() UnmountFolderError._tagmap = { 'access_error': UnmountFolderError._access_error_validator, 'no_permission': UnmountFolderError._no_permission_validator, + 'not_unmountable': UnmountFolderError._not_unmountable_validator, 'other': UnmountFolderError._other_validator, } UnmountFolderError.no_permission = UnmountFolderError('no_permission') +UnmountFolderError.not_unmountable = UnmountFolderError('not_unmountable') UnmountFolderError.other = UnmountFolderError('other') -UnshareFolderArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +UnshareFolderArg._shared_folder_id_validator = common.SharedFolderId_validator UnshareFolderArg._leave_a_copy_validator = bv.Boolean() UnshareFolderArg._all_field_names_ = set([ 'shared_folder_id', @@ -9797,7 +10046,7 @@ def __repr__(self): UnshareFolderError.no_permission = UnshareFolderError('no_permission') UnshareFolderError.other = UnshareFolderError('other') -UpdateFolderMemberArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +UpdateFolderMemberArg._shared_folder_id_validator = common.SharedFolderId_validator UpdateFolderMemberArg._member_validator = bv.Union(MemberSelector) UpdateFolderMemberArg._access_level_validator = bv.Union(AccessLevel) UpdateFolderMemberArg._all_field_names_ = set([ @@ -9828,7 +10077,7 @@ def __repr__(self): UpdateFolderMemberError.no_permission = UpdateFolderMemberError('no_permission') UpdateFolderMemberError.other = UpdateFolderMemberError('other') -UpdateFolderPolicyArg._shared_folder_id_validator = bv.String(pattern=u'[-_0-9a-zA-Z:]+') +UpdateFolderPolicyArg._shared_folder_id_validator = common.SharedFolderId_validator UpdateFolderPolicyArg._member_policy_validator = bv.Nullable(bv.Union(MemberPolicy)) UpdateFolderPolicyArg._acl_update_policy_validator = bv.Nullable(bv.Union(AclUpdatePolicy)) UpdateFolderPolicyArg._shared_link_policy_validator = bv.Nullable(bv.Union(SharedLinkPolicy)) @@ -9863,7 +10112,7 @@ def __repr__(self): UpdateFolderPolicyError.disallowed_shared_link_policy = UpdateFolderPolicyError('disallowed_shared_link_policy') UpdateFolderPolicyError.other = UpdateFolderPolicyError('other') -UserInfo._account_id_validator = bv.String(min_length=40, max_length=40) +UserInfo._account_id_validator = users.AccountId_validator UserInfo._same_team_validator = bv.Boolean() UserInfo._team_member_id_validator = bv.Nullable(bv.String()) UserInfo._all_field_names_ = set([ diff --git a/dropbox/team.py b/dropbox/team.py index 4df52405..2041d16a 100644 --- a/dropbox/team.py +++ b/dropbox/team.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. try: from . import babel_validators as bv @@ -9,10 +10,12 @@ try: from . import ( async, + common, users, ) except (SystemError, ValueError): import async + import common import users class DeviceSession(object): @@ -2081,8 +2084,7 @@ class GetMembershipReport(BaseDfbReport): day. :ivar members_joined: The number of members that joined the team, for each day. - :ivar suspended_members: The number of members that joined the team, for - each day. + :ivar suspended_members: The number of suspended team members, for each day. :ivar licenses: The total number of licenses the team has, for each day. """ @@ -2202,7 +2204,7 @@ def members_joined(self): @property def suspended_members(self): """ - The number of members that joined the team, for each day. + The number of suspended team members, for each day. :rtype: list of [Optional[long]] """ @@ -3865,6 +3867,68 @@ def get_group_external_id(self): def __repr__(self): return 'GroupSelector(%r, %r)' % (self._tag, self._value) +class GroupType(object): + """ + The group type determines how a group is created and managed. + + 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: A group to which team members are automatically added. + Applicable to `team folders `_ only. + :ivar user_managed: A group is created and managed by a user. + """ + + __slots__ = ['_tag', '_value'] + + _catch_all = 'other' + # Attribute is overwritten below the class definition + team = None + # Attribute is overwritten below the class definition + user_managed = 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_team(self): + """ + Check if the union tag is ``team``. + + :rtype: bool + """ + return self._tag == 'team' + + def is_user_managed(self): + """ + Check if the union tag is ``user_managed``. + + :rtype: bool + """ + return self._tag == 'user_managed' + + def is_other(self): + """ + Check if the union tag is ``other``. + + :rtype: bool + """ + return self._tag == 'other' + + def __repr__(self): + return 'GroupType(%r, %r)' % (self._tag, self._value) + class GroupUpdateArgs(object): """ :ivar group: Specify a group. @@ -6618,7 +6682,7 @@ def name(self): """ Representations for a person's name. - :rtype: users.Name + :rtype: users.Name_validator """ if self._name_present: return self._name_value @@ -7927,6 +7991,8 @@ class MembersSetPermissionsError(UserSelectorError): :ivar last_admin: Cannot remove the admin setting of the last admin. :ivar user_not_in_team: The user is not a member of the team. :ivar cannot_set_permissions: Cannot remove/grant permissions. + :ivar team_license_limit: Team is full. The organization has no available + licenses. :ivar other: An unspecified error. """ @@ -7940,6 +8006,8 @@ class MembersSetPermissionsError(UserSelectorError): # Attribute is overwritten below the class definition cannot_set_permissions = None # Attribute is overwritten below the class definition + team_license_limit = None + # Attribute is overwritten below the class definition other = None def __init__(self, tag, value=None): @@ -7978,6 +8046,14 @@ def is_cannot_set_permissions(self): """ return self._tag == 'cannot_set_permissions' + def is_team_license_limit(self): + """ + Check if the union tag is ``team_license_limit``. + + :rtype: bool + """ + return self._tag == 'team_license_limit' + def is_other(self): """ Check if the union tag is ``other``. @@ -8378,6 +8454,8 @@ class MembersSuspendError(MembersDeactivateError): suspended. :ivar suspend_last_admin: The user is the last admin of the team, so it cannot be suspended. + :ivar team_license_limit: Team is full. The organization has no available + licenses. """ __slots__ = ['_tag', '_value'] @@ -8386,6 +8464,8 @@ class MembersSuspendError(MembersDeactivateError): suspend_inactive_user = None # Attribute is overwritten below the class definition suspend_last_admin = None + # Attribute is overwritten below the class definition + team_license_limit = None def __init__(self, tag, value=None): assert tag in self._tagmap, 'Invalid tag %r.' % tag @@ -8415,6 +8495,14 @@ def is_suspend_last_admin(self): """ return self._tag == 'suspend_last_admin' + def is_team_license_limit(self): + """ + Check if the union tag is ``team_license_limit``. + + :rtype: bool + """ + return self._tag == 'team_license_limit' + def __repr__(self): return 'MembersSuspendError(%r, %r)' % (self._tag, self._value) @@ -8476,12 +8564,16 @@ class MembersUnsuspendError(MembersDeactivateError): :ivar unsuspend_non_suspended_member: The user is unsuspended, so it cannot be unsuspended again. + :ivar team_license_limit: Team is full. The organization has no available + licenses. """ __slots__ = ['_tag', '_value'] # Attribute is overwritten below the class definition unsuspend_non_suspended_member = None + # Attribute is overwritten below the class definition + team_license_limit = None def __init__(self, tag, value=None): assert tag in self._tagmap, 'Invalid tag %r.' % tag @@ -8503,6 +8595,14 @@ def is_unsuspend_non_suspended_member(self): """ return self._tag == 'unsuspend_non_suspended_member' + def is_team_license_limit(self): + """ + Check if the union tag is ``team_license_limit``. + + :rtype: bool + """ + return self._tag == 'team_license_limit' + def __repr__(self): return 'MembersUnsuspendError(%r, %r)' % (self._tag, self._value) @@ -9750,6 +9850,83 @@ def is_other(self): def __repr__(self): return 'SharedFolderMemberPolicy(%r, %r)' % (self._tag, self._value) +class SharedLinkCreatePolicy(object): + """ + Policy governing the visibility of newly created shared links. + + 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 default_public: By default, anyone can access newly created shared + links. No login will be required to access the shared links unless + overridden. + :ivar default_team_only: By default, only members of the same team can + access newly created shared links. Login will be required to access the + shared links unless overridden. + :ivar team_only: Only members of the same team can access newly created + shared links. Login will be required to access the shared links. + """ + + __slots__ = ['_tag', '_value'] + + _catch_all = 'other' + # Attribute is overwritten below the class definition + default_public = None + # Attribute is overwritten below the class definition + default_team_only = None + # Attribute is overwritten below the class definition + team_only = 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_default_public(self): + """ + Check if the union tag is ``default_public``. + + :rtype: bool + """ + return self._tag == 'default_public' + + def is_default_team_only(self): + """ + Check if the union tag is ``default_team_only``. + + :rtype: bool + """ + return self._tag == 'default_team_only' + + def is_team_only(self): + """ + Check if the union tag is ``team_only``. + + :rtype: bool + """ + return self._tag == 'team_only' + + def is_other(self): + """ + Check if the union tag is ``other``. + + :rtype: bool + """ + return self._tag == 'other' + + def __repr__(self): + return 'SharedLinkCreatePolicy(%r, %r)' % (self._tag, self._value) + class StorageBucket(object): """ Describes the number of users in a specific storage bucket. @@ -10319,6 +10496,8 @@ class TeamSharingPolicies(object): :ivar shared_folder_member_policy: Who can join folders shared by team members. :ivar shared_folder_join_policy: Which shared folders team members can join. + :ivar shared_link_create_policy: What is the visibility of newly created + shared links. """ __slots__ = [ @@ -10326,21 +10505,28 @@ class TeamSharingPolicies(object): '_shared_folder_member_policy_present', '_shared_folder_join_policy_value', '_shared_folder_join_policy_present', + '_shared_link_create_policy_value', + '_shared_link_create_policy_present', ] _has_required_fields = True def __init__(self, shared_folder_member_policy=None, - shared_folder_join_policy=None): + shared_folder_join_policy=None, + shared_link_create_policy=None): self._shared_folder_member_policy_value = None self._shared_folder_member_policy_present = False self._shared_folder_join_policy_value = None self._shared_folder_join_policy_present = False + self._shared_link_create_policy_value = None + self._shared_link_create_policy_present = False if shared_folder_member_policy is not None: self.shared_folder_member_policy = shared_folder_member_policy if shared_folder_join_policy is not None: self.shared_folder_join_policy = shared_folder_join_policy + if shared_link_create_policy is not None: + self.shared_link_create_policy = shared_link_create_policy @property def shared_folder_member_policy(self): @@ -10388,10 +10574,34 @@ def shared_folder_join_policy(self): self._shared_folder_join_policy_value = None self._shared_folder_join_policy_present = False + @property + def shared_link_create_policy(self): + """ + What is the visibility of newly created shared links. + + :rtype: SharedLinkCreatePolicy + """ + if self._shared_link_create_policy_present: + return self._shared_link_create_policy_value + else: + raise AttributeError("missing required field 'shared_link_create_policy'") + + @shared_link_create_policy.setter + def shared_link_create_policy(self, val): + self._shared_link_create_policy_validator.validate_type_only(val) + self._shared_link_create_policy_value = val + self._shared_link_create_policy_present = True + + @shared_link_create_policy.deleter + def shared_link_create_policy(self): + self._shared_link_create_policy_value = None + self._shared_link_create_policy_present = False + def __repr__(self): - return 'TeamSharingPolicies(shared_folder_member_policy={!r}, shared_folder_join_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_join_policy_value, + self._shared_link_create_policy_value, ) class UserSelectorArg(object): @@ -10636,11 +10846,17 @@ def get_emails(self): def __repr__(self): return 'UsersSelectorArg(%r, %r)' % (self._tag, self._value) +GroupId_validator = bv.String() +GroupsGetInfoResult_validator = bv.List(bv.Union(GroupsGetInfoItem)) +MemberExternalId_validator = bv.String(max_length=64) +MembersGetInfoResult_validator = bv.List(bv.Union(MembersGetInfoItem)) +NumberPerDay_validator = bv.List(bv.Nullable(bv.UInt64())) +TeamMemberId_validator = bv.String() DeviceSession._session_id_validator = bv.String() DeviceSession._ip_address_validator = bv.Nullable(bv.String()) DeviceSession._country_validator = bv.Nullable(bv.String()) -DeviceSession._created_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) -DeviceSession._updated_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +DeviceSession._created_validator = bv.Nullable(common.DropboxTimestamp_validator) +DeviceSession._updated_validator = bv.Nullable(common.DropboxTimestamp_validator) DeviceSession._all_field_names_ = set([ 'session_id', 'ip_address', @@ -10690,7 +10906,7 @@ def __repr__(self): ApiApp._app_name_validator = bv.String() ApiApp._publisher_validator = bv.Nullable(bv.String()) ApiApp._publisher_url_validator = bv.Nullable(bv.String()) -ApiApp._linked_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%dT%H:%M:%SZ')) +ApiApp._linked_validator = bv.Nullable(common.DropboxTimestamp_validator) ApiApp._is_app_folder_validator = bv.Boolean() ApiApp._all_field_names_ = set([ 'app_id', @@ -10713,8 +10929,8 @@ def __repr__(self): BaseDfbReport._all_field_names_ = set(['start_date']) BaseDfbReport._all_fields_ = [('start_date', BaseDfbReport._start_date_validator)] -DateRange._start_date_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%d')) -DateRange._end_date_validator = bv.Nullable(bv.Timestamp(u'%Y-%m-%d')) +DateRange._start_date_validator = bv.Nullable(common.Date_validator) +DateRange._end_date_validator = bv.Nullable(common.Date_validator) DateRange._all_field_names_ = set([ 'start_date', 'end_date', @@ -10778,13 +10994,13 @@ def __repr__(self): ('team_member_id', DeviceSessionArg._team_member_id_validator), ] -DevicesActive._windows_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._macos_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._linux_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._ios_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._android_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._other_validator = bv.List(bv.Nullable(bv.UInt64())) -DevicesActive._total_validator = bv.List(bv.Nullable(bv.UInt64())) +DevicesActive._windows_validator = NumberPerDay_validator +DevicesActive._macos_validator = NumberPerDay_validator +DevicesActive._linux_validator = NumberPerDay_validator +DevicesActive._ios_validator = NumberPerDay_validator +DevicesActive._android_validator = NumberPerDay_validator +DevicesActive._other_validator = NumberPerDay_validator +DevicesActive._total_validator = NumberPerDay_validator DevicesActive._all_field_names_ = set([ 'windows', 'macos', @@ -10820,20 +11036,20 @@ def __repr__(self): EmmState.required = EmmState('required') EmmState.other = EmmState('other') -GetActivityReport._adds_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._edits_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._deletes_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_users_28_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_users_7_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_users_1_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_shared_folders_28_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_shared_folders_7_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._active_shared_folders_1_day_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._shared_links_created_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._shared_links_viewed_by_team_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._shared_links_viewed_by_outside_user_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._shared_links_viewed_by_not_logged_in_validator = bv.List(bv.Nullable(bv.UInt64())) -GetActivityReport._shared_links_viewed_total_validator = bv.List(bv.Nullable(bv.UInt64())) +GetActivityReport._adds_validator = NumberPerDay_validator +GetActivityReport._edits_validator = NumberPerDay_validator +GetActivityReport._deletes_validator = NumberPerDay_validator +GetActivityReport._active_users_28_day_validator = NumberPerDay_validator +GetActivityReport._active_users_7_day_validator = NumberPerDay_validator +GetActivityReport._active_users_1_day_validator = NumberPerDay_validator +GetActivityReport._active_shared_folders_28_day_validator = NumberPerDay_validator +GetActivityReport._active_shared_folders_7_day_validator = NumberPerDay_validator +GetActivityReport._active_shared_folders_1_day_validator = NumberPerDay_validator +GetActivityReport._shared_links_created_validator = NumberPerDay_validator +GetActivityReport._shared_links_viewed_by_team_validator = NumberPerDay_validator +GetActivityReport._shared_links_viewed_by_outside_user_validator = NumberPerDay_validator +GetActivityReport._shared_links_viewed_by_not_logged_in_validator = NumberPerDay_validator +GetActivityReport._shared_links_viewed_total_validator = NumberPerDay_validator GetActivityReport._all_field_names_ = BaseDfbReport._all_field_names_.union(set([ 'adds', 'edits', @@ -10881,11 +11097,11 @@ def __repr__(self): ('active_28_day', GetDevicesReport._active_28_day_validator), ] -GetMembershipReport._team_size_validator = bv.List(bv.Nullable(bv.UInt64())) -GetMembershipReport._pending_invites_validator = bv.List(bv.Nullable(bv.UInt64())) -GetMembershipReport._members_joined_validator = bv.List(bv.Nullable(bv.UInt64())) -GetMembershipReport._suspended_members_validator = bv.List(bv.Nullable(bv.UInt64())) -GetMembershipReport._licenses_validator = bv.List(bv.Nullable(bv.UInt64())) +GetMembershipReport._team_size_validator = NumberPerDay_validator +GetMembershipReport._pending_invites_validator = NumberPerDay_validator +GetMembershipReport._members_joined_validator = NumberPerDay_validator +GetMembershipReport._suspended_members_validator = NumberPerDay_validator +GetMembershipReport._licenses_validator = NumberPerDay_validator GetMembershipReport._all_field_names_ = BaseDfbReport._all_field_names_.union(set([ 'team_size', 'pending_invites', @@ -10901,10 +11117,10 @@ def __repr__(self): ('licenses', GetMembershipReport._licenses_validator), ] -GetStorageReport._total_usage_validator = bv.List(bv.Nullable(bv.UInt64())) -GetStorageReport._shared_usage_validator = bv.List(bv.Nullable(bv.UInt64())) -GetStorageReport._unshared_usage_validator = bv.List(bv.Nullable(bv.UInt64())) -GetStorageReport._shared_folders_validator = bv.List(bv.Nullable(bv.UInt64())) +GetStorageReport._total_usage_validator = NumberPerDay_validator +GetStorageReport._shared_usage_validator = NumberPerDay_validator +GetStorageReport._unshared_usage_validator = NumberPerDay_validator +GetStorageReport._shared_folders_validator = NumberPerDay_validator GetStorageReport._member_storage_map_validator = bv.List(bv.List(bv.Struct(StorageBucket))) GetStorageReport._all_field_names_ = BaseDfbReport._all_field_names_.union(set([ 'total_usage', @@ -10977,7 +11193,7 @@ def __repr__(self): GroupDeleteError.group_already_deleted = GroupDeleteError('group_already_deleted') GroupSummary._group_name_validator = bv.String() -GroupSummary._group_id_validator = bv.String() +GroupSummary._group_id_validator = GroupId_validator GroupSummary._group_external_id_validator = bv.Nullable(bv.String()) GroupSummary._member_count_validator = bv.UInt32() GroupSummary._all_field_names_ = set([ @@ -11064,7 +11280,7 @@ def __repr__(self): GroupMembersAddError.user_must_be_active_to_be_owner = GroupMembersAddError('user_must_be_active_to_be_owner') GroupMembersChangeResult._group_info_validator = bv.Struct(GroupFullInfo) -GroupMembersChangeResult._async_job_id_validator = bv.String(min_length=1) +GroupMembersChangeResult._async_job_id_validator = async.AsyncJobId_validator GroupMembersChangeResult._all_field_names_ = set([ 'group_info', 'async_job_id', @@ -11116,13 +11332,26 @@ def __repr__(self): GroupMembersSetAccessTypeArg._all_field_names_ = GroupMemberSelector._all_field_names_.union(set(['access_type'])) GroupMembersSetAccessTypeArg._all_fields_ = GroupMemberSelector._all_fields_ + [('access_type', GroupMembersSetAccessTypeArg._access_type_validator)] -GroupSelector._group_id_validator = bv.String() +GroupSelector._group_id_validator = GroupId_validator GroupSelector._group_external_id_validator = bv.String() GroupSelector._tagmap = { 'group_id': GroupSelector._group_id_validator, 'group_external_id': GroupSelector._group_external_id_validator, } +GroupType._team_validator = bv.Void() +GroupType._user_managed_validator = bv.Void() +GroupType._other_validator = bv.Void() +GroupType._tagmap = { + 'team': GroupType._team_validator, + 'user_managed': GroupType._user_managed_validator, + 'other': GroupType._other_validator, +} + +GroupType.team = GroupType('team') +GroupType.user_managed = GroupType('user_managed') +GroupType.other = GroupType('other') + GroupUpdateArgs._group_validator = bv.Union(GroupSelector) GroupUpdateArgs._new_group_name_validator = bv.Nullable(bv.String()) GroupUpdateArgs._new_group_external_id_validator = bv.Nullable(bv.String()) @@ -11202,7 +11431,7 @@ def __repr__(self): GroupsPollError.access_denied = GroupsPollError('access_denied') -GroupsSelector._group_ids_validator = bv.List(bv.String()) +GroupsSelector._group_ids_validator = bv.List(GroupId_validator) GroupsSelector._group_external_ids_validator = bv.List(bv.String()) GroupsSelector._tagmap = { 'group_ids': GroupsSelector._group_ids_validator, @@ -11348,10 +11577,10 @@ def __repr__(self): ('access_type', MemberAccess._access_type_validator), ] -MemberAddArg._member_email_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}$") -MemberAddArg._member_given_name_validator = bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*') -MemberAddArg._member_surname_validator = bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*') -MemberAddArg._member_external_id_validator = bv.Nullable(bv.String(max_length=64)) +MemberAddArg._member_email_validator = common.EmailAddress_validator +MemberAddArg._member_given_name_validator = common.NamePart_validator +MemberAddArg._member_surname_validator = common.NamePart_validator +MemberAddArg._member_external_id_validator = bv.Nullable(MemberExternalId_validator) MemberAddArg._send_welcome_email_validator = bv.Boolean() MemberAddArg._role_validator = bv.Union(AdminTier) MemberAddArg._all_field_names_ = set([ @@ -11372,14 +11601,14 @@ def __repr__(self): ] MemberAddResult._success_validator = bv.Struct(TeamMemberInfo) -MemberAddResult._team_license_limit_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}$") -MemberAddResult._free_team_member_limit_reached_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}$") -MemberAddResult._user_already_on_team_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}$") -MemberAddResult._user_on_another_team_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}$") -MemberAddResult._user_already_paired_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}$") -MemberAddResult._user_migration_failed_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}$") -MemberAddResult._duplicate_external_member_id_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}$") -MemberAddResult._user_creation_failed_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}$") +MemberAddResult._team_license_limit_validator = common.EmailAddress_validator +MemberAddResult._free_team_member_limit_reached_validator = common.EmailAddress_validator +MemberAddResult._user_already_on_team_validator = common.EmailAddress_validator +MemberAddResult._user_on_another_team_validator = common.EmailAddress_validator +MemberAddResult._user_already_paired_validator = common.EmailAddress_validator +MemberAddResult._user_migration_failed_validator = common.EmailAddress_validator +MemberAddResult._duplicate_external_member_id_validator = common.EmailAddress_validator +MemberAddResult._user_creation_failed_validator = common.EmailAddress_validator MemberAddResult._tagmap = { 'success': MemberAddResult._success_validator, 'team_license_limit': MemberAddResult._team_license_limit_validator, @@ -11420,7 +11649,7 @@ def __repr__(self): ('linked_api_apps', MemberLinkedApps._linked_api_apps_validator), ] -MemberProfile._team_member_id_validator = bv.String() +MemberProfile._team_member_id_validator = TeamMemberId_validator MemberProfile._external_id_validator = bv.Nullable(bv.String()) MemberProfile._email_validator = bv.String() MemberProfile._email_verified_validator = bv.Boolean() @@ -11627,11 +11856,13 @@ def __repr__(self): MembersSetPermissionsError._last_admin_validator = bv.Void() MembersSetPermissionsError._user_not_in_team_validator = bv.Void() MembersSetPermissionsError._cannot_set_permissions_validator = bv.Void() +MembersSetPermissionsError._team_license_limit_validator = bv.Void() MembersSetPermissionsError._other_validator = bv.Void() MembersSetPermissionsError._tagmap = { 'last_admin': MembersSetPermissionsError._last_admin_validator, 'user_not_in_team': MembersSetPermissionsError._user_not_in_team_validator, 'cannot_set_permissions': MembersSetPermissionsError._cannot_set_permissions_validator, + 'team_license_limit': MembersSetPermissionsError._team_license_limit_validator, 'other': MembersSetPermissionsError._other_validator, } MembersSetPermissionsError._tagmap.update(UserSelectorError._tagmap) @@ -11639,9 +11870,10 @@ def __repr__(self): MembersSetPermissionsError.last_admin = MembersSetPermissionsError('last_admin') MembersSetPermissionsError.user_not_in_team = MembersSetPermissionsError('user_not_in_team') MembersSetPermissionsError.cannot_set_permissions = MembersSetPermissionsError('cannot_set_permissions') +MembersSetPermissionsError.team_license_limit = MembersSetPermissionsError('team_license_limit') MembersSetPermissionsError.other = MembersSetPermissionsError('other') -MembersSetPermissionsResult._team_member_id_validator = bv.String() +MembersSetPermissionsResult._team_member_id_validator = TeamMemberId_validator MembersSetPermissionsResult._role_validator = bv.Union(AdminTier) MembersSetPermissionsResult._all_field_names_ = set([ 'team_member_id', @@ -11653,10 +11885,10 @@ def __repr__(self): ] MembersSetProfileArg._user_validator = bv.Union(UserSelectorArg) -MembersSetProfileArg._new_email_validator = bv.Nullable(bv.String()) -MembersSetProfileArg._new_external_id_validator = bv.Nullable(bv.String()) -MembersSetProfileArg._new_given_name_validator = bv.Nullable(bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*')) -MembersSetProfileArg._new_surname_validator = bv.Nullable(bv.String(min_length=1, max_length=100, pattern=u'[^/:?*<>"|]*')) +MembersSetProfileArg._new_email_validator = bv.Nullable(common.EmailAddress_validator) +MembersSetProfileArg._new_external_id_validator = bv.Nullable(MemberExternalId_validator) +MembersSetProfileArg._new_given_name_validator = bv.Nullable(common.NamePart_validator) +MembersSetProfileArg._new_surname_validator = bv.Nullable(common.NamePart_validator) MembersSetProfileArg._all_field_names_ = set([ 'user', 'new_email', @@ -11700,26 +11932,32 @@ def __repr__(self): MembersSuspendError._suspend_inactive_user_validator = bv.Void() MembersSuspendError._suspend_last_admin_validator = bv.Void() +MembersSuspendError._team_license_limit_validator = bv.Void() MembersSuspendError._tagmap = { 'suspend_inactive_user': MembersSuspendError._suspend_inactive_user_validator, 'suspend_last_admin': MembersSuspendError._suspend_last_admin_validator, + 'team_license_limit': MembersSuspendError._team_license_limit_validator, } MembersSuspendError._tagmap.update(MembersDeactivateError._tagmap) MembersSuspendError.suspend_inactive_user = MembersSuspendError('suspend_inactive_user') MembersSuspendError.suspend_last_admin = MembersSuspendError('suspend_last_admin') +MembersSuspendError.team_license_limit = MembersSuspendError('team_license_limit') MembersUnsuspendArg._user_validator = bv.Union(UserSelectorArg) MembersUnsuspendArg._all_field_names_ = set(['user']) MembersUnsuspendArg._all_fields_ = [('user', MembersUnsuspendArg._user_validator)] MembersUnsuspendError._unsuspend_non_suspended_member_validator = bv.Void() +MembersUnsuspendError._team_license_limit_validator = bv.Void() MembersUnsuspendError._tagmap = { 'unsuspend_non_suspended_member': MembersUnsuspendError._unsuspend_non_suspended_member_validator, + 'team_license_limit': MembersUnsuspendError._team_license_limit_validator, } MembersUnsuspendError._tagmap.update(MembersDeactivateError._tagmap) MembersUnsuspendError.unsuspend_non_suspended_member = MembersUnsuspendError('unsuspend_non_suspended_member') +MembersUnsuspendError.team_license_limit = MembersUnsuspendError('team_license_limit') MobileClientPlatform._iphone_validator = bv.Void() MobileClientPlatform._ipad_validator = bv.Void() @@ -11894,6 +12132,22 @@ def __repr__(self): SharedFolderMemberPolicy.anyone = SharedFolderMemberPolicy('anyone') SharedFolderMemberPolicy.other = SharedFolderMemberPolicy('other') +SharedLinkCreatePolicy._default_public_validator = bv.Void() +SharedLinkCreatePolicy._default_team_only_validator = bv.Void() +SharedLinkCreatePolicy._team_only_validator = bv.Void() +SharedLinkCreatePolicy._other_validator = bv.Void() +SharedLinkCreatePolicy._tagmap = { + 'default_public': SharedLinkCreatePolicy._default_public_validator, + 'default_team_only': SharedLinkCreatePolicy._default_team_only_validator, + 'team_only': SharedLinkCreatePolicy._team_only_validator, + 'other': SharedLinkCreatePolicy._other_validator, +} + +SharedLinkCreatePolicy.default_public = SharedLinkCreatePolicy('default_public') +SharedLinkCreatePolicy.default_team_only = SharedLinkCreatePolicy('default_team_only') +SharedLinkCreatePolicy.team_only = SharedLinkCreatePolicy('team_only') +SharedLinkCreatePolicy.other = SharedLinkCreatePolicy('other') + StorageBucket._bucket_validator = bv.String() StorageBucket._users_validator = bv.UInt64() StorageBucket._all_field_names_ = set([ @@ -11936,7 +12190,7 @@ def __repr__(self): ('role', TeamMemberInfo._role_validator), ] -TeamMemberProfile._groups_validator = bv.List(bv.String()) +TeamMemberProfile._groups_validator = bv.List(GroupId_validator) TeamMemberProfile._all_field_names_ = MemberProfile._all_field_names_.union(set(['groups'])) TeamMemberProfile._all_fields_ = MemberProfile._all_fields_ + [('groups', TeamMemberProfile._groups_validator)] @@ -11966,27 +12220,30 @@ def __repr__(self): TeamSharingPolicies._shared_folder_member_policy_validator = bv.Union(SharedFolderMemberPolicy) TeamSharingPolicies._shared_folder_join_policy_validator = bv.Union(SharedFolderJoinPolicy) +TeamSharingPolicies._shared_link_create_policy_validator = bv.Union(SharedLinkCreatePolicy) TeamSharingPolicies._all_field_names_ = set([ 'shared_folder_member_policy', 'shared_folder_join_policy', + 'shared_link_create_policy', ]) TeamSharingPolicies._all_fields_ = [ ('shared_folder_member_policy', TeamSharingPolicies._shared_folder_member_policy_validator), ('shared_folder_join_policy', TeamSharingPolicies._shared_folder_join_policy_validator), + ('shared_link_create_policy', TeamSharingPolicies._shared_link_create_policy_validator), ] -UserSelectorArg._team_member_id_validator = bv.String() -UserSelectorArg._external_id_validator = bv.String() -UserSelectorArg._email_validator = bv.String() +UserSelectorArg._team_member_id_validator = TeamMemberId_validator +UserSelectorArg._external_id_validator = MemberExternalId_validator +UserSelectorArg._email_validator = common.EmailAddress_validator UserSelectorArg._tagmap = { 'team_member_id': UserSelectorArg._team_member_id_validator, 'external_id': UserSelectorArg._external_id_validator, 'email': UserSelectorArg._email_validator, } -UsersSelectorArg._team_member_ids_validator = bv.List(bv.String()) -UsersSelectorArg._external_ids_validator = bv.List(bv.String()) -UsersSelectorArg._emails_validator = bv.List(bv.String()) +UsersSelectorArg._team_member_ids_validator = bv.List(TeamMemberId_validator) +UsersSelectorArg._external_ids_validator = bv.List(MemberExternalId_validator) +UsersSelectorArg._emails_validator = bv.List(common.EmailAddress_validator) UsersSelectorArg._tagmap = { 'team_member_ids': UsersSelectorArg._team_member_ids_validator, 'external_ids': UsersSelectorArg._external_ids_validator, diff --git a/dropbox/users.py b/dropbox/users.py index 6d612678..f9a71617 100644 --- a/dropbox/users.py +++ b/dropbox/users.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Auto-generated by BabelAPI, do not modify. """ This namespace contains endpoints and data types for user management. @@ -1399,7 +1400,9 @@ def __repr__(self): self._allocated_value, ) -Account._account_id_validator = bv.String(min_length=40, max_length=40) +AccountId_validator = bv.String(min_length=40, max_length=40) +GetAccountBatchResult_validator = bv.List(bv.Struct(BasicAccount)) +Account._account_id_validator = AccountId_validator Account._name_validator = bv.Struct(Name) Account._email_validator = bv.String() Account._email_verified_validator = bv.Boolean() @@ -1469,15 +1472,15 @@ def __repr__(self): ('account_type', FullAccount._account_type_validator), ] -GetAccountArg._account_id_validator = bv.String(min_length=40, max_length=40) +GetAccountArg._account_id_validator = AccountId_validator GetAccountArg._all_field_names_ = set(['account_id']) GetAccountArg._all_fields_ = [('account_id', GetAccountArg._account_id_validator)] -GetAccountBatchArg._account_ids_validator = bv.List(bv.String(min_length=40, max_length=40), min_items=1) +GetAccountBatchArg._account_ids_validator = bv.List(AccountId_validator, min_items=1) GetAccountBatchArg._all_field_names_ = set(['account_ids']) GetAccountBatchArg._all_fields_ = [('account_ids', GetAccountBatchArg._account_ids_validator)] -GetAccountBatchError._no_account_validator = bv.String(min_length=40, max_length=40) +GetAccountBatchError._no_account_validator = AccountId_validator GetAccountBatchError._other_validator = bv.Void() GetAccountBatchError._tagmap = { 'no_account': GetAccountBatchError._no_account_validator, diff --git a/setup.py b/setup.py index fa2c133a..42636c92 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ dist = setup( name='dropbox', - version='6.0', + version='6.1', description='Official Dropbox API Client', author='Dropbox', author_email='dev-platform@dropbox.com',