def api_proc_high_permit(request, appname, procname): if request.method == 'DELETE': status_code, view_object, msg, url = ProcApi.delete_app_proc(appname, procname) return render_json_response(status_code, 'proc', view_object, msg, url) elif request.method == 'PATCH': try: options = json.loads(request.body) except Exception: return render_json_response(400, 'proc', None, 'invalid request: should be json body with num_instances(integer) or cpu(integer) or memory(str)', reverse('api_docs')) status_code, view_object, msg, url = ProcApi.update_app_proc(appname, procname, options) return render_json_response(status_code, 'proc', view_object, msg, url)
def api_proc_high_permit(request, appname, procname): if request.method == 'DELETE': status_code, view_object, msg, url = ProcApi.delete_app_proc( appname, procname) return render_json_response(status_code, 'proc', view_object, msg, url) elif request.method == 'PATCH': try: options = json.loads(request.body) operation = options.get('operation', 'schedule') access_token = request.META.get('HTTP_ACCESS_TOKEN', 'unknown') if operation == 'schedule': status_code, view_object, msg, url = ProcApi.update_app_proc( access_token, appname, procname, options) else: status_code, view_object, msg, url = ProcApi.operate_proc( appname, procname, operation, options) except Exception: return render_json_response(400, 'proc', None, 'invalid request: should be json body with num_instances(integer) or cpu(integer) or memory(str)', reverse('api_docs')) return render_json_response(status_code, 'proc', view_object, msg, url)
def api_proc_high_permit(request, appname, procname): if request.method == 'DELETE': status_code, view_object, msg, url = ProcApi.delete_app_proc( appname, procname) return render_json_response(status_code, 'proc', view_object, msg, url) elif request.method == 'PATCH': try: options = json.loads(request.body) operation = options.get('operation', 'schedule') access_token = request.META.get('HTTP_ACCESS_TOKEN', 'unknown') if operation == 'schedule': status_code, view_object, msg, url = ProcApi.update_app_proc( access_token, appname, procname, options) else: status_code, view_object, msg, url = ProcApi.operate_proc( appname, procname, operation, options) except Exception: return render_json_response( 400, 'proc', None, 'invalid request: should be json body with num_instances(integer) or cpu(integer) or memory(str)', reverse('api_docs')) return render_json_response(status_code, 'proc', view_object, msg, url)