Skip to content
Permalink
Browse files
AIRAVATA-3460 Pass path as request param
  • Loading branch information
machristie committed May 14, 2021
1 parent 8b9e926 commit 54914bced9c5724e74005806aa1f798056f8090c
Showing 1 changed file with 20 additions and 21 deletions.
@@ -82,8 +82,8 @@ def save(request, path, file, name=None, content_type=None, storage_resource_id=
files = {'file': (name, file, content_type)
if content_type is not None else file, }
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
data={"path": path},
method="post",
files=files)
data = resp.json()
@@ -267,8 +267,8 @@ def dir_exists(request, path, storage_resource_id=None):
"Return True if path exists in user's data store."
if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
params={"path": path},
raise_for_status=False)
if resp.status_code == HTTPStatus.NOT_FOUND:
return False
@@ -283,8 +283,8 @@ def user_file_exists(request, path, storage_resource_id=None):
"""If file exists, return data product URI, else None."""
if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
params={"path": path},
raise_for_status=False)
if resp.status_code == HTTPStatus.NOT_FOUND or resp.json()['isDir']:
return None
@@ -304,8 +304,8 @@ def delete_dir(request, path, storage_resource_id=None):
"""Delete path in user's data store, if it exists."""
if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
data={"path": path},
method="delete",
raise_for_status=False)
_raise_404(resp, f"File path does not exist {path}")
@@ -319,8 +319,8 @@ def delete_user_file(request, path, storage_resource_id=None):
"""Delete file in user's data store, if it exists."""
if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
data={"path": path},
method="delete",
raise_for_status=False)
_raise_404(resp, f"File path does not exist {path}")
@@ -333,11 +333,10 @@ def delete_user_file(request, path, storage_resource_id=None):
def update_file_content(request, path, fileContentText, storage_resource_id=None):
if _is_remote_api():
_call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
method="put",
data={"fileContentText": fileContentText}
)
"/user-storage/~/",
data={"path": path,
"fileContentText": fileContentText},
method="put")
return
else:
backend = get_user_storage_provider(request, storage_resource_id=storage_resource_id)
@@ -363,8 +362,8 @@ def update_data_product_content(request, data_product=None, fileContentText="",
def get_file_metadata(request, path, storage_resource_id=None):
if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
params={"path": path},
raise_for_status=False
)
_raise_404(resp, "User storage file path does not exist")
@@ -481,8 +480,8 @@ def listdir(request, path, storage_resource_id=None):

if _is_remote_api():
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
params={"path": path},
)
data = resp.json()
for directory in data['directories']:
@@ -631,8 +630,8 @@ def create_user_dir(request, path="", dir_names=(), create_unique=False, storage
if _is_remote_api():
logger.debug(f"path={path}")
resp = _call_remote_api(request,
"/user-storage/~/{path}",
path_params={"path": path},
"/user-storage/~/",
data={"path": path},
method="post")
path = resp.json()['path']
# FIXME: should use the storage_resource_id returned from remote API call

0 comments on commit 54914bc

Please sign in to comment.