Пример #1
0
class AuthConfigSchema(BaseSchema):
    host = fields.String(validate=Length(min=1, max=1024), missing='localhost')
    port = fields.Integer(validate=Range(min=1, max=65535), missing=9497)
    key_file = fields.String(validate=Length(min=1, max=1024), allow_none=True)
    username = fields.String(validate=Length(min=1, max=512), allow_none=True)
    password = fields.String(validate=Length(min=1, max=512), allow_none=True)
    verify_certificate = VerifyCertificateField(missing=True)
    timeout = fields.Float(validate=Range(min=0, max=3660))
    version = fields.String(validate=Length(min=1, max=16), missing='0.1')

    @validates_schema
    def validate_auth_info(self, data):
        key_file = data.get('key_file')
        username = data.get('username')

        if key_file and username:
            raise exceptions.ValidationError(
                'a "key_file" or a "username" and "password" must be specified',
            )

        if key_file or username:
            return

        raise exceptions.ValidationError(
            'a "key_file" or a "username" and "password" must be specified', )
Пример #2
0
class LDAPConfig(BaseSchema):
    tenant_uuid = fields.String(dump_only=True, default=None)
    host = fields.String(validate=Length(max=512), required=True, default=None)
    port = fields.Integer(required=True, default=None)
    protocol_version = fields.Integer(validate=Range(min=2, max=3),
                                      missing=3,
                                      default=None)
    protocol_security = fields.String(
        validate=OneOf(['ldaps', 'tls']),
        allow_none=True,
        default=None,
    )
    bind_dn = fields.String(validate=Length(max=256),
                            allow_none=True,
                            default=None)
    user_base_dn = fields.String(validate=Length(max=256),
                                 required=True,
                                 default=None)
    user_login_attribute = fields.String(validate=Length(max=64),
                                         required=True,
                                         default=None)
    user_email_attribute = fields.String(validate=Length(max=64),
                                         required=True,
                                         default=None)
    search_filters = fields.String(allow_none=True, default=None)
Пример #3
0
class SourceSchema(BaseSourceSchema):
    lookup_url = fields.URL(required=True)
    list_url = fields.URL(allownone=True, missing=None)
    verify_certificate = VerifyCertificateField(missing=True)
    delimiter = fields.String(Length(min=1, max=1), missing=',')
    timeout = fields.Float(Range(min=0), missing=10.0)
    unique_column = fields.String(Length(min=1, max=128), allownone=True, missing=None)
Пример #4
0
class ConfdConfigSchema(BaseSchema):
    host = fields.String(validate=Length(min=1, max=1024), missing='localhost')
    port = fields.Integer(validate=Range(min=1, max=65535), missing=9486)
    verify_certificate = VerifyCertificateField(missing=True)
    timeout = fields.Float(validate=Range(min=0, max=3660))
    https = fields.Boolean(missing=True)
    version = fields.String(validate=Length(min=1, max=16), missing='1.1')
Пример #5
0
class SourceSchema(BaseSourceSchema):
    unique_column = fields.String(
        validate=Length(min=1, max=128),
        allow_none=True,
        missing=None,
    )
    file = fields.String(validate=Length(min=1), required=True)
    separator = fields.String(validate=Length(min=1, max=1), missing=',')
Пример #6
0
class BaseAuthConfigSchema(BaseSchema):
    host = fields.String(validate=Length(min=1, max=1024), missing='localhost')
    port = fields.Integer(validate=Range(min=1, max=65535), missing=443)
    https = fields.Boolean(missing=True)
    verify_certificate = VerifyCertificateField(missing=True)
    prefix = fields.String(allow_none=True, missing='/api/auth')
    version = fields.String(validate=Length(min=1, max=16), missing='0.1')
    timeout = fields.Float(validate=Range(min=0, max=3660))
Пример #7
0
class ApplicationCallUserRequestSchema(BaseSchema):
    user_uuid = fields.String(required=True)
    autoanswer = fields.Boolean(required=False, missing=False)
    variables = fields.Dict(validate=validate_string_dict, missing={})
    displayed_caller_id_name = fields.String(missing='',
                                             validate=Length(max=256))
    displayed_caller_id_number = fields.String(missing='',
                                               validate=Length(max=256))
