Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit be656a4

Browse files
authored
Merge pull request #12 from JaneliaSciComp/proxied-path-response
Wrap user proxied paths in an object instead of returning a list
2 parents 30b359e + dc4a360 commit be656a4

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

fileglancer_central/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from fastapi.exceptions import RequestValidationError, StarletteHTTPException
1212

1313
from fileglancer_central import database as db
14-
from fileglancer_central.model import FileSharePath, FileSharePathResponse, Ticket, ProxiedPath
14+
from fileglancer_central.model import FileSharePath, FileSharePathResponse, Ticket, ProxiedPath, ProxiedPathResponse
1515
from fileglancer_central.settings import get_settings
1616
from fileglancer_central.wiki import get_wiki_table, convert_table_to_file_share_paths
1717
from fileglancer_central.issues import create_jira_ticket, get_jira_ticket_details, delete_jira_ticket
@@ -247,11 +247,18 @@ async def create_proxied_path(username: str = Path(..., description="The usernam
247247
)
248248

249249

250-
@app.get("/proxied-path/{username}", response_model=List[ProxiedPath],
250+
@app.get("/proxied-path/{username}", response_model=ProxiedPathResponse,
251251
description="Retrieve all proxied paths for a user")
252252
async def get_proxied_paths(username: str = Path(..., description="The username of the user who owns the proxied paths")):
253253
with db.get_db_session() as session:
254-
return db.get_all_proxied_paths(session, username)
254+
db_proxied_paths = db.get_all_proxied_paths(session, username)
255+
proxied_paths = [ProxiedPath(
256+
username=db_proxied_path.username,
257+
sharing_key=db_proxied_path.sharing_key,
258+
sharing_name=db_proxied_path.sharing_name,
259+
mount_path=db_proxied_path.mount_path
260+
) for db_proxied_path in db_proxied_paths]
261+
return ProxiedPathResponse(paths=proxied_paths)
255262

256263

257264
@app.get("/proxied-path/{username}/{sharing_key}", response_model=ProxiedPath,

fileglancer_central/model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class UserPreference(BaseModel):
108108
description="The value of the preference"
109109
)
110110

111+
111112
class ProxiedPath(BaseModel):
112113
"""A proxied path which is used to share a file system path via a URL"""
113114
username: str = Field(
@@ -122,3 +123,9 @@ class ProxiedPath(BaseModel):
122123
mount_path: str = Field(
123124
description="The root path on the file system to be proxied"
124125
)
126+
127+
128+
class ProxiedPathResponse(BaseModel):
129+
paths: List[ProxiedPath] = Field(
130+
description="A list of proxied paths"
131+
)

tests/test_endpoints.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ def test_get_proxied_paths(test_client, temp_dir):
102102
response = test_client.get(f"/proxied-path/testuser")
103103
assert response.status_code == 200
104104
data = response.json()
105-
assert isinstance(data, list)
106-
assert len(data) > 1
105+
assert isinstance(data, dict)
106+
assert "paths" in data
107+
assert isinstance(data["paths"], list)
108+
assert len(data["paths"]) > 1
107109

108110

109111
def test_update_proxied_path(test_client, temp_dir):

0 commit comments

Comments
 (0)