def rest__save_script_in_storage(request, script_id=None, get_from_params=False): if get_from_params: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__USER, REQUEST_PARAM_NAME__SCRIPT_ID]) script_id = request_params[REQUEST_PARAM_NAME__SCRIPT_ID] else: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__USER]) curr_user = request_params[REQUEST_PARAM_NAME__USER] script_body = request.body ScriptUtils.get_storage_manager().update_script_in_storage(script_id, script_body, curr_user) return http_ok_response()
def rest__list_script_history(request, script_id=None, get_from_params=False): if get_from_params: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__SCRIPT_ID]) script_id = request_params[REQUEST_PARAM_NAME__SCRIPT_ID] scripts_history_json_array = ScriptUtils.get_storage_manager().get_script_history_json(script_id) return create_http_json_response(scripts_history_json_array)
def rest__create_new_script(request, get_from_params=False): request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__USER, REQUEST_PARAM_NAME__STORAGE_FILENAME]) curr_user = request_params[REQUEST_PARAM_NAME__USER] storage_filename = request_params[REQUEST_PARAM_NAME__STORAGE_FILENAME] new_script_json = ScriptUtils.get_storage_manager().create_script_in_repo(curr_user, storage_filename) return create_http_json_response(new_script_json)
def rest__get_script_of_revision(request, script_id=None, revision=None, get_from_params=False): if get_from_params: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__SCRIPT_ID, REQUEST_PARAM_NAME__SCRIPT_REVISION]) script_id = request_params[REQUEST_PARAM_NAME__SCRIPT_ID] revision = request_params[REQUEST_PARAM_NAME__SCRIPT_REVISION] scripts_json = ScriptUtils.get_storage_manager().get_script_revision(script_id, revision) return create_http_json_response(scripts_json)
def rest__fork_script_of_revision(request, script_id=None, revision=None, get_from_params=False): if get_from_params: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__USER, REQUEST_PARAM_NAME__SCRIPT_ID, REQUEST_PARAM_NAME__SCRIPT_REVISION, REQUEST_PARAM_NAME__STORAGE_FILENAME]) script_id = request_params[REQUEST_PARAM_NAME__SCRIPT_ID] revision = request_params[REQUEST_PARAM_NAME__SCRIPT_REVISION] else: request_params = process_request_params(request.GET, [REQUEST_PARAM_NAME__USER, REQUEST_PARAM_NAME__STORAGE_FILENAME]) user_name = request_params[REQUEST_PARAM_NAME__USER] storage_filename = request_params[REQUEST_PARAM_NAME__STORAGE_FILENAME] scripts_json = ScriptUtils.get_storage_manager().fork_script_of_revision(script_id, revision, user_name, storage_filename) return create_http_json_response(scripts_json)
def rest__list_storage_scripts(request, get_from_params=False): scripts_json_array = ScriptUtils.get_storage_manager().get_scripts_in_storage_json() return create_http_json_response(scripts_json_array)