Пример #8
0
class SourceSchema(BaseSourceSchema):

    auth = fields.Dict(keys=fields.String(validate=Length(min=1, max=64)),
                       values=fields.String(validate=Length(min=1, max=64)))
    endpoint = fields.String(
        missing='https://graph.microsoft.com/v1.0/me/contacts',
        validate=Length(min=1, max=255),
    )
Пример #9
0
class BaseSourceSchema(BaseSchema):
    uuid = fields.UUID(dump_only=True)
    tenant_uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(min=1, max=512), required=True)
    first_matched_columns = fields.List(
        fields.String(validate=Length(min=1, max=128)), missing=[])
    searched_columns = fields.List(
        fields.String(validate=Length(min=1, max=128)), missing=[])
    format_columns = fields.Dict(validate=validate_string_dict, missing={})
Пример #10
0
class DisplaySchema(BaseSchema):
    uuid = fields.UUID(dump_only=True)
    tenant_uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(min=1, max=512), required=True)
    columns = fields.Nested(
        DisplayColumnSchema,
        many=True,
        required=True,
        validate=Length(min=1),
    )
Пример #11
0
class UserSubscriptionSchema(Schema):
    uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(max=128), required=True)
    service = fields.String(validate=Length(max=128),
                            allow_none=False,
                            required=True)
    events = fields.List(fields.String(validate=Length(max=128),
                                       allow_none=False),
                         allow_none=False,
                         required=True)
    config = ConfigField(allow_none=False, required=True)
    metadata_ = fields.Dict(load_from='metadata')
Пример #12
0
class ApplicationCallRequestSchema(BaseSchema):
    exten = fields.String(validate=Length(min=1), required=True)
    context = fields.String(required=True)
    autoanswer = fields.Boolean(required=False, missing=False)
    variables = fields.Dict(validate=validate_string_dict, missing={})
    displayed_caller_id_name = fields.String(missing='',
                                             validate=Length(max=256))
    displayed_caller_id_number = fields.String(missing='',
                                               validate=Length(max=256))

    @post_load
    def remove_extension_whitespace(self, call_request, **kwargs):
        call_request['exten'] = ''.join(call_request['exten'].split())
        return call_request
Пример #13
0
class UserSubscriptionSchema(Schema):
    class Meta:
        unknown = EXCLUDE

    uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(max=128), required=True)
    service = fields.String(validate=Length(max=128),
                            allow_none=False,
                            required=True)
    events = fields.List(
        fields.String(validate=Length(max=128), allow_none=False),
        allow_none=False,
        required=True,
    )
    config = ConfigField(allow_none=False, required=True)
    metadata_ = fields.Dict(data_key='metadata')
Пример #14
0
class RefreshTokenSchema(BaseSchema):

    client_id = fields.String(validate=Length(min=1, max=1024))
    created_at = fields.DateTime()
    mobile = fields.Boolean()
    user_uuid = fields.String()
    tenant_uuid = fields.String()
Пример #15
0
class ProfileSchema(BaseSchema):

    uuid = fields.UUID(dump_only=True)
    tenant_uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(min=1, max=512), required=True)
    display = fields.Nested(ResourceSchema)
    services = ServiceDictSchema(BaseSchema, required=True)
Пример #16
0
class MarketListRequestSchema(Schema):

    direction = fields.String(validate=OneOf(['asc', 'desc']), missing='asc')
    order = fields.String(validate=Length(min=1), missing='name')
    limit = fields.Integer(validate=Range(min=0), missing=None)
    offset = fields.Integer(validate=Range(min=0), missing=0)
    search = fields.String(missing=None)
    installed = fields.Boolean()
