from xivo_restapi.helpers import serializer from xivo_restapi.helpers.common import extract_search_parameters from xivo_restapi.helpers.formatter import Formatter from xivo_restapi.resources.extensions.routes import extension_route as route from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int, Unicode, Boolean logger = logging.getLogger(__name__) formatter = Formatter(mapper, serializer, Extension) extra_parameters = ['type'] document = content_parser.document( Field('id', Int()), Field('exten', Unicode()), Field('context', Unicode()), Field('commented', Boolean()) ) @route('') def list(): parameters = extract_search_parameters(request.args, extra_parameters) search_result = extension_services.search(**parameters) result = formatter.list_to_api(search_result.items, search_result.total) return make_response(result, 200) @route('/<int:extensionid>') def get(extensionid): extension = extension_services.get(extensionid)
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from xivo_restapi.resources.users.routes import route from xivo_restapi.resources.user_cti_profile.formatter import UserCtiProfileFormatter from flask.globals import request from xivo_dao.data_handler.user_cti_profile import services as user_cti_profile_services from flask.helpers import make_response from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int, Boolean formatter = UserCtiProfileFormatter() document = content_parser.document( Field('user_id', Int()), Field('cti_profile_id', Int()), Field('enabled', Boolean()) ) @route('/<int:userid>/cti', methods=['PUT']) def edit_cti_configuration(userid): data = document.parse(request) model = formatter.dict_to_model(data, userid) user_cti_profile_services.edit(model) return make_response('', 204) @route('/<int:userid>/cti', methods=['GET']) def get_cti_configuration(userid):
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # 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 request, url_for, make_response from . import actions from xivo_restapi.resources.lines.routes import line_blueprint, line_route from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int document = content_parser.document(Field('line_id', Int()), Field('extension_id', Int())) @line_route('/<int:lineid>/extensions') def list_extensions(lineid): response = actions.list_extensions(lineid) return make_response(response, 200) @line_route('/<int:lineid>/extensions', methods=['POST']) def associate_line_extension(lineid): parameters = document.parse(request) response = actions.associate_extension(lineid, parameters) location = url_for('.list_extensions', lineid=lineid) return make_response(response, 201, {'Location': location})
from xivo_restapi.helpers.request_bouncer import limit_to_localhost from xivo_dao.data_handler.device.model import Device from xivo_dao.data_handler.device import services as device_services from xivo_dao.data_handler.line import services as line_services from xivo_restapi.helpers.common import extract_search_parameters from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Unicode document = content_parser.document( Field('id', Unicode()), Field('ip', Unicode()), Field('mac', Unicode()), Field('sn', Unicode()), Field('plugin', Unicode()), Field('vendor', Unicode()), Field('model', Unicode()), Field('version', Unicode()), Field('description', Unicode()), Field('status', Unicode()), Field('template_id', Unicode()) ) logger = logging.getLogger(__name__) blueprint = Blueprint('devices', __name__, url_prefix='/%s/devices' % config.VERSION_1_1) route = RouteGenerator(blueprint) formatter = Formatter(mapper, serializer, Device) @route('/<deviceid>')
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> from xivo_restapi.resources.configuration.routes import blueprint from xivo_restapi.helpers.route_generator import RouteGenerator from xivo_restapi.helpers import serializer from xivo_dao.data_handler.configuration import services from flask.helpers import make_response from flask.globals import request from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Boolean route = RouteGenerator(blueprint) document = content_parser.document(Field('enabled', Boolean())) @route('/live_reload', methods=['GET']) def get_live_reload(): result = services.get_live_reload_status() return make_response(serializer.encode(result), 200) @route('/live_reload', methods=['PUT']) def set_live_reload(): data = document.parse(request) services.set_live_reload_status(data) return make_response('', 204)
# GNU General Public License for more details. # # 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 request, url_for, make_response from . import actions from xivo_restapi.resources.lines.routes import line_blueprint, line_route from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int document = content_parser.document( Field('line_id', Int()), Field('extension_id', Int()) ) @line_route('/<int:lineid>/extensions') def list_extensions(lineid): response = actions.list_extensions(lineid) return make_response(response, 200) @line_route('/<int:lineid>/extensions', methods=['POST']) def associate_line_extension(lineid): parameters = document.parse(request) response = actions.associate_extension(lineid, parameters) location = url_for('.list_extensions', lineid=lineid) return make_response(response, 201, {'Location': location})
from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Unicode, Int, Boolean logger = logging.getLogger(__name__) blueprint = Blueprint('voicemails', __name__, url_prefix='/%s/voicemails' % config.VERSION_1_1) route = RouteGenerator(blueprint) formatter = Formatter(mapper, serializer, Voicemail) document = content_parser.document( Field('id', Int()), Field('name', Unicode()), Field('number', Unicode()), Field('context', Unicode()), Field('password', Unicode()), Field('email', Unicode()), Field('language', Unicode()), Field('timezone', Unicode()), Field('max_messages', Int()), Field('attach_audio', Boolean()), Field('delete_messages', Boolean()), Field('ask_password', Boolean()) ) @route('') def list(): search_parameters = extract_search_parameters(request.args) search_result = voicemail_services.search(**search_parameters) result = formatter.list_to_api(search_result.items, search_result.total) return make_response(result, 200)
from xivo_restapi.helpers.formatter import Formatter from xivo_restapi.helpers.request_bouncer import limit_to_localhost from xivo_dao.data_handler.device.model import Device from xivo_dao.data_handler.device import services as device_services from xivo_dao.data_handler.line import services as line_services from xivo_restapi.helpers.common import extract_search_parameters from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Unicode document = content_parser.document(Field('id', Unicode()), Field('ip', Unicode()), Field('mac', Unicode()), Field('sn', Unicode()), Field('plugin', Unicode()), Field('vendor', Unicode()), Field('model', Unicode()), Field('version', Unicode()), Field('description', Unicode()), Field('status', Unicode()), Field('template_id', Unicode())) logger = logging.getLogger(__name__) blueprint = Blueprint('devices', __name__, url_prefix='/%s/devices' % config.VERSION_1_1) route = RouteGenerator(blueprint) formatter = Formatter(mapper, serializer, Device) @route('/<deviceid>')
from xivo_restapi.resources.users.routes import route from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Unicode, Int logger = logging.getLogger(__name__) formatter = Formatter(mapper, serializer, User) document = content_parser.document( Field('id', Int()), Field('firstname', Unicode()), Field('lastname', Unicode()), Field('caller_id', Unicode()), Field('outgoing_caller_id', Unicode()), Field('username', Unicode()), Field('password', Unicode()), Field('music_on_hold', Unicode()), Field('mobile_phone_number', Unicode()), Field('userfield', Unicode()), Field('timezone', Unicode()), Field('language', Unicode()), Field('description', Unicode()), Field('preprocess_subroutine', Unicode()), ) @route('') def list(): if 'q' in request.args: items = user_services.find_all_by_fullname(request.args['q']) total = len(items) else:
from xivo_dao.data_handler.exception import AssociationNotExistsError from xivo_dao.data_handler.user_line.exception import UserLineNotExistsError from xivo_dao.data_handler.user_line import services as user_line_services from xivo_dao.data_handler.user import services as user_services from xivo_restapi.resources.users.routes import route from xivo_restapi.resources.user_line.formatter import UserLineFormatter from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int formatter = UserLineFormatter() document = content_parser.document( Field('user_id', Int()), Field('line_id', Int()) ) @route('/<int:userid>/lines', methods=['POST']) def associate_line(userid): data = document.parse(request) model = formatter.dict_to_model(data, userid) created_model = user_line_services.associate(model) result = formatter.to_api(created_model) location = url_for('.associate_line', userid=userid) return make_response(result, 201, {'Location': location}) @route('/<int:userid>/lines/<int:lineid>', methods=['DELETE'])
from xivo_restapi.helpers.formatter import Formatter from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int, Unicode logger = logging.getLogger(__name__) blueprint = Blueprint('lines_sip', __name__, url_prefix='/%s/lines_sip' % config.VERSION_1_1) route = RouteGenerator(blueprint) formatter = Formatter(mapper_sip, serializer, LineSIP) document = content_parser.document( Field('id', Int()), Field('username', Unicode()), Field('secret', Unicode()), Field('callerid', Unicode()), Field('provisioning_extension', Unicode()), Field('device_slot', Int()), Field('context', Unicode()), ) @route('') def list_sip(): lines = line_services.find_all_by_protocol('sip') result = formatter.list_to_api(lines) return make_response(result, 200) @route('/<int:lineid>') def get(lineid):
from xivo_dao.data_handler.exception import AssociationNotExistsError from xivo_dao.data_handler.user_voicemail.exception import UserVoicemailNotExistsError from xivo_dao.data_handler.user_voicemail import services as user_voicemail_services from xivo_restapi.resources.users.routes import route from xivo_restapi.resources.user_voicemail.formatter import UserVoicemailFormatter from xivo_restapi.flask_http_server import content_parser from xivo_restapi.helpers.premacop import Field, Int, Boolean formatter = UserVoicemailFormatter() document = content_parser.document( Field('user_id', Int()), Field('voicemail_id', Int()), Field('enabled', Boolean()) ) @route('/<int:userid>/voicemail', methods=['POST']) def associate_voicemail(userid): data = document.parse(request) model = formatter.dict_to_model(data, userid) created_model = user_voicemail_services.associate(model) result = formatter.to_api(created_model) location = url_for('.associate_voicemail', userid=userid) return make_response(result, 201, {'Location': location})