Skip to content

Commit 45f9cee

Browse files
committed
initial page model
1 parent 7f8900d commit 45f9cee

File tree

3 files changed

+100
-4
lines changed
  • api/specs/web-server
  • packages/models-library/src/models_library/api_schemas_webserver
  • services/web/server/src/simcore_service_webserver/api/v0

3 files changed

+100
-4
lines changed

api/specs/web-server/_storage.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# pylint: disable=too-many-arguments
55

66

7-
from typing import TypeAlias
7+
from typing import Annotated, TypeAlias
88

9-
from fastapi import APIRouter, Query, status
9+
from _common import as_query
10+
from fastapi import APIRouter, Depends, Query, status
1011
from models_library.api_schemas_storage import (
1112
FileMetaDataGet,
1213
FileUploadCompleteFutureResponse,
@@ -16,8 +17,13 @@
1617
LinkType,
1718
PresignedLink,
1819
)
20+
from models_library.api_schemas_webserver.storage import (
21+
ListPathsQueryParams,
22+
StorageLocationPathParams,
23+
)
1924
from models_library.generics import Envelope
2025
from models_library.projects_nodes_io import LocationID
26+
from models_library.rest_pagination import Page
2127
from pydantic import AnyUrl, ByteSize
2228
from simcore_service_webserver._meta import API_VTAG
2329
from simcore_service_webserver.storage.schemas import DatasetMetaData, FileMetaData
@@ -44,12 +50,25 @@ async def list_storage_locations():
4450
"""Returns the list of available storage locations"""
4551

4652

53+
@router.get(
54+
"/storage/locations/{location_id}/paths",
55+
response_model=Page[FileMetaDataGet],
56+
)
57+
async def list_paths(
58+
_path: Annotated[StorageLocationPathParams, Depends()],
59+
_query: Annotated[as_query(ListPathsQueryParams), Depends()],
60+
):
61+
"""Lists the files/directories in WorkingDirectory"""
62+
63+
4764
@router.get(
4865
"/storage/locations/{location_id}/datasets",
4966
response_model=Envelope[list[DatasetMetaData]],
5067
summary="Get datasets metadata",
5168
)
52-
async def list_datasets_metadata(location_id: LocationID):
69+
async def list_datasets_metadata(
70+
_path: Annotated[StorageLocationPathParams, Depends()],
71+
):
5372
"""returns all the top level datasets a user has access to"""
5473

5574

@@ -59,7 +78,7 @@ async def list_datasets_metadata(location_id: LocationID):
5978
summary="Get datasets metadata",
6079
)
6180
async def get_files_metadata(
62-
location_id: LocationID,
81+
_path: Annotated[StorageLocationPathParams, Depends()],
6382
uuid_filter: str = "",
6483
expand_dirs: bool = Query(
6584
True,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pathlib import Path
2+
3+
from pydantic import BaseModel
4+
5+
from ..projects_nodes_io import LocationID
6+
from ..rest_pagination import PageQueryParameters
7+
from ._base import InputSchema
8+
9+
10+
class StorageLocationPathParams(BaseModel):
11+
location_id: LocationID
12+
13+
14+
class ListPathsQueryParams(InputSchema, PageQueryParameters):
15+
file_filter: Path | None = None

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5651,6 +5651,50 @@ paths:
56515651
$ref: '#/components/schemas/DatasetMetaData'
56525652
type: array
56535653
title: Response List Storage Locations
5654+
/v0/storage/locations/{location_id}/paths:
5655+
get:
5656+
tags:
5657+
- storage
5658+
summary: List Paths
5659+
description: Lists the files/directories in WorkingDirectory
5660+
operationId: list_paths
5661+
parameters:
5662+
- name: location_id
5663+
in: path
5664+
required: true
5665+
schema:
5666+
type: integer
5667+
title: Location Id
5668+
- name: limit
5669+
in: query
5670+
required: false
5671+
schema:
5672+
type: integer
5673+
default: 20
5674+
title: Limit
5675+
- name: offset
5676+
in: query
5677+
required: false
5678+
schema:
5679+
type: integer
5680+
default: 0
5681+
title: Offset
5682+
- name: fileFilter
5683+
in: query
5684+
required: false
5685+
schema:
5686+
anyOf:
5687+
- type: string
5688+
format: path
5689+
- type: 'null'
5690+
title: Filefilter
5691+
responses:
5692+
'200':
5693+
description: Successful Response
5694+
content:
5695+
application/json:
5696+
schema:
5697+
$ref: '#/components/schemas/Page_FileMetaDataGet_'
56545698
/v0/storage/locations/{location_id}/datasets:
56555699
get:
56565700
tags:
@@ -11379,6 +11423,24 @@ components:
1137911423
- _links
1138011424
- data
1138111425
title: Page[CatalogServiceGet]
11426+
Page_FileMetaDataGet_:
11427+
properties:
11428+
_meta:
11429+
$ref: '#/components/schemas/PageMetaInfoLimitOffset'
11430+
_links:
11431+
$ref: '#/components/schemas/PageLinks'
11432+
data:
11433+
items:
11434+
$ref: '#/components/schemas/FileMetaDataGet'
11435+
type: array
11436+
title: Data
11437+
additionalProperties: false
11438+
type: object
11439+
required:
11440+
- _meta
11441+
- _links
11442+
- data
11443+
title: Page[FileMetaDataGet]
1138211444
Page_LicensedItemPurchaseGet_:
1138311445
properties:
1138411446
_meta:

0 commit comments

Comments
 (0)