From 6ba06b1020c965722d869047dd44e6ae4bdcbf1b Mon Sep 17 00:00:00 2001 From: andrewelamb Date: Thu, 2 Nov 2023 13:08:09 -0700 Subject: [PATCH] feat(schematic): refactor storage endpoints (#2274) * refactored endpoints * refactored endpoints * change asset type decription --- .devcontainer/devcontainer.json | 1 + .../controllers/storage_controller.py | 64 ++-- .../controllers/storage_controller_impl.py | 124 ++++---- .../api/schematic_api/openapi/openapi.yaml | 286 +++++++++--------- .../test/test_storage_controller_endpoints.py | 104 ++++--- .../test/test_storage_controller_impl.py | 72 ++--- .../api-description/build/openapi.yaml | 61 ++-- .../src/components/schemas/AssetType.yaml | 2 +- .../api-description/src/openapi.yaml | 16 +- .../datasets/@{datasetId}/files.yaml | 30 -- .../datasets/@{datasetId}/manifestJson.yaml | 27 -- .../assetViews/@{assetViewId}/projects.yaml | 2 +- .../projects/@{projectId}/datasets.yaml | 27 -- .../projects/@{projectId}/manifests.yaml | 27 -- .../datasets/@{datasetId}/files.yaml | 30 ++ .../datasets/@{datasetId}/manifestJson.yaml | 28 ++ .../projects/@{projectId}/datasets.yaml | 28 ++ .../projects/@{projectId}/manifests.yaml | 28 ++ 18 files changed, 499 insertions(+), 458 deletions(-) delete mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/files.yaml delete mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/manifestJson.yaml delete mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/datasets.yaml delete mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/manifests.yaml create mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/files.yaml create mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/manifestJson.yaml create mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/datasets.yaml create mode 100644 libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/manifests.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ba7b709167..58188dcb02 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -51,6 +51,7 @@ "mtxr.sqltools-driver-mysql", "mtxr.sqltools-driver-pg", "mtxr.sqltools", + "njpwerner.autodocstring", "nrwl.angular-console", "pranaygp.vscode-css-peek", "ritwickdey.LiveServer", diff --git a/apps/schematic/api/schematic_api/controllers/storage_controller.py b/apps/schematic/api/schematic_api/controllers/storage_controller.py index c5d3c77274..3398efc611 100644 --- a/apps/schematic/api/schematic_api/controllers/storage_controller.py +++ b/apps/schematic/api/schematic_api/controllers/storage_controller.py @@ -32,7 +32,7 @@ def get_asset_view_json(asset_view_id, asset_type): # noqa: E501 def get_dataset_files( - dataset_id, asset_view_id, asset_type, file_names=None, use_full_file_path=None + dataset_id, asset_type, asset_view_id, file_names=None, use_full_file_path=None ): # noqa: E501 """Gets all files associated with a dataset. @@ -40,10 +40,10 @@ def get_dataset_files( :param dataset_id: The ID of a dataset. :type dataset_id: str - :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - :type asset_view_id: str :param asset_type: Type of asset, such as Synapse :type asset_type: dict | bytes + :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project + :type asset_view_id: str :param file_names: A list of file names used to filter the output. :type file_names: List[str] :param use_full_file_path: Whether or not to return the full path of output, or just the basename. @@ -54,28 +54,28 @@ def get_dataset_files( if connexion.request.is_json: asset_type = AssetType.from_dict(connexion.request.get_json()) # noqa: E501 return storage_controller_impl.get_dataset_files( - dataset_id, asset_view_id, asset_type, file_names, use_full_file_path + dataset_id, asset_type, asset_view_id, file_names, use_full_file_path ) -def get_dataset_manifest_json(asset_type, asset_view_id, dataset_id): # noqa: E501 +def get_dataset_manifest_json(asset_type, dataset_id, asset_view_id): # noqa: E501 """Gets the manifest in json form Gets the manifest in json form # noqa: E501 :param asset_type: Type of asset, such as Synapse :type asset_type: dict | bytes - :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - :type asset_view_id: str :param dataset_id: The ID of a dataset. :type dataset_id: str + :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project + :type asset_view_id: str :rtype: Union[object, Tuple[object, int], Tuple[object, int, Dict[str, str]] """ if connexion.request.is_json: asset_type = AssetType.from_dict(connexion.request.get_json()) # noqa: E501 return storage_controller_impl.get_dataset_manifest_json( - asset_type, asset_view_id, dataset_id + asset_type, dataset_id, asset_view_id ) @@ -96,60 +96,60 @@ def get_manifest_json(asset_type, manifest_id): # noqa: E501 return storage_controller_impl.get_manifest_json(asset_type, manifest_id) -def list_projects(asset_view_id, asset_type): # noqa: E501 - """Gets all storage projects the current user has access to. +def get_project_datasets(project_id, asset_type, asset_view_id): # noqa: E501 + """Gets all datasets in folder under a given storage project that the current user has access to. - Gets all storage projects the current user has access to. # noqa: E501 + Gets all datasets in folder under a given storage project that the current user has access to. # noqa: E501 - :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - :type asset_view_id: str + :param project_id: The Synapse ID of a storage project. + :type project_id: str :param asset_type: Type of asset, such as Synapse :type asset_type: dict | bytes + :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project + :type asset_view_id: str - :rtype: Union[ProjectsPage, Tuple[ProjectsPage, int], Tuple[ProjectsPage, int, Dict[str, str]] + :rtype: Union[DatasetsPage, Tuple[DatasetsPage, int], Tuple[DatasetsPage, int, Dict[str, str]] """ if connexion.request.is_json: asset_type = AssetType.from_dict(connexion.request.get_json()) # noqa: E501 - return storage_controller_impl.list_projects(asset_view_id, asset_type) + return storage_controller_impl.get_project_datasets( + project_id, asset_type, asset_view_id + ) -def list_storage_project_datasets(project_id, asset_view_id, asset_type): # noqa: E501 - """Gets all datasets in folder under a given storage project that the current user has access to. +def get_project_manifests(project_id, asset_type, asset_view_id): # noqa: E501 + """Gets all manifests in a project folder that users have access to - Gets all datasets in folder under a given storage project that the current user has access to. # noqa: E501 + Gets all manifests in a project folder that the current user has access to. # noqa: E501 :param project_id: The Synapse ID of a storage project. :type project_id: str - :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - :type asset_view_id: str :param asset_type: Type of asset, such as Synapse :type asset_type: dict | bytes + :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project + :type asset_view_id: str - :rtype: Union[DatasetsPage, Tuple[DatasetsPage, int], Tuple[DatasetsPage, int, Dict[str, str]] + :rtype: Union[ManifestsPage, Tuple[ManifestsPage, int], Tuple[ManifestsPage, int, Dict[str, str]] """ if connexion.request.is_json: asset_type = AssetType.from_dict(connexion.request.get_json()) # noqa: E501 - return storage_controller_impl.list_storage_project_datasets( - project_id, asset_view_id, asset_type + return storage_controller_impl.get_project_manifests( + project_id, asset_type, asset_view_id ) -def list_storage_project_manifests(project_id, asset_view_id, asset_type): # noqa: E501 - """Gets all manifests in a project folder that users have access to +def get_projects(asset_view_id, asset_type): # noqa: E501 + """Gets all storage projects the current user has access to. - Gets all manifests in a project folder that the current user has access to. # noqa: E501 + Gets all storage projects the current user has access to. # noqa: E501 - :param project_id: The Synapse ID of a storage project. - :type project_id: str :param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project :type asset_view_id: str :param asset_type: Type of asset, such as Synapse :type asset_type: dict | bytes - :rtype: Union[ManifestsPage, Tuple[ManifestsPage, int], Tuple[ManifestsPage, int, Dict[str, str]] + :rtype: Union[ProjectsPage, Tuple[ProjectsPage, int], Tuple[ProjectsPage, int, Dict[str, str]] """ if connexion.request.is_json: asset_type = AssetType.from_dict(connexion.request.get_json()) # noqa: E501 - return storage_controller_impl.list_storage_project_manifests( - project_id, asset_view_id, asset_type - ) + return storage_controller_impl.get_projects(asset_view_id, asset_type) diff --git a/apps/schematic/api/schematic_api/controllers/storage_controller_impl.py b/apps/schematic/api/schematic_api/controllers/storage_controller_impl.py index e7142e7f9f..cf81d8e48d 100644 --- a/apps/schematic/api/schematic_api/controllers/storage_controller_impl.py +++ b/apps/schematic/api/schematic_api/controllers/storage_controller_impl.py @@ -106,8 +106,8 @@ def get_dataset_files_from_schematic( @handle_exceptions def get_dataset_files( dataset_id: str, - asset_view_id: str, asset_type: str, + asset_view_id: str, file_names: Optional[list[str]] = None, use_full_file_path: bool = False, ) -> tuple[Union[FilesPage, BasicError], int]: @@ -186,7 +186,9 @@ def get_dataset_manifest_from_schematic( @handle_exceptions def get_dataset_manifest_json( - asset_type: str, asset_view_id: str, dataset_id: str + asset_type: str, + dataset_id: str, + asset_view_id: str, ) -> tuple[Union[str, BasicError], int]: """Gets a manifest in json form @@ -253,57 +255,9 @@ def get_manifest_json( return result, status -def get_projects(asset_type: str) -> list[tuple[str, str]]: - """Gets a list of projects - - Args: - asset_type (str): The type of asset, ie "synapse" - - Returns: - list[tuple(str, str)]: A list of projects in tuple form - """ - access_token = get_access_token() - asset_type_object = get_asset_storage_class(asset_type) - store = asset_type_object(access_token=access_token) - return store.getStorageProjects() - - -@handle_exceptions -def list_projects( - asset_view_id: str, asset_type: str -) -> tuple[Union[ProjectsPage, BasicError], int]: - """Attempts to get a list of projects the user has access to - - Args: - asset_view_id (str): The id for the asset view of the project - asset_type (str): The type of asset, ie "synapse" - - Returns: - tuple[Union[ProjectsPage, BasicError], int]: A tuple - The first item is either the projects or an error object - The second item is the response status - """ - - CONFIG.synapse_master_fileview_id = asset_view_id - project_tuples = get_projects(asset_type) - projects = [Project(id=item[0], name=item[1]) for item in project_tuples] - - page = ProjectsPage( - number=0, - size=100, - total_elements=len(projects), - total_pages=1, - has_next=False, - has_previous=False, - projects=projects, - ) - result: Union[ProjectsPage, BasicError] = page - status = 200 - - return result, status - - -def get_project_datasets(project_id: str, asset_type: str) -> list[tuple[str, str]]: +def get_project_datasets_from_schematic( + project_id: str, asset_type: str +) -> list[tuple[str, str]]: """Gets a list of datasets from the project Args: @@ -320,8 +274,8 @@ def get_project_datasets(project_id: str, asset_type: str) -> list[tuple[str, st @handle_exceptions -def list_storage_project_datasets( - project_id: str, asset_view_id: str, asset_type: str +def get_project_datasets( + project_id: str, asset_type: str, asset_view_id: str ) -> tuple[Union[DatasetsPage, BasicError], int]: """Attempts to get a list of datasets from a Synapse project @@ -337,7 +291,7 @@ def list_storage_project_datasets( """ CONFIG.synapse_master_fileview_id = asset_view_id - dataset_tuples = get_project_datasets(project_id, asset_type) + dataset_tuples = get_project_datasets_from_schematic(project_id, asset_type) datasets = [Dataset(id=item[0], name=item[1]) for item in dataset_tuples] page = DatasetsPage( @@ -355,7 +309,7 @@ def list_storage_project_datasets( return result, status -def get_project_manifests( +def get_project_manifests_from_schematic( project_id: str, asset_type: str ) -> list[tuple[tuple[str, str], tuple[str, str], tuple[str, str]]]: """Gets a list of manifests from the project @@ -374,8 +328,8 @@ def get_project_manifests( @handle_exceptions -def list_storage_project_manifests( - project_id: str, asset_view_id: str, asset_type: str +def get_project_manifests( + project_id: str, asset_type: str, asset_view_id: str ) -> tuple[Union[ManifestsPage, BasicError], int]: """Attempts to get a list of manifests from a Synapse project @@ -391,7 +345,7 @@ def list_storage_project_manifests( """ # load config CONFIG.synapse_master_fileview_id = asset_view_id - project_manifests = get_project_manifests(project_id, asset_type) + project_manifests = get_project_manifests_from_schematic(project_id, asset_type) manifests = [ Manifest( name=item[1][1], @@ -416,3 +370,53 @@ def list_storage_project_manifests( status = 200 return result, status + + +def get_projects_from_schematic(asset_type: str) -> list[tuple[str, str]]: + """Gets a list of projects + + Args: + asset_type (str): The type of asset, ie "synapse" + + Returns: + list[tuple(str, str)]: A list of projects in tuple form + """ + access_token = get_access_token() + asset_type_object = get_asset_storage_class(asset_type) + store = asset_type_object(access_token=access_token) + return store.getStorageProjects() + + +@handle_exceptions +def get_projects( + asset_view_id: str, asset_type: str +) -> tuple[Union[ProjectsPage, BasicError], int]: + """Attempts to get a list of projects the user has access to + + Args: + asset_view_id (str): The id for the asset view of the project + asset_type (str): The type of asset, ie "synapse" + + Returns: + tuple[Union[ProjectsPage, BasicError], int]: A tuple + The first item is either the projects or an error object + The second item is the response status + """ + + CONFIG.synapse_master_fileview_id = asset_view_id + project_tuples = get_projects_from_schematic(asset_type) + projects = [Project(id=item[0], name=item[1]) for item in project_tuples] + + page = ProjectsPage( + number=0, + size=100, + total_elements=len(projects), + total_pages=1, + has_next=False, + has_previous=False, + projects=projects, + ) + result: Union[ProjectsPage, BasicError] = page + status = 200 + + return result, status diff --git a/apps/schematic/api/schematic_api/openapi/openapi.yaml b/apps/schematic/api/schematic_api/openapi/openapi.yaml index ae16e21267..b86c236194 100644 --- a/apps/schematic/api/schematic_api/openapi/openapi.yaml +++ b/apps/schematic/api/schematic_api/openapi/openapi.yaml @@ -18,19 +18,11 @@ tags: - description: Operations about storages. name: Storage paths: - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/files: + /assetTypes/{assetType}/assetViews/{assetViewId}/json: get: - description: Gets all files associated with a dataset. - operationId: get_dataset_files + description: Gets the asset view table in json form + operationId: get_asset_view_json parameters: - - description: The ID of a dataset. - explode: false - in: path - name: datasetId - required: true - schema: - $ref: '#/components/schemas/DatasetId' - style: simple - description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project @@ -49,29 +41,12 @@ paths: schema: $ref: '#/components/schemas/AssetType' style: simple - - description: A list of file names used to filter the output. - explode: true - in: query - name: fileNames - required: false - schema: - $ref: '#/components/schemas/FileNames' - style: form - - description: "Whether or not to return the full path of output, or just the\ - \ basename." - explode: true - in: query - name: useFullFilePath - required: false - schema: - $ref: '#/components/schemas/UseFullFilePath' - style: form responses: "200": content: application/json: schema: - $ref: '#/components/schemas/FilesPage' + $ref: '#/components/schemas/AssetViewJson' description: Success "400": content: @@ -104,23 +79,15 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets all files associated with a dataset. + summary: Gets the asset view table in json form tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/manifestJson: + /assetTypes/{assetType}/assetViews/{assetViewId}/projects: get: - description: Gets the manifest in json form - operationId: get_dataset_manifest_json + description: Gets all storage projects the current user has access to. + operationId: get_projects parameters: - - description: "Type of asset, such as Synapse" - explode: false - in: path - name: assetType - required: true - schema: - $ref: '#/components/schemas/AssetType' - style: simple - description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project @@ -131,20 +98,20 @@ paths: schema: $ref: '#/components/schemas/AssetViewId' style: simple - - description: The ID of a dataset. + - description: "Type of asset, such as Synapse" explode: false in: path - name: datasetId + name: assetType required: true schema: - $ref: '#/components/schemas/DatasetId' + $ref: '#/components/schemas/AssetType' style: simple responses: "200": content: application/json: schema: - $ref: '#/components/schemas/ManifestJson' + $ref: '#/components/schemas/ProjectsPage' description: Success "400": content: @@ -177,24 +144,22 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets the manifest in json form + summary: Gets all storage projects the current user has access to. tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/assetViews/{assetViewId}/json: + /assetTypes/{assetType}/datasets/{datasetId}/files: get: - description: Gets the asset view table in json form - operationId: get_asset_view_json + description: Gets all files associated with a dataset. + operationId: get_dataset_files parameters: - - description: ID of view listing all project data assets. E.g. for Synapse - this would be the Synapse ID of the fileview listing all data assets for - a given project + - description: The ID of a dataset. explode: false in: path - name: assetViewId + name: datasetId required: true schema: - $ref: '#/components/schemas/AssetViewId' + $ref: '#/components/schemas/DatasetId' style: simple - description: "Type of asset, such as Synapse" explode: false @@ -204,12 +169,39 @@ paths: schema: $ref: '#/components/schemas/AssetType' style: simple + - description: A list of file names used to filter the output. + explode: true + in: query + name: fileNames + required: false + schema: + $ref: '#/components/schemas/FileNames' + style: form + - description: "Whether or not to return the full path of output, or just the\ + \ basename." + explode: true + in: query + name: useFullFilePath + required: false + schema: + $ref: '#/components/schemas/UseFullFilePath' + style: form + - description: ID of view listing all project data assets. E.g. for Synapse + this would be the Synapse ID of the fileview listing all data assets for + a given project + explode: true + in: query + name: assetViewId + required: true + schema: + $ref: '#/components/schemas/AssetViewId' + style: form responses: "200": content: application/json: schema: - $ref: '#/components/schemas/AssetViewJson' + $ref: '#/components/schemas/FilesPage' description: Success "400": content: @@ -242,39 +234,47 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets the asset view table in json form + summary: Gets all files associated with a dataset. tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/assetViews/{assetViewId}/projects: + /assetTypes/{assetType}/datasets/{datasetId}/manifestJson: get: - description: Gets all storage projects the current user has access to. - operationId: list_projects + description: Gets the manifest in json form + operationId: get_dataset_manifest_json parameters: - - description: ID of view listing all project data assets. E.g. for Synapse - this would be the Synapse ID of the fileview listing all data assets for - a given project + - description: "Type of asset, such as Synapse" explode: false in: path - name: assetViewId + name: assetType required: true schema: - $ref: '#/components/schemas/AssetViewId' + $ref: '#/components/schemas/AssetType' style: simple - - description: "Type of asset, such as Synapse" + - description: The ID of a dataset. explode: false in: path - name: assetType + name: datasetId required: true schema: - $ref: '#/components/schemas/AssetType' + $ref: '#/components/schemas/DatasetId' style: simple + - description: ID of view listing all project data assets. E.g. for Synapse + this would be the Synapse ID of the fileview listing all data assets for + a given project + explode: true + in: query + name: assetViewId + required: true + schema: + $ref: '#/components/schemas/AssetViewId' + style: form responses: "200": content: application/json: schema: - $ref: '#/components/schemas/ProjectsPage' + $ref: '#/components/schemas/ManifestJson' description: Success "400": content: @@ -307,48 +307,37 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets all storage projects the current user has access to. + summary: Gets the manifest in json form tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/datasets: + /assetTypes/{assetType}/manifests/{manifestId}/json: get: - description: Gets all datasets in folder under a given storage project that - the current user has access to. - operationId: list_storage_project_datasets + description: Gets the manifest in json form + operationId: get_manifest_json parameters: - - description: The Synapse ID of a storage project. - explode: false - in: path - name: projectId - required: true - schema: - $ref: '#/components/schemas/ProjectId' - style: simple - - description: ID of view listing all project data assets. E.g. for Synapse - this would be the Synapse ID of the fileview listing all data assets for - a given project + - description: "Type of asset, such as Synapse" explode: false in: path - name: assetViewId + name: assetType required: true schema: - $ref: '#/components/schemas/AssetViewId' + $ref: '#/components/schemas/AssetType' style: simple - - description: "Type of asset, such as Synapse" + - description: ID of a manifest explode: false in: path - name: assetType + name: manifestId required: true schema: - $ref: '#/components/schemas/AssetType' + $ref: '#/components/schemas/ManifestId' style: simple responses: "200": content: application/json: schema: - $ref: '#/components/schemas/DatasetsPage' + $ref: '#/components/schemas/ManifestJson' description: Success "400": content: @@ -381,16 +370,15 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets all datasets in folder under a given storage project that the - current user has access to. + summary: Gets the manifest in json form tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/manifests: + /assetTypes/{assetType}/projects/{projectId}/datasets: get: - description: Gets all manifests in a project folder that the current user has - access to. - operationId: list_storage_project_manifests + description: Gets all datasets in folder under a given storage project that + the current user has access to. + operationId: get_project_datasets parameters: - description: The Synapse ID of a storage project. explode: false @@ -400,16 +388,6 @@ paths: schema: $ref: '#/components/schemas/ProjectId' style: simple - - description: ID of view listing all project data assets. E.g. for Synapse - this would be the Synapse ID of the fileview listing all data assets for - a given project - explode: false - in: path - name: assetViewId - required: true - schema: - $ref: '#/components/schemas/AssetViewId' - style: simple - description: "Type of asset, such as Synapse" explode: false in: path @@ -418,12 +396,22 @@ paths: schema: $ref: '#/components/schemas/AssetType' style: simple + - description: ID of view listing all project data assets. E.g. for Synapse + this would be the Synapse ID of the fileview listing all data assets for + a given project + explode: true + in: query + name: assetViewId + required: true + schema: + $ref: '#/components/schemas/AssetViewId' + style: form responses: "200": content: application/json: schema: - $ref: '#/components/schemas/ManifestsPage' + $ref: '#/components/schemas/DatasetsPage' description: Success "400": content: @@ -456,37 +444,49 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets all manifests in a project folder that users have access to + summary: Gets all datasets in folder under a given storage project that the + current user has access to. tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller - /assetTypes/{assetType}/manifests/{manifestId}/json: + /assetTypes/{assetType}/projects/{projectId}/manifests: get: - description: Gets the manifest in json form - operationId: get_manifest_json + description: Gets all manifests in a project folder that the current user has + access to. + operationId: get_project_manifests parameters: - - description: "Type of asset, such as Synapse" + - description: The Synapse ID of a storage project. explode: false in: path - name: assetType + name: projectId required: true schema: - $ref: '#/components/schemas/AssetType' + $ref: '#/components/schemas/ProjectId' style: simple - - description: ID of a manifest + - description: "Type of asset, such as Synapse" explode: false in: path - name: manifestId + name: assetType required: true schema: - $ref: '#/components/schemas/ManifestId' + $ref: '#/components/schemas/AssetType' style: simple + - description: ID of view listing all project data assets. E.g. for Synapse + this would be the Synapse ID of the fileview listing all data assets for + a given project + explode: true + in: query + name: assetViewId + required: true + schema: + $ref: '#/components/schemas/AssetViewId' + style: form responses: "200": content: application/json: schema: - $ref: '#/components/schemas/ManifestJson' + $ref: '#/components/schemas/ManifestsPage' description: Success "400": content: @@ -519,7 +519,7 @@ paths: $ref: '#/components/schemas/BasicError' description: The request cannot be fulfilled due to an unexpected server error - summary: Gets the manifest in json form + summary: Gets all manifests in a project folder that users have access to tags: - Storage x-openapi-router-controller: schematic_api.controllers.storage_controller @@ -1382,25 +1382,36 @@ components: schema: $ref: '#/components/schemas/ProjectId' style: simple - assetViewId: + assetType: + description: "Type of asset, such as Synapse" + explode: false + in: path + name: assetType + required: true + schema: + $ref: '#/components/schemas/AssetType' + style: simple + assetViewIdQuery: description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - explode: false - in: path + explode: true + in: query name: assetViewId required: true schema: $ref: '#/components/schemas/AssetViewId' - style: simple - assetType: - description: "Type of asset, such as Synapse" + style: form + assetViewId: + description: ID of view listing all project data assets. E.g. for Synapse this + would be the Synapse ID of the fileview listing all data assets for a given + project explode: false in: path - name: assetType + name: assetViewId required: true schema: - $ref: '#/components/schemas/AssetType' + $ref: '#/components/schemas/AssetViewId' style: simple datasetId: description: The ID of a dataset. @@ -1595,17 +1606,6 @@ components: default: false type: boolean style: form - assetViewIdQuery: - description: ID of view listing all project data assets. E.g. for Synapse this - would be the Synapse ID of the fileview listing all data assets for a given - project - explode: true - in: query - name: assetViewId - required: true - schema: - $ref: '#/components/schemas/AssetViewId' - style: form tableManipulationMethod: description: "replace will remove the rows and columns from the existing table\ \ and store the new rows and columns, preserving the name and synID. upsert\ @@ -1716,17 +1716,17 @@ components: description: A project ID. example: syn26251192 type: string - AssetViewId: - description: An asset view ID. - example: syn23643253 - type: string AssetType: - description: A type of asset. + description: "Type of asset store, such as Synapse" enum: - synapse example: synapse title: AssetType type: string + AssetViewId: + description: An asset view ID. + example: syn23643253 + type: string PageMetadata: description: The metadata of a page. properties: diff --git a/apps/schematic/api/schematic_api/test/test_storage_controller_endpoints.py b/apps/schematic/api/schematic_api/test/test_storage_controller_endpoints.py index 20a7a70cea..83997b9621 100644 --- a/apps/schematic/api/schematic_api/test/test_storage_controller_endpoints.py +++ b/apps/schematic/api/schematic_api/test/test_storage_controller_endpoints.py @@ -17,14 +17,18 @@ } ASSET_VIEW_JSON_URL = "/api/v1/assetTypes/synapse/assetViews/syn1/json" -FILES_URL = "/api/v1/assetTypes/synapse/assetViews/syn1/datasets/syn2/files" -MANIFEST_JSON_URL = "/api/v1/assetTypes/synapse/manifests/syn1/json" +DATASET_FILES_URL = "/api/v1/assetTypes/synapse/datasets/syn2/files?assetViewId=syn1" DATASET_MANIFEST_JSON_URL = ( - "/api/v1/assetTypes/synapse/assetViews/syn1/datasets/syn2/manifestJson" + "/api/v1/assetTypes/synapse/datasets/syn2/manifestJson?assetViewId=syn1" ) +MANIFEST_JSON_URL = "/api/v1/assetTypes/synapse/manifests/syn1/json" PROJECTS_URL = "/api/v1/assetTypes/synapse/assetViews/syn1/projects" -DATASETS_URL = "/api/v1/assetTypes/synapse/assetViews/syn1/projects/syn2/datasets" -MANIFESTS_URL = "/api/v1/assetTypes/synapse/assetViews/syn1/projects/syn2/manifests" +PROJECT_DATASETS_URL = ( + "/api/v1/assetTypes/synapse/projects/syn2/datasets?assetViewId=syn1" +) +PROJECT_MANIFESTS_URL = ( + "/api/v1/assetTypes/synapse/projects/syn2/manifests?assetViewId=syn1" +) class TestGetAssetViewJson(BaseTestCase): @@ -100,7 +104,9 @@ def test_success(self) -> None: "get_dataset_files_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ): - response = self.client.open(FILES_URL, method="GET", headers=HEADERS) + response = self.client.open( + DATASET_FILES_URL, method="GET", headers=HEADERS + ) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -126,20 +132,22 @@ def test_file_names(self) -> None: "get_dataset_files_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ) as mock_function: - response = self.client.open(FILES_URL, method="GET", headers=HEADERS) + response = self.client.open( + DATASET_FILES_URL, method="GET", headers=HEADERS + ) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) mock_function.assert_called_with("syn2", "synapse", None, False) - url = f"{FILES_URL}?fileNames=file.text" + url = f"{DATASET_FILES_URL}&fileNames=file.text" response = self.client.open(url, method="GET", headers=HEADERS) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) mock_function.assert_called_with("syn2", "synapse", ["file.text"], False) - url = f"{FILES_URL}?fileNames=file.text&fileNames=file2.text" + url = f"{DATASET_FILES_URL}&fileNames=file.text&fileNames=file2.text" response = self.client.open(url, method="GET", headers=HEADERS) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" @@ -156,14 +164,14 @@ def test_use_full_file_path(self) -> None: "get_dataset_files_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ) as mock_function: - url = f"{FILES_URL}?useFullFilePath=true" + url = f"{DATASET_FILES_URL}&useFullFilePath=true" response = self.client.open(url, method="GET", headers=HEADERS) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) mock_function.assert_called_with("syn2", "synapse", None, True) - url = f"{FILES_URL}?useFullFilePath=false" + url = f"{DATASET_FILES_URL}&useFullFilePath=false" response = self.client.open(url, method="GET", headers=HEADERS) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" @@ -177,7 +185,9 @@ def test_401(self) -> None: "get_dataset_files_from_schematic", side_effect=SynapseNoCredentialsError, ): - response = self.client.open(FILES_URL, method="GET", headers=HEADERS) + response = self.client.open( + DATASET_FILES_URL, method="GET", headers=HEADERS + ) self.assert401( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -189,7 +199,9 @@ def test_403(self) -> None: "get_dataset_files_from_schematic", side_effect=AccessCredentialsError("project"), ): - response = self.client.open(FILES_URL, method="GET", headers=HEADERS) + response = self.client.open( + DATASET_FILES_URL, method="GET", headers=HEADERS + ) self.assert403( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -201,7 +213,9 @@ def test_500(self) -> None: "get_dataset_files_from_schematic", side_effect=TypeError, ): - response = self.client.open(FILES_URL, method="GET", headers=HEADERS) + response = self.client.open( + DATASET_FILES_URL, method="GET", headers=HEADERS + ) self.assert500( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -331,7 +345,7 @@ def test_500(self) -> None: ) -class TestProjects(BaseTestCase): +class TestGetProjects(BaseTestCase): """Test case for projects endpoint""" def test_success(self) -> None: @@ -339,7 +353,7 @@ def test_success(self) -> None: with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ): response = self.client.open(PROJECTS_URL, method="GET", headers=HEADERS) @@ -364,7 +378,7 @@ def test_401(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=SynapseNoCredentialsError, ): response = self.client.open(PROJECTS_URL, method="GET", headers=HEADERS) @@ -376,7 +390,7 @@ def test_403(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=AccessCredentialsError("project"), ): response = self.client.open(PROJECTS_URL, method="GET", headers=HEADERS) @@ -388,7 +402,7 @@ def test_500(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=TypeError, ): response = self.client.open(PROJECTS_URL, method="GET", headers=HEADERS) @@ -397,7 +411,7 @@ def test_500(self) -> None: ) -class TestDatasets(BaseTestCase): +class TestGetProjectDatasets(BaseTestCase): """Test case for datasets endpoint""" def test_success(self) -> None: @@ -405,10 +419,12 @@ def test_success(self) -> None: with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ): - response = self.client.open(DATASETS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_DATASETS_URL, method="GET", headers=HEADERS + ) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -430,10 +446,12 @@ def test_401(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=SynapseNoCredentialsError, ): - response = self.client.open(DATASETS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_DATASETS_URL, method="GET", headers=HEADERS + ) self.assert401( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -442,10 +460,12 @@ def test_403(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=AccessCredentialsError("project"), ): - response = self.client.open(DATASETS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_DATASETS_URL, method="GET", headers=HEADERS + ) self.assert403( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -454,16 +474,18 @@ def test_500(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=TypeError, ): - response = self.client.open(DATASETS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_DATASETS_URL, method="GET", headers=HEADERS + ) self.assert500( response, f"Response body is : {response.data.decode('utf-8')}" ) -class TestManifests(BaseTestCase): +class TestGetProjectManifests(BaseTestCase): """Test case for manifests endpoint""" def test_success(self) -> None: @@ -471,10 +493,12 @@ def test_success(self) -> None: with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", return_value=EXAMPLE_MANIFEST_METADATA, ): - response = self.client.open(MANIFESTS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_MANIFESTS_URL, method="GET", headers=HEADERS + ) self.assert200( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -505,10 +529,12 @@ def test_401(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=SynapseNoCredentialsError, ): - response = self.client.open(MANIFESTS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_MANIFESTS_URL, method="GET", headers=HEADERS + ) self.assert401( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -517,10 +543,12 @@ def test_403(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=AccessCredentialsError("project"), ): - response = self.client.open(MANIFESTS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_MANIFESTS_URL, method="GET", headers=HEADERS + ) self.assert403( response, f"Response body is : {response.data.decode('utf-8')}" ) @@ -529,10 +557,12 @@ def test_500(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=TypeError, ): - response = self.client.open(MANIFESTS_URL, method="GET", headers=HEADERS) + response = self.client.open( + PROJECT_MANIFESTS_URL, method="GET", headers=HEADERS + ) self.assert500( response, f"Response body is : {response.data.decode('utf-8')}" ) diff --git a/apps/schematic/api/schematic_api/test/test_storage_controller_impl.py b/apps/schematic/api/schematic_api/test/test_storage_controller_impl.py index 638182990f..de8d5bf78e 100644 --- a/apps/schematic/api/schematic_api/test/test_storage_controller_impl.py +++ b/apps/schematic/api/schematic_api/test/test_storage_controller_impl.py @@ -20,9 +20,9 @@ get_manifest_json, get_asset_view_json, get_dataset_files, - list_projects, - list_storage_project_datasets, - list_storage_project_manifests, + get_projects, + get_project_datasets, + get_project_manifests, ) @@ -292,17 +292,17 @@ def test_internal_error(self) -> None: assert isinstance(result, BasicError) -class TestListProjects: +class TestGetProjects: """Test case for list_projects""" def test_success(self) -> None: """Test for successful result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ): - result, status = list_projects(asset_view_id="syn1", asset_type="synapse") + result, status = get_projects(asset_view_id="syn1", asset_type="synapse") assert status == 200 assert isinstance(result, ProjectsPage) @@ -310,10 +310,10 @@ def test_no_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=SynapseNoCredentialsError, ): - result, status = list_projects(asset_view_id="syn1", asset_type="synapse") + result, status = get_projects(asset_view_id="syn1", asset_type="synapse") assert status == 401 assert isinstance(result, BasicError) @@ -321,10 +321,10 @@ def test_bad_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=SynapseAuthenticationError, ): - result, status = list_projects(asset_view_id="syn1", asset_type="synapse") + result, status = get_projects(asset_view_id="syn1", asset_type="synapse") assert status == 401 assert isinstance(result, BasicError) @@ -332,10 +332,10 @@ def test_no_access_error(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=AccessCredentialsError("project"), ): - result, status = list_projects(asset_view_id="syn1", asset_type="synapse") + result, status = get_projects(asset_view_id="syn1", asset_type="synapse") assert status == 403 assert isinstance(result, BasicError) @@ -343,25 +343,25 @@ def test_internal_error(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_projects", + "get_projects_from_schematic", side_effect=TypeError, ): - result, status = list_projects(asset_view_id="syn1", asset_type="synapse") + result, status = get_projects(asset_view_id="syn1", asset_type="synapse") assert status == 500 assert isinstance(result, BasicError) -class TestListStorageProjectDatasets: +class TestGetProjectDatasets: """Test case for list_storage_project_datasets""" def test_success(self) -> None: """Test for successful result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", return_value=[("syn1", "name1"), ("syn2", "name2")], ): - result, status = list_storage_project_datasets( + result, status = get_project_datasets( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 200 @@ -371,10 +371,10 @@ def test_no_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=SynapseNoCredentialsError, ): - result, status = list_storage_project_datasets( + result, status = get_project_datasets( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 401 @@ -384,10 +384,10 @@ def test_bad_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=SynapseAuthenticationError, ): - result, status = list_storage_project_datasets( + result, status = get_project_datasets( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 401 @@ -397,10 +397,10 @@ def test_no_access_error(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=AccessCredentialsError("project"), ): - result, status = list_storage_project_datasets( + result, status = get_project_datasets( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 403 @@ -410,27 +410,27 @@ def test_internal_error(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_datasets", + "get_project_datasets_from_schematic", side_effect=TypeError, ): - result, status = list_storage_project_datasets( + result, status = get_project_datasets( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 500 assert isinstance(result, BasicError) -class TestListStorageProjectManifests: +class TestGetProjectManifests: """Test case for list_storage_project_manifests""" def test_success(self, example_manifest_metadata: list) -> None: """Test for successful result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", return_value=example_manifest_metadata, ): - result, status = list_storage_project_manifests( + result, status = get_project_manifests( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 200 @@ -440,10 +440,10 @@ def test_no_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=SynapseNoCredentialsError, ): - result, status = list_storage_project_manifests( + result, status = get_project_manifests( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 401 @@ -453,10 +453,10 @@ def test_bad_credentials_error(self) -> None: """Test for 401 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=SynapseAuthenticationError, ): - result, status = list_storage_project_manifests( + result, status = get_project_manifests( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 401 @@ -466,10 +466,10 @@ def test_no_access_error(self) -> None: """Test for 403 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=AccessCredentialsError("project"), ): - result, status = list_storage_project_manifests( + result, status = get_project_manifests( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 403 @@ -479,10 +479,10 @@ def test_internal_error(self) -> None: """Test for 500 result""" with patch.object( schematic_api.controllers.storage_controller_impl, - "get_project_manifests", + "get_project_manifests_from_schematic", side_effect=TypeError, ): - result, status = list_storage_project_manifests( + result, status = get_project_manifests( project_id="syn1", asset_view_id="syn2", asset_type="synapse" ) assert status == 500 diff --git a/libs/schematic/api-description/build/openapi.yaml b/libs/schematic/api-description/build/openapi.yaml index 25599c5096..84bfe1770f 100644 --- a/libs/schematic/api-description/build/openapi.yaml +++ b/libs/schematic/api-description/build/openapi.yaml @@ -35,17 +35,18 @@ paths: example: v21.1.1 '500': $ref: '#/components/responses/InternalServerError' - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/datasets: + /assetTypes/{assetType}/projects/{projectId}/datasets: parameters: - $ref: '#/components/parameters/projectId' - - $ref: '#/components/parameters/assetViewId' - $ref: '#/components/parameters/assetType' get: tags: - Storage summary: Gets all datasets in folder under a given storage project that the current user has access to. description: Gets all datasets in folder under a given storage project that the current user has access to. - operationId: listStorageProjectDatasets + operationId: getProjectDatasets + parameters: + - $ref: '#/components/parameters/assetViewIdQuery' responses: '200': description: Success @@ -63,17 +64,18 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalServerError' - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/manifests: + /assetTypes/{assetType}/projects/{projectId}/manifests: parameters: - $ref: '#/components/parameters/projectId' - - $ref: '#/components/parameters/assetViewId' - $ref: '#/components/parameters/assetType' get: tags: - Storage summary: Gets all manifests in a project folder that users have access to description: Gets all manifests in a project folder that the current user has access to. - operationId: listStorageProjectManifests + operationId: getProjectManifests + parameters: + - $ref: '#/components/parameters/assetViewIdQuery' responses: '200': description: Success @@ -118,10 +120,9 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalServerError' - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/manifestJson: + /assetTypes/{assetType}/datasets/{datasetId}/manifestJson: parameters: - $ref: '#/components/parameters/assetType' - - $ref: '#/components/parameters/assetViewId' - $ref: '#/components/parameters/datasetId' get: tags: @@ -129,6 +130,8 @@ paths: summary: Gets the manifest in json form description: Gets the manifest in json form operationId: getDatasetManifestJson + parameters: + - $ref: '#/components/parameters/assetViewIdQuery' responses: '200': description: Success @@ -155,7 +158,7 @@ paths: - Storage summary: Gets all storage projects the current user has access to. description: Gets all storage projects the current user has access to. - operationId: listProjects + operationId: getProjects responses: '200': description: Success @@ -173,10 +176,9 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalServerError' - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/files: + /assetTypes/{assetType}/datasets/{datasetId}/files: parameters: - $ref: '#/components/parameters/datasetId' - - $ref: '#/components/parameters/assetViewId' - $ref: '#/components/parameters/assetType' get: tags: @@ -187,6 +189,7 @@ paths: parameters: - $ref: '#/components/parameters/fileNames' - $ref: '#/components/parameters/useFullFilePath' + - $ref: '#/components/parameters/assetViewIdQuery' responses: '200': description: Success @@ -586,16 +589,16 @@ components: description: A project ID. type: string example: syn26251192 - AssetViewId: - description: An asset view ID. - type: string - example: syn23643253 AssetType: - description: A type of asset. + description: Type of asset store, such as Synapse type: string example: synapse enum: - synapse + AssetViewId: + description: An asset view ID. + type: string + example: syn23643253 PageMetadata: type: object description: The metadata of a page. @@ -1008,20 +1011,27 @@ components: required: true schema: $ref: '#/components/schemas/ProjectId' - assetViewId: - name: assetViewId + assetType: + name: assetType in: path + description: Type of asset, such as Synapse + required: true + schema: + $ref: '#/components/schemas/AssetType' + assetViewIdQuery: + name: assetViewId + in: query description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project required: true schema: $ref: '#/components/schemas/AssetViewId' - assetType: - name: assetType + assetViewId: + name: assetViewId in: path - description: Type of asset, such as Synapse + description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project required: true schema: - $ref: '#/components/schemas/AssetType' + $ref: '#/components/schemas/AssetViewId' datasetId: name: datasetId in: path @@ -1162,13 +1172,6 @@ components: schema: type: boolean default: false - assetViewIdQuery: - name: assetViewId - in: query - description: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project - required: true - schema: - $ref: '#/components/schemas/AssetViewId' tableManipulationMethod: name: tableManipulationMethod in: query diff --git a/libs/schematic/api-description/src/components/schemas/AssetType.yaml b/libs/schematic/api-description/src/components/schemas/AssetType.yaml index dcdf56f7fb..acb70e2c33 100644 --- a/libs/schematic/api-description/src/components/schemas/AssetType.yaml +++ b/libs/schematic/api-description/src/components/schemas/AssetType.yaml @@ -1,4 +1,4 @@ -description: A type of asset. +description: 'Type of asset store, such as Synapse' type: string example: synapse enum: [synapse] diff --git a/libs/schematic/api-description/src/openapi.yaml b/libs/schematic/api-description/src/openapi.yaml index 7a326668f8..30d891e592 100644 --- a/libs/schematic/api-description/src/openapi.yaml +++ b/libs/schematic/api-description/src/openapi.yaml @@ -28,23 +28,23 @@ paths: /schematicVersion: $ref: paths/schematicVersion.yaml - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/datasets: - $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/datasets.yaml + /assetTypes/{assetType}/projects/{projectId}/datasets: + $ref: paths/assetTypes/@{assetType}/projects/@{projectId}/datasets.yaml - /assetTypes/{assetType}/assetViews/{assetViewId}/projects/{projectId}/manifests: - $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/manifests.yaml + /assetTypes/{assetType}/projects/{projectId}/manifests: + $ref: paths/assetTypes/@{assetType}/projects/@{projectId}/manifests.yaml /assetTypes/{assetType}/assetViews/{assetViewId}/json: $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/json.yaml - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/manifestJson: - $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/manifestJson.yaml + /assetTypes/{assetType}/datasets/{datasetId}/manifestJson: + $ref: paths/assetTypes/@{assetType}/datasets/@{datasetId}/manifestJson.yaml /assetTypes/{assetType}/assetViews/{assetViewId}/projects: $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects.yaml - /assetTypes/{assetType}/assetViews/{assetViewId}/datasets/{datasetId}/files: - $ref: paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/files.yaml + /assetTypes/{assetType}/datasets/{datasetId}/files: + $ref: paths/assetTypes/@{assetType}/datasets/@{datasetId}/files.yaml /assetTypes/{assetType}/manifests/{manifestId}/json: $ref: paths/assetTypes/@{assetType}/manifests/@{manifestId}/json.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/files.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/files.yaml deleted file mode 100644 index edc1aac911..0000000000 --- a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/files.yaml +++ /dev/null @@ -1,30 +0,0 @@ -parameters: - - $ref: ../../../../../../../components/parameters/path/datasetId.yaml - - $ref: ../../../../../../../components/parameters/path/assetViewId.yaml - - $ref: ../../../../../../../components/parameters/path/assetType.yaml -get: - tags: - - Storage - summary: Gets all files associated with a dataset. - description: Gets all files associated with a dataset. - operationId: getDatasetFiles - parameters: - - $ref: ../../../../../../../components/parameters/query/fileNames.yaml - - $ref: ../../../../../../../components/parameters/query/useFullFilePath.yaml - responses: - '200': - description: Success - content: - application/json: - schema: - $ref: ../../../../../../../components/schemas/FilesPage.yaml - '400': - $ref: ../../../../../../../components/responses/BadRequest.yaml - '401': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '403': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '404': - $ref: ../../../../../../../components/responses/NotFound.yaml - '500': - $ref: ../../../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/manifestJson.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/manifestJson.yaml deleted file mode 100644 index 2b9377c317..0000000000 --- a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/datasets/@{datasetId}/manifestJson.yaml +++ /dev/null @@ -1,27 +0,0 @@ -parameters: - - $ref: ../../../../../../../components/parameters/path/assetType.yaml - - $ref: ../../../../../../../components/parameters/path/assetViewId.yaml - - $ref: ../../../../../../../components/parameters/path/datasetId.yaml -get: - tags: - - Storage - summary: Gets the manifest in json form - description: Gets the manifest in json form - operationId: getDatasetManifestJson - responses: - '200': - description: Success - content: - application/json: - schema: - $ref: ../../../../../../../components/schemas/ManifestJson.yaml - '400': - $ref: ../../../../../../../components/responses/BadRequest.yaml - '401': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '403': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '404': - $ref: ../../../../../../../components/responses/NotFound.yaml - '500': - $ref: ../../../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects.yaml index c05bf6da7e..ab0e549e71 100644 --- a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects.yaml +++ b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects.yaml @@ -6,7 +6,7 @@ get: - Storage summary: Gets all storage projects the current user has access to. description: Gets all storage projects the current user has access to. - operationId: listProjects + operationId: getProjects responses: '200': description: Success diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/datasets.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/datasets.yaml deleted file mode 100644 index 57aeca54ed..0000000000 --- a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/datasets.yaml +++ /dev/null @@ -1,27 +0,0 @@ -parameters: - - $ref: ../../../../../../../components/parameters/path/projectId.yaml - - $ref: ../../../../../../../components/parameters/path/assetViewId.yaml - - $ref: ../../../../../../../components/parameters/path/assetType.yaml -get: - tags: - - Storage - summary: Gets all datasets in folder under a given storage project that the current user has access to. - description: Gets all datasets in folder under a given storage project that the current user has access to. - operationId: listStorageProjectDatasets - responses: - '200': - description: Success - content: - application/json: - schema: - $ref: ../../../../../../../components/schemas/DatasetsPage.yaml - '400': - $ref: ../../../../../../../components/responses/BadRequest.yaml - '401': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '403': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '404': - $ref: ../../../../../../../components/responses/NotFound.yaml - '500': - $ref: ../../../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/manifests.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/manifests.yaml deleted file mode 100644 index db8cf4b33b..0000000000 --- a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/assetViews/@{assetViewId}/projects/@{projectId}/manifests.yaml +++ /dev/null @@ -1,27 +0,0 @@ -parameters: - - $ref: ../../../../../../../components/parameters/path/projectId.yaml - - $ref: ../../../../../../../components/parameters/path/assetViewId.yaml - - $ref: ../../../../../../../components/parameters/path/assetType.yaml -get: - tags: - - Storage - summary: Gets all manifests in a project folder that users have access to - description: Gets all manifests in a project folder that the current user has access to. - operationId: listStorageProjectManifests - responses: - '200': - description: Success - content: - application/json: - schema: - $ref: ../../../../../../../components/schemas/ManifestsPage.yaml - '400': - $ref: ../../../../../../../components/responses/BadRequest.yaml - '401': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '403': - $ref: ../../../../../../../components/responses/Unauthorized.yaml - '404': - $ref: ../../../../../../../components/responses/NotFound.yaml - '500': - $ref: ../../../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/files.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/files.yaml new file mode 100644 index 0000000000..51e9e9429c --- /dev/null +++ b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/files.yaml @@ -0,0 +1,30 @@ +parameters: + - $ref: ../../../../../components/parameters/path/datasetId.yaml + - $ref: ../../../../../components/parameters/path/assetType.yaml +get: + tags: + - Storage + summary: Gets all files associated with a dataset. + description: Gets all files associated with a dataset. + operationId: getDatasetFiles + parameters: + - $ref: ../../../../../components/parameters/query/fileNames.yaml + - $ref: ../../../../../components/parameters/query/useFullFilePath.yaml + - $ref: ../../../../../components/parameters/query/assetViewIdQuery.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../../../components/schemas/FilesPage.yaml + '400': + $ref: ../../../../../components/responses/BadRequest.yaml + '401': + $ref: ../../../../../components/responses/Unauthorized.yaml + '403': + $ref: ../../../../../components/responses/Unauthorized.yaml + '404': + $ref: ../../../../../components/responses/NotFound.yaml + '500': + $ref: ../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/manifestJson.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/manifestJson.yaml new file mode 100644 index 0000000000..f793b23246 --- /dev/null +++ b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/datasets/@{datasetId}/manifestJson.yaml @@ -0,0 +1,28 @@ +parameters: + - $ref: ../../../../../components/parameters/path/assetType.yaml + - $ref: ../../../../../components/parameters/path/datasetId.yaml +get: + tags: + - Storage + summary: Gets the manifest in json form + description: Gets the manifest in json form + operationId: getDatasetManifestJson + parameters: + - $ref: ../../../../../components/parameters/query/assetViewIdQuery.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../../../components/schemas/ManifestJson.yaml + '400': + $ref: ../../../../../components/responses/BadRequest.yaml + '401': + $ref: ../../../../../components/responses/Unauthorized.yaml + '403': + $ref: ../../../../../components/responses/Unauthorized.yaml + '404': + $ref: ../../../../../components/responses/NotFound.yaml + '500': + $ref: ../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/datasets.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/datasets.yaml new file mode 100644 index 0000000000..43db86f25d --- /dev/null +++ b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/datasets.yaml @@ -0,0 +1,28 @@ +parameters: + - $ref: ../../../../../components/parameters/path/projectId.yaml + - $ref: ../../../../../components/parameters/path/assetType.yaml +get: + tags: + - Storage + summary: Gets all datasets in folder under a given storage project that the current user has access to. + description: Gets all datasets in folder under a given storage project that the current user has access to. + operationId: getProjectDatasets + parameters: + - $ref: ../../../../../components/parameters/query/assetViewIdQuery.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../../../components/schemas/DatasetsPage.yaml + '400': + $ref: ../../../../../components/responses/BadRequest.yaml + '401': + $ref: ../../../../../components/responses/Unauthorized.yaml + '403': + $ref: ../../../../../components/responses/Unauthorized.yaml + '404': + $ref: ../../../../../components/responses/NotFound.yaml + '500': + $ref: ../../../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/manifests.yaml b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/manifests.yaml new file mode 100644 index 0000000000..4254ae9442 --- /dev/null +++ b/libs/schematic/api-description/src/paths/assetTypes/@{assetType}/projects/@{projectId}/manifests.yaml @@ -0,0 +1,28 @@ +parameters: + - $ref: ../../../../../components/parameters/path/projectId.yaml + - $ref: ../../../../../components/parameters/path/assetType.yaml +get: + tags: + - Storage + summary: Gets all manifests in a project folder that users have access to + description: Gets all manifests in a project folder that the current user has access to. + operationId: getProjectManifests + parameters: + - $ref: ../../../../../components/parameters/query/assetViewIdQuery.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../../../components/schemas/ManifestsPage.yaml + '400': + $ref: ../../../../../components/responses/BadRequest.yaml + '401': + $ref: ../../../../../components/responses/Unauthorized.yaml + '403': + $ref: ../../../../../components/responses/Unauthorized.yaml + '404': + $ref: ../../../../../components/responses/NotFound.yaml + '500': + $ref: ../../../../../components/responses/InternalServerError.yaml