Beispiel #1
0
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)
Beispiel #2
0
def api_proc_history_get(request, appname, procname, instance):
    try:
        status_code, view_object, msg, url = ProcApi.get_proc_history(
            appname, procname, instance)
        return render_json_response(status_code, 'proc', view_object, msg, url)
    except Exception:
        return render_json_response(400, 'proc history', None, 'invalid request: should be json body with procname(detail string) instance(int)', reverse('api_docs'))
Beispiel #3
0
def api_procs_post(request, appname):
    try:
        options = json.loads(request.body)
        procname = options['procname']
    except Exception:
        return render_json_response(400, 'proc', None, 'invalid request: should be json body with procname(string)', reverse('api_docs'))
    status_code, view_object, msg, url = ProcApi.create_app_proc(appname, procname, options)
    return render_json_response(status_code, 'proc', view_object, msg, url)
Beispiel #4
0
def api_proc_history_get(request, appname, procname, instance):
    try:
        status_code, view_object, msg, url = ProcApi.get_proc_history(
            appname, procname, instance)
        return render_json_response(status_code, 'proc', view_object, msg, url)
    except Exception:
        return render_json_response(
            400, 'proc history', None,
            'invalid request: should be json body with procname(detail string) instance(int)',
            reverse('api_docs'))
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
def api_proc_get(request, appname, procname):
    status_code, view_object, msg, url = ProcApi.get_app_proc(
        appname, procname)
    return render_json_response(status_code, 'proc', view_object, msg, url)
Beispiel #8
0
def api_proc_get(request, appname, procname):
    status_code, view_object, msg, url = ProcApi.get_app_proc(
        appname, procname)
    return render_json_response(status_code, 'proc', view_object, msg, url)
Beispiel #9
0
def test_ProcApi_render_pod_data_with_value_error(pod):
    with pytest.raises(ValueError):
        ProcApi.render_pod_data(pod)
Beispiel #10
0
def test_ProcApi_render_pod_data_with_type_error(pod):
    with pytest.raises(TypeError):
        ProcApi.render_pod_data(pod)
Beispiel #11
0
def test_ProcApi_render_pod_data(pod, want):
    got = ProcApi.render_pod_data(pod)
    assert got == want