def get_mq_handler(name): try: api = init_dpapi(request.args) mq_handler = api.mq_handler.get(name) return jsonify(mq_handler) except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def get_http_handlers(): try: api = init_dpapi(request.args) http_handlers = api.http_handler.get_all() return jsonify(http_handlers) except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def create_load_balncer_group(): try: api = init_dpapi(request.args) lbg_req = request.get_json(force=True) create_lbg(lbg_req, api) return success_response("Load Balancer Group {} was created successfully".format(lbg_req["name"])) except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def create_http_handler(): try: json_data = request.get_json(force=True) api = init_dpapi(request.args) handler = api.http_handler.create_from_dict(json_data["name"], fields=json_data) return success_response('HTTP Handler "' + handler["name"] + '" was created') except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def create_mpgw_from_template(): try: api = init_dpapi(request.args) req = request.get_json(force=True) mpgw = populate_mpgw_template(req, api) xml_manager_name = create_xml_manager(mpgw["name"], api) policy = create_style_policy(mpgw["rules"], mpgw["name"], api=api) api.mpgw.create(mpgw["name"], mpgw["handlers"], xml_manager_name, policy["name"], state="enabled", UserSummary=str(req)) return success_response('MultiProtocolGateway "' + mpgw["name"] + '" was created') except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def create_mq_handler(): try: json_data = request.get_json(force=True) handlers = [] api = init_dpapi(request.args) if isinstance(json_data, list): for handler_obj in json_data: api.mq_handler.create_from_dict(handler_obj["name"], fields=handler_obj) handlers.append(handler_obj["name"]) else: api.mq_handler.create_from_dict(json_data["name"], fields=json_data) return success_response('MQ Handler "' + json_data["name"] + '" was created') return success_response('MQ Handlers ' + str(handlers).strip('[]') + ' were created') except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)
def get_mqqm(): try: api = init_dpapi(request.args) return jsonify([qm["name"] for qm in api.mqqm.get_all()]) except exceptions.ApiError as e: raise exceptions.ApiError(e.message, e.status_code)