Пример #17
0
class TokenRequestSchema(BaseSchema):
    backend = fields.String(missing='wazo_user')
    expiration = fields.Integer(validate=Range(min=1))
    access_type = fields.String(validate=OneOf(['online', 'offline']))
    client_id = fields.String(validate=Length(min=1, max=1024))
    refresh_token = fields.String()
    tenant_id = fields.String()
    domain_name = fields.String()

    @validates_schema
    def check_access_type_usage(self, data, **kwargs):
        access_type = data.get('access_type')
        if access_type != 'offline':
            return

        refresh_token = data.get('refresh_token')
        if refresh_token:
            raise ValidationError(
                'cannot use the "access_type" "offline" with a refresh token'
            )

        client_id = data.get('client_id')
        if not client_id:
            raise ValidationError(
                '"client_id" must be specified when using "access_type" is "offline"'
            )

    @validates_schema
    def check_backend_type_for_tenant_id_and_domain_name(self, data, **kwargs):
        backend = data.get('backend')
        if not backend == 'ldap_user':
            return

        tenant_id = data.get('tenant_id')
        domain_name = data.get('domain_name')
        if tenant_id and domain_name:
            raise ValidationError(
                '"tenant_id" and "domain_name" must be mutually exclusive'
            )

        if not tenant_id and not domain_name:
            raise ValidationError(
                '"tenant_id" or "domain_name" must be specified when using the "ldap_user" backend'
            )

    @validates_schema
    def check_refresh_token_usage(self, data, **kwargs):
        refresh_token = data.get('refresh_token')
        if not refresh_token:
            return

        client_id = data.get('client_id')
        if not client_id:
            raise ValidationError(
                '"client_id" must be specified when using a "refresh_token"'
            )
Пример #18
0
class SourceSchema(BaseSourceSchema):

    auth = fields.Nested(
        BaseAuthConfigSchema,
        missing=lambda: BaseAuthConfigSchema().load({}),
    )
    endpoint = fields.String(
        missing='https://graph.microsoft.com/v1.0/me/contacts',
        validate=Length(min=1, max=255),
    )
Пример #19
0
class AuthConfigSchema(BaseAuthConfigSchema):
    key_file = fields.String(validate=Length(min=1, max=1024), allow_none=True)
    username = fields.String(validate=Length(min=1, max=512), allow_none=True)
    password = fields.String(validate=Length(min=1, max=512), allow_none=True)

    @validates_schema
    def validate_auth_info(self, data, **kwargs):
        key_file = data.get('key_file')
        username = data.get('username')

        if key_file and username:
            raise exceptions.ValidationError(
                'a "key_file" or a "username" and "password" must be specified'
            )

        if key_file or username:
            return

        raise exceptions.ValidationError(
            'a "key_file" or a "username" and "password" must be specified')
Пример #20
0
class HTTPSubscriptionConfigSchema(Schema):
    body = fields.String(validate=Length(max=16384))
    method = fields.String(required=True, validate=Length(max=64))
    url = fields.String(required=True, validate=Length(max=8192))
    verify_certificate = fields.String(validate=Length(max=1024))
    content_type = fields.String(validate=Length(max=256))

    @pre_load
    def remove_none_values(self, config):
        optional_keys = (name for name, field in self.fields.items()
                         if not field.required)
        for optional_key in optional_keys:
            if config.get(optional_key) is None:
                config.pop(optional_key, None)
        return config

    @post_load
    def lowercase_method(self, data):
        data['method'] = data['method'].lower()
        return data

    @validates('method')
    def validate_method(self, data):
        OneOf(VALID_METHODS)(data.lower())

    @validates('verify_certificate')
    def validate_verify(self, data):
        if data in ('true', 'false'):
            pass
        elif data.startswith('/'):
            pass
        else:
            raise ValidationError({
                'message': 'Wrong value for verify_certificate',
                'constraint_id': 'verify-certificate-invalid',
                'constraint': ['true', 'false', '/*'],
            })
Пример #21
0
    def post(self):
        room_args = RoomSchema().load(request.get_json())

        if self._is_duplicate_user(room_args['users']):
            raise DuplicateUserException()

        if not self._current_user_is_in_room(token.user_uuid, room_args):
            self._add_current_user(room_args, token.user_uuid)

        try:
            Length(equal=2)(room_args['users'])
        except ValidationError as error:
            raise ValidationError({'users': error.messages})

        room_args['tenant_uuid'] = token.tenant_uuid
        room_args['users'] = [RoomUser(**user) for user in room_args['users']]
        room = Room(**room_args)

        room = self._service.create(room)
        return RoomSchema().dump(room), 201
