示例#1
0
class LineItem(ItemResource):

    fields = line_fields

    parser = reqparse.RequestParser()
    parser.add_argument('context', store_missing=False)
    parser.add_argument('provisioning_code',
                        type=DigitStr(6),
                        store_missing=False,
                        nullable=False)
    parser.add_argument('position',
                        type=inputs.positive,
                        store_missing=False,
                        nullable=False)
    parser.add_argument('caller_id_name',
                        type=Strict(unicode),
                        store_missing=False)
    parser.add_argument('caller_id_num', type=DigitStr(), store_missing=False)
    parser.add_argument('registrar', type=Strict(unicode), store_missing=False)

    @required_acl('confd.lines.{id}.read')
    def get(self, id):
        return super(LineItem, self).get(id)

    @required_acl('confd.lines.{id}.update')
    def put(self, id):
        return super(LineItem, self).put(id)

    @required_acl('confd.lines.{id}.delete')
    def delete(self, id):
        return super(LineItem, self).delete(id)
示例#2
0
class LineList(ListResource):

    model = Line

    fields = line_fields

    parser = reqparse.RequestParser()
    parser.add_argument('context', required=True)
    parser.add_argument('provisioning_code', type=DigitStr(6))
    parser.add_argument('position', type=inputs.positive, store_missing=False)
    parser.add_argument('caller_id_name',
                        type=Strict(unicode),
                        store_missing=False)
    parser.add_argument('caller_id_num', type=DigitStr(), store_missing=False)
    parser.add_argument('registrar', type=Strict(unicode), store_missing=False)

    def build_headers(self, line):
        return {'Location': url_for('lines', id=line.id, _external=True)}

    @required_acl('confd.lines.read')
    def get(self):
        return super(LineList, self).get()

    @required_acl('confd.lines.create')
    def post(self):
        return super(LineList, self).post()
示例#3
0
from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ListResource, ItemResource, \
    Strict, DigitStr
from xivo_dao.alchemy.extension import Extension

fields = {
    'id': fields.Integer,
    'exten': fields.String,
    'context': fields.String,
    'commented': fields.Boolean(attribute='legacy_commented'),
    'links': FieldList(Link('extensions'))
}

parser = reqparse.RequestParser()
parser.add_argument('exten', type=DigitStr(), store_missing=False)
parser.add_argument('context', type=Strict(unicode), store_missing=False)
parser.add_argument('commented',
                    type=Strict(bool),
                    store_missing=False,
                    dest='legacy_commented')


class ExtensionList(ListResource):

    model = Extension
    fields = fields
    parser = parser

    def build_headers(self, extension):
        return {
            'Location': url_for('extensions', id=extension.id, _external=True)
示例#4
0
        'id': fields.Integer,
        'uuid': fields.String,
        'firstname': fields.String,
        'lastname': fields.String,
        'extension': fields.String,
        'context': fields.String,
        'provisioning_code': fields.String,
        'entity': fields.String,
        'protocol': fields.String,
        'enabled': fields.Boolean,
    }
}

parser = reqparse.RequestParser()
parser.add_argument('firstname',
                    type=Strict(unicode),
                    store_missing=False,
                    nullable=False)
parser.add_argument('lastname', type=Strict(unicode), store_missing=False)
parser.add_argument('email', type=Strict(unicode), store_missing=False)
parser.add_argument('timezone', type=Strict(unicode), store_missing=False)
parser.add_argument('language', type=Strict(unicode), store_missing=False)
parser.add_argument('description', type=Strict(unicode), store_missing=False)
parser.add_argument('outgoing_caller_id',
                    type=Strict(unicode),
                    store_missing=False)
parser.add_argument('username', type=Strict(unicode), store_missing=False)
parser.add_argument('password', type=Strict(unicode), store_missing=False)
parser.add_argument('music_on_hold', type=Strict(unicode), store_missing=False)
parser.add_argument('preprocess_subroutine',
                    type=Strict(unicode),
示例#5
0
    'provisioning_extension': fields.String,
    'links': FieldList(Link('lines'), Link('lines_sip')),
}

parser = reqparse.RequestParser()
parser.add_argument('username',
                    type=inputs.regex(r"^[a-zA-Z0-9]+$"),
                    store_missing=False)
parser.add_argument('secret',
                    type=inputs.regex(r"^[a-zA-Z0-9]+$"),
                    store_missing=False)
parser.add_argument('context', required=True)
parser.add_argument('provisioning_extension',
                    type=DigitStr(6),
                    store_missing=False)
parser.add_argument('device_slot', type=Strict(int), store_missing=False)
parser.add_argument('callerid',
                    type=inputs.regex(r'"[^"]+"(\s+<[+0-9]>)?'),
                    store_missing=False)


class LineSipList(ListResource):

    model = LineSip
    fields = fields
    parser = parser

    def build_headers(self, line):
        return {'Location': url_for('lines_sip', id=line.id, _external=True)}

示例#6
0
    'ip': fields.String,
    'mac': fields.String,
    'sn': fields.String,
    'plugin': fields.String,
    'vendor': fields.String,
    'model': fields.String,
    'version': fields.String,
    'description': fields.String,
    'status': fields.String,
    'template_id': fields.String,
    'options': fields.Nested(options_fields, allow_null=True),
    'links': FieldList(Link('devices'))
}

parser = reqparse.RequestParser()
parser.add_argument('ip', type=Strict(unicode), store_missing=False)
parser.add_argument('mac', type=Strict(unicode), store_missing=False)
parser.add_argument('sn', type=Strict(unicode), store_missing=False)
parser.add_argument('plugin', type=Strict(unicode), store_missing=False)
parser.add_argument('vendor', type=Strict(unicode), store_missing=False)
parser.add_argument('model', type=Strict(unicode), store_missing=False)
parser.add_argument('version', type=Strict(unicode), store_missing=False)
parser.add_argument('description', type=Strict(unicode), store_missing=False)
parser.add_argument('template_id', type=Strict(unicode), store_missing=False)
parser.add_argument('options', type=Strict(dict), store_missing=False)


class DeviceList(ListResource):

    model = Device.from_args
    fields = fields
示例#7
0
from xivo_dao.alchemy.rightcall import RightCall as CallPermission

call_permission_fields = {
    'id': fields.Integer,
    'name': fields.String,
    'password': fields.String,
    'description': fields.String,
    'mode': fields.String,
    'enabled': fields.Boolean,
    'extensions': fields.List(fields.String),
    'links': FieldList(Link('callpermissions'))
}

parser = reqparse.RequestParser()
parser.add_argument('name',
                    type=Strict(unicode),
                    store_missing=False,
                    nullable=False)
parser.add_argument('password', type=Strict(unicode), store_missing=False)
parser.add_argument('description', type=Strict(unicode), store_missing=False)
parser.add_argument('mode',
                    type=Strict(unicode),
                    store_missing=False,
                    nullable=False)
parser.add_argument('enabled',
                    type=Strict(bool),
                    store_missing=False,
                    nullable=False)
parser.add_argument('extensions',
                    type=Strict(unicode),
                    action='append',
示例#8
0
 def test_that_strict_pass(self):
     strict = Strict(bool)
     self.assertEqual(strict(True), True)
示例#9
0
 def test_that_strict_raise_error(self):
     strict = Strict(bool)
     self.assertRaises(ValueError, strict, 'not_boolean')