Exemplo n.º 1
0
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from flask import url_for
from flask_restful import reqparse, fields

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
Exemplo n.º 2
0
    'outgoing_caller_id': fields.String,
    'mobile_phone_number': fields.String,
    'username': fields.String,
    'password': fields.String,
    'music_on_hold': fields.String,
    'preprocess_subroutine': fields.String,
    'userfield': fields.String,
    'call_transfer_enabled': fields.Boolean,
    'call_record_enabled': fields.Boolean,
    'online_call_record_enabled': fields.Boolean,
    'supervision_enabled': fields.Boolean,
    'ring_seconds': fields.Integer,
    'simultaneous_calls': fields.Integer,
    'call_permission_password': fields.String,
    'enabled': fields.Boolean,
    'links': FieldList(Link('users'))
}

view_fields = {
    'directory': {
        'id': fields.Integer,
        'uuid': fields.String,
        'line_id': fields.Integer(default=None),
        'agent_id': fields.Integer(default=None),
        'firstname': fields.String,
        'lastname': fields.String,
        'email': fields.String,
        'exten': fields.String,
        'mobile_phone_number': fields.String,
        'voicemail_number': fields.String,
        'userfield': fields.String,
Exemplo n.º 3
0
from xivo_dao.alchemy.linefeatures import LineFeatures as Line

line_fields = {
    'id': fields.Integer,
    'name': fields.String,
    'protocol': fields.String,
    'device_slot': fields.Integer,
    'device_id': fields.String,
    'context': fields.String,
    'provisioning_code': fields.String,
    'provisioning_extension': fields.String,
    'position': fields.Integer,
    'caller_id_name': fields.String,
    'caller_id_num': fields.String,
    'registrar': fields.String,
    'links': FieldList(Link('lines'))
}


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),
Exemplo n.º 4
0
from flask import url_for
from flask_restful import reqparse, inputs, fields

from xivo_confd.helpers.restful import FieldList, Link, DigitStr, \
    ListResource, ItemResource, Strict
from xivo_confd.plugins.line_sip.model import LineSip

fields = {
    'id': fields.Integer,
    'username': fields.String,
    'secret': fields.String,
    'callerid': fields.String,
    'device_slot': fields.Integer,
    'context': fields.String,
    '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',
Exemplo n.º 5
0
from flask import url_for
from flask_restful import reqparse, fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ConfdResource

fields = {
    'user_id':
    fields.Integer,
    'voicemail_id':
    fields.Integer,
    'links':
    FieldList(
        Link('voicemails',
             route='voicemails.get',
             field='voicemail_id',
             target='resource_id'), Link('users', field='user_id',
                                         target='id'))
}

parser = reqparse.RequestParser()
parser.add_argument('voicemail_id', type=int, required=True)


class UserVoicemailResource(ConfdResource):
    def __init__(self, service, user_dao, voicemail_dao):
        super(ConfdResource, self).__init__()
        self.service = service
        self.user_dao = user_dao
        self.voicemail_dao = voicemail_dao
Exemplo n.º 6
0
from flask_restful import reqparse, fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ConfdResource

fields = {
    'user_id':
    fields.Integer,
    'line_id':
    fields.Integer,
    'main_user':
    fields.Boolean,
    'main_line':
    fields.Boolean,
    'links':
    FieldList(Link('lines', field='line_id', target='id'),
              Link('users', field='user_id', target='id'))
}

parser = reqparse.RequestParser()
parser.add_argument('line_id', type=int, required=True)


class UserLineResource(ConfdResource):
    def __init__(self, service, user_dao, line_dao):
        super(UserLineResource, self).__init__()
        self.service = service
        self.user_dao = user_dao
        self.line_dao = line_dao

    def get_line_or_fail(self):
        form = parser.parse_args()
Exemplo n.º 7
0
from flask import url_for
from flask_restful import reqparse, inputs, fields

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ListResource, ItemResource, \
    option
from xivo_dao.alchemy.usersip import UserSIP as SIPEndpoint

sip_fields = {
    'id': fields.Integer,
    'username': fields.String(attribute='name'),
    'secret': fields.String,
    'type': fields.String,
    'host': fields.String,
    'options': fields.List(fields.List(fields.String)),
    'links': FieldList(Link('endpoint_sip'))
}

sip_parser = reqparse.RequestParser()
sip_parser.add_argument('username',
                        type=inputs.regex(r"^[a-zA-Z0-9]+$"),
                        dest='name',
                        store_missing=False)
sip_parser.add_argument('secret',
                        type=inputs.regex(r"^[a-zA-Z0-9]+$"),
                        store_missing=False)
sip_parser.add_argument('type',
                        choices=('friend', 'peer', 'user'),
                        store_missing=False)
sip_parser.add_argument('host', store_missing=False)
sip_parser.add_argument('options',
Exemplo n.º 8
0
}

fields = {
    'id': fields.String,
    '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)

Exemplo n.º 9
0
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from flask import url_for
from flask_restful import reqparse, fields

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ListResource, ItemResource
from xivo_dao.alchemy.usercustom import UserCustom as Custom

custom_fields = {
    'id': fields.Integer,
    'interface': fields.String,
    'enabled': fields.Boolean,
    'links': FieldList(Link('endpoint_custom'))
}


class CustomList(ListResource):

    model = Custom
    fields = custom_fields

    parser = reqparse.RequestParser()
    parser.add_argument('interface', required=True)
    parser.add_argument('enabled', type=bool, store_missing=False)

    def build_headers(self, custom):
        return {
            'Location': url_for('endpoint_custom',
Exemplo n.º 10
0
from flask_restful import marshal

from flask_restful import fields
from xivo_confd.helpers.restful import ConfdResource
from xivo_confd.helpers.restful import Link, FieldList

from xivo_confd.authentication.confd_auth import required_acl


fields = {
    'user_id': fields.Integer,
    'call_permission_id': fields.Integer,
    'links': FieldList(Link('users',
                            field='user_id',
                            target='id'),
                       Link('callpermissions',
                            field='call_permission_id',
                            target='id'))
}


class UserCallPermission(ConfdResource):

    def __init__(self, service, user_dao, call_permission_dao):
        super(UserCallPermission, self).__init__()
        self.service = service
        self.user_dao = user_dao
        self.call_permission_dao = call_permission_dao

    def get_user(self, user_id):
        return self.user_dao.get_by_id_uuid(user_id)
Exemplo n.º 11
0
from flask_restful import reqparse, fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ConfdResource

fields = {
    'user_id':
    fields.Integer,
    'enabled':
    fields.Boolean,
    'cti_profile_id':
    fields.Integer(default=None),
    'links':
    FieldList(
        Link('cti_profiles',
             route='cti_profiles.get',
             field='cti_profile_id',
             target='resource_id'), Link('users', field='user_id',
                                         target='id'))
}

parser = reqparse.RequestParser()
parser.add_argument('cti_profile_id', type=int, store_missing=False)
parser.add_argument('enabled', type=bool, store_missing=False)


class UserCtiProfileRoot(ConfdResource):
    def __init__(self, service, user_dao, cti_profile_dao):
        super(ConfdResource, self).__init__()
        self.service = service
        self.user_dao = user_dao
        self.cti_profile_dao = cti_profile_dao
Exemplo n.º 12
0
from flask_restful import marshal

from flask_restful import fields
from xivo_confd.helpers.restful import ConfdResource
from xivo_confd.helpers.restful import Link, FieldList

from xivo_confd.authentication.confd_auth import required_acl

fields = {
    'line_id':
    fields.Integer,
    'device_id':
    fields.String,
    'links':
    FieldList(Link('lines', field='line_id', target='id'),
              Link('devices', field='device_id', target='id'))
}


class LineDevice(ConfdResource):
    def __init__(self, line_dao, device_dao, service):
        super(LineDevice, self).__init__()
        self.line_dao = line_dao
        self.device_dao = device_dao
        self.service = service


class LineDeviceAssociation(LineDevice):
    @required_acl('confd.lines.{line_id}.devices.{device_id}.update')
    def put(self, line_id, device_id):
        line = self.line_dao.get(line_id)
Exemplo n.º 13
0
from flask import url_for
from flask_restful import reqparse, fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ListResource, ItemResource, Strict
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),
Exemplo n.º 14
0
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from flask_restful import fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ConfdResource


fields = {
    'user_id': fields.Integer,
    'entity_id': fields.Integer,
    'links': FieldList(Link('users',
                            field='user_id',
                            target='id'))
}


class UserEntityResource(ConfdResource):

    def __init__(self, service, user_dao):
        super(UserEntityResource, self).__init__()
        self.service = service
        self.user_dao = user_dao

    def get_user(self, user_id):
        return self.user_dao.get_by_id_uuid(user_id)

Exemplo n.º 15
0
from xivo_dao.helpers.exception import NotFoundError
from xivo_dao.helpers import errors

from flask import url_for
from flask_restful import reqparse, fields, marshal

from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import FieldList, Link, ConfdResource

fields = {
    'line_id':
    fields.Integer,
    'extension_id':
    fields.Integer,
    'links':
    FieldList(Link('lines', field='line_id', target='id'),
              Link('extensions', field='extension_id', target='id'))
}

parser = reqparse.RequestParser()
parser.add_argument('line_id', type=int, required=True, location='view_args')
parser.add_argument('extension_id', type=int, required=True)


class LineExtensionResource(ConfdResource):
    def __init__(self, service, line_dao, extension_dao):
        super(ConfdResource, self).__init__()
        self.service = service
        self.line_dao = line_dao
        self.extension_dao = extension_dao

    def get_extension_or_fail(self):
Exemplo n.º 16
0
from flask_restful import marshal

from flask_restful import fields
from xivo_confd.authentication.confd_auth import required_acl
from xivo_confd.helpers.restful import ConfdResource
from xivo_confd.helpers.restful import Link, FieldList

sccp_fields = {
    'line_id':
    fields.Integer,
    'endpoint_id':
    fields.Integer,
    'endpoint':
    fields.String,
    'links':
    FieldList(Link('lines', field='line_id', target='id'),
              Link('endpoint_sccp', field='endpoint_id', target='id'))
}

sip_fields = {
    'line_id':
    fields.Integer,
    'endpoint_id':
    fields.Integer,
    'endpoint':
    fields.String,
    'links':
    FieldList(Link('lines', field='line_id', target='id'),
              Link('endpoint_sip', field='endpoint_id', target='id'))
}

custom_fields = {