Пример #22
0
class SubscriptionSchema(Schema):
    uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(max=128), required=True)
    service = fields.String(validate=Length(max=128),
                            allow_none=False,
                            required=True)
    events = fields.List(fields.String(validate=Length(max=128),
                                       allow_none=False),
                         allow_none=False,
                         required=True)
    events_user_uuid = fields.String(validate=Length(equal=36), missing=None)
    events_wazo_uuid = fields.String(validate=Length(equal=36), missing=None)
    config = ConfigField(allow_none=False, required=True)
    owner_user_uuid = fields.String(validate=Length(equal=36), missing=None)
    metadata = fields.Dict()
Пример #23
0
class SourceSchema(BaseSourceSchema):
    ldap_uri = fields.String(validate=Length(min=1, max=256), required=True)
    ldap_base_dn = fields.String(validate=Length(min=1, max=1024),
                                 required=True)
    ldap_username = fields.String(validate=Length(min=1), missing=None)
    ldap_password = fields.String(validate=Length(min=1), missing=None)
    ldap_custom_filter = fields.String(validate=Length(min=1, max=1024),
                                       missing=None)
    ldap_network_timeout = fields.Float(validate=Range(min=0), default=0.3)
    ldap_timeout = fields.Float(validate=Range(min=0), default=1.0)
    unique_column = fields.String(validate=Length(min=1, max=128),
                                  allow_none=True,
                                  missing=None)
    unique_column_format = fields.String(validate=OneOf(
        ['string', 'binary_uuid']),
                                         missing='string')
Пример #24
0
class SubscriptionSchema(Schema):
    class Meta:
        unknown = EXCLUDE

    uuid = fields.UUID(dump_only=True)
    name = fields.String(validate=Length(max=128), required=True)
    service = fields.String(validate=Length(max=128),
                            allow_none=False,
                            required=True)
    events = fields.List(
        fields.String(validate=Length(max=128), allow_none=False),
        allow_none=False,
        required=True,
    )
    events_user_uuid = fields.String(validate=Length(equal=36), missing=None)
    events_wazo_uuid = fields.String(validate=Length(equal=36), missing=None)
    config = ConfigField(allow_none=False, required=True)
    owner_user_uuid = fields.String(validate=Length(equal=36), missing=None)
    owner_tenant_uuid = fields.UUID(dump_only=True)
    # TODO(sileht): We should also add an events_tenant_uuid to filter
    # event on tenant_uuid. Currently if I have the
    # "webhookd.subscriptions.create" I can receive event of all tenants...
    metadata_ = fields.Dict(data_key="metadata")
Пример #25
0
class RecordingMediaDeleteRequestSchema(Schema):
    cdr_ids = fields.List(fields.Integer(), validate=Length(min=1), required=True)
Пример #26
0
class MicrosoftSchema(schemas.BaseSchema):

    scope = fields.List(fields.String(validate=Length(min=1, max=512)))
    access_token = fields.String(dump_only=True)
    token_expiration = fields.Integer(dump_only=True)
Пример #27
0
class ApplicationNodeSchema(BaseSchema):
    uuid = fields.String(dump_only=True)
    calls = fields.Nested(ApplicationNodeCallSchema,
                          many=True,
                          validate=Length(min=1),
                          required=True)
Пример #28
0
class MarketInstallOptionsSchema(Schema):

    namespace = fields.String(validate=Length(min=1), required=True)
    name = fields.String(validate=Length(min=1), required=True)
    version = fields.String()
Пример #29
0
class GitInstallOptionsSchema(Schema):

    ref = fields.String(missing='master', validate=Length(min=1))
    url = fields.String(validate=Length(min=1), required=True)
Пример #30
0
class DependencyMetadataSchema(Schema):

    namespace = fields.String(validate=Length(min=1), required=True)
    name = fields.String(validate=Length(min=1), required=True)