From 27dd87ee8635921b6831ba3e4a649ffae0336e82 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 10 Jan 2024 08:06:19 +0100 Subject: [PATCH] Mark public methods that don't use trans as public in schema --- .redocly.lint-ignore.yaml | 25 ------------------- lib/galaxy/webapps/galaxy/api/authenticate.py | 1 + .../webapps/galaxy/api/configuration.py | 1 + lib/galaxy/webapps/galaxy/api/datatypes.py | 9 +++++++ .../galaxy/api/display_applications.py | 1 + lib/galaxy/webapps/galaxy/api/drs.py | 11 ++++---- lib/galaxy/webapps/galaxy/api/licenses.py | 6 ++++- .../webapps/galaxy/api/short_term_storage.py | 1 + lib/galaxy/webapps/galaxy/api/tasks.py | 1 + lib/galaxy/webapps/galaxy/api/tool_data.py | 2 +- .../galaxy/api/tool_shed_repositories.py | 2 ++ lib/galaxy/webapps/galaxy/api/tours.py | 4 +-- 12 files changed, 30 insertions(+), 34 deletions(-) diff --git a/.redocly.lint-ignore.yaml b/.redocly.lint-ignore.yaml index ebc5c08edc6..3d24e44b03d 100644 --- a/.redocly.lint-ignore.yaml +++ b/.redocly.lint-ignore.yaml @@ -34,28 +34,3 @@ _schema.yaml: - '#/components/schemas/FetchDataPayload' security-defined: - '#/paths/~1api~1authenticate~1baseauth/get' - - '#/paths/~1api~1cloud~1storage/get' - - '#/paths/~1api~1datatypes/get' - - '#/paths/~1api~1datatypes~1converters/get' - - '#/paths/~1api~1datatypes~1edam_data/get' - - '#/paths/~1api~1datatypes~1edam_data~1detailed/get' - - '#/paths/~1api~1datatypes~1edam_formats/get' - - '#/paths/~1api~1datatypes~1edam_formats~1detailed/get' - - '#/paths/~1api~1datatypes~1mapping/get' - - '#/paths/~1api~1datatypes~1sniffers/get' - - '#/paths/~1api~1datatypes~1types_and_mapping/get' - - '#/paths/~1api~1display_applications/get' - - '#/paths/~1api~1genomes~1{id}~1indexes/get' - - '#/paths/~1api~1help~1forum~1search/get' - - '#/paths/~1api~1licenses/get' - - '#/paths/~1api~1licenses~1{id}/get' - - '#/paths/~1api~1short_term_storage~1{storage_request_id}/get' - - '#/paths/~1api~1short_term_storage~1{storage_request_id}~1ready/get' - - '#/paths/~1api~1tasks~1{task_id}~1state/get' - - '#/paths/~1api~1tool_data/get' - - '#/paths/~1api~1tool_shed_repositories/get' - - '#/paths/~1api~1tool_shed_repositories~1{id}/get' - - '#/paths/~1api~1tours/get' - - '#/paths/~1api~1tours~1{tour_id}/get' - - '#/paths/~1api~1version/get' - - '#/paths/~1ga4gh~1drs~1v1~1service-info/get' diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index 8c5a7d5b780..cb4a26a9c77 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -59,6 +59,7 @@ class FastAPIAuthenticate: summary="Returns returns an API key for authenticated user based on BaseAuth headers.", ) def get_api_key(self, request: Request) -> APIKeyResponse: + # TODO: use fastapi.security mechanism authorization = request.headers.get("Authorization") auth = {"HTTP_AUTHORIZATION": authorization} return self.authentication_service.get_api_key(auth, request) diff --git a/lib/galaxy/webapps/galaxy/api/configuration.py b/lib/galaxy/webapps/galaxy/api/configuration.py index 2f941676cfb..daa50afaf82 100644 --- a/lib/galaxy/webapps/galaxy/api/configuration.py +++ b/lib/galaxy/webapps/galaxy/api/configuration.py @@ -74,6 +74,7 @@ class FastAPIConfiguration: @router.get( "/api/version", + public=True, summary="Return Galaxy version information: major/minor version, optional extra info", response_description="Galaxy version information: major/minor version, optional extra info", ) diff --git a/lib/galaxy/webapps/galaxy/api/datatypes.py b/lib/galaxy/webapps/galaxy/api/datatypes.py index 7a35bc4b0a6..0bc22ed98ef 100644 --- a/lib/galaxy/webapps/galaxy/api/datatypes.py +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -60,6 +60,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes", + public=True, summary="Lists all available data types", response_description="List of data types", ) @@ -73,6 +74,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/mapping", + public=True, summary="Returns mappings for data types and their implementing classes", response_description="Dictionary to map data types with their classes", ) @@ -82,6 +84,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/types_and_mapping", + public=True, summary="Returns all the data types extensions and their mappings", response_description="Dictionary to map data types with their classes", ) @@ -100,6 +103,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/sniffers", + public=True, summary="Returns the list of all installed sniffers", response_description="List of datatype sniffers", ) @@ -109,6 +113,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/converters", + public=True, summary="Returns the list of all installed converters", response_description="List of all datatype converters", ) @@ -118,6 +123,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/edam_formats", + public=True, summary="Returns a dictionary/map of datatypes and EDAM formats", response_description="Dictionary/map of datatypes and EDAM formats", ) @@ -127,6 +133,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/edam_formats/detailed", + public=True, summary="Returns a dictionary of datatypes and EDAM format details", response_description="Dictionary of EDAM format details containing the EDAM iri, label, and definition", response_model=DatatypesEDAMDetailsDict, @@ -138,6 +145,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/edam_data", + public=True, summary="Returns a dictionary/map of datatypes and EDAM data", response_description="Dictionary/map of datatypes and EDAM data", ) @@ -147,6 +155,7 @@ class FastAPIDatatypes: @router.get( "/api/datatypes/edam_data/detailed", + public=True, summary="Returns a dictionary of datatypes and EDAM data details", response_description="Dictionary of EDAM data details containing the EDAM iri, label, and definition", response_model=DatatypesEDAMDetailsDict, diff --git a/lib/galaxy/webapps/galaxy/api/display_applications.py b/lib/galaxy/webapps/galaxy/api/display_applications.py index b08a58d0a8b..8a572ceec15 100644 --- a/lib/galaxy/webapps/galaxy/api/display_applications.py +++ b/lib/galaxy/webapps/galaxy/api/display_applications.py @@ -31,6 +31,7 @@ class FastAPIDisplay: @router.get( "/api/display_applications", + public=True, summary="Returns the list of display applications.", name="display_applications_index", ) diff --git a/lib/galaxy/webapps/galaxy/api/drs.py b/lib/galaxy/webapps/galaxy/api/drs.py index f003e522c74..5b5504cba3c 100644 --- a/lib/galaxy/webapps/galaxy/api/drs.py +++ b/lib/galaxy/webapps/galaxy/api/drs.py @@ -42,7 +42,7 @@ class DrsApi: service: DatasetsService = depends(DatasetsService) config: GalaxyAppConfiguration = depends(GalaxyAppConfiguration) - @router.get("/ga4gh/drs/v1/service-info") + @router.get("/ga4gh/drs/v1/service-info", public=True) def service_info(self, request: Request) -> Service: components = request.url.components hostname = components.hostname @@ -75,8 +75,8 @@ class DrsApi: **extra_kwds, ) - @router.get("/ga4gh/drs/v1/objects/{object_id}") - @router.post("/ga4gh/drs/v1/objects/{object_id}") # spec specifies both get and post should work. + @router.get("/ga4gh/drs/v1/objects/{object_id}", public=True) + @router.post("/ga4gh/drs/v1/objects/{object_id}", public=True) # spec specifies both get and post should work. def get_object( self, request: Request, @@ -85,8 +85,8 @@ class DrsApi: ) -> DrsObject: return self.service.get_drs_object(trans, object_id, request_url=request.url) - @router.get("/ga4gh/drs/v1/objects/{object_id}/access/{access_id}") - @router.post("/ga4gh/drs/v1/objects/{object_id}/access/{access_id}") + @router.get("/ga4gh/drs/v1/objects/{object_id}/access/{access_id}", public=True) + @router.post("/ga4gh/drs/v1/objects/{object_id}/access/{access_id}", public=True) def get_access_url( self, request: Request, @@ -98,6 +98,7 @@ class DrsApi: @router.get( "/api/drs_download/{object_id}", + public=True, response_class=FileResponse, ) def download(self, trans: ProvidesHistoryContext = DependsOnTrans, object_id: str = ObjectIDParam): diff --git a/lib/galaxy/webapps/galaxy/api/licenses.py b/lib/galaxy/webapps/galaxy/api/licenses.py index 823840676d7..cc64c372af4 100644 --- a/lib/galaxy/webapps/galaxy/api/licenses.py +++ b/lib/galaxy/webapps/galaxy/api/licenses.py @@ -26,7 +26,10 @@ class FastAPILicenses: licenses_manager: LicensesManager = depends(LicensesManager) @router.get( - "/api/licenses", summary="Lists all available SPDX licenses", response_description="List of SPDX licenses" + "/api/licenses", + public=True, + summary="Lists all available SPDX licenses", + response_description="List of SPDX licenses", ) async def index(self) -> List[LicenseMetadataModel]: """Returns an index with all the available [SPDX licenses](https://spdx.org/licenses/).""" @@ -34,6 +37,7 @@ class FastAPILicenses: @router.get( "/api/licenses/{id}", + public=True, summary="Gets the SPDX license metadata associated with the short identifier", response_description="SPDX license metadata", ) diff --git a/lib/galaxy/webapps/galaxy/api/short_term_storage.py b/lib/galaxy/webapps/galaxy/api/short_term_storage.py index 97f0ea6ac38..2fa5f55b6a2 100644 --- a/lib/galaxy/webapps/galaxy/api/short_term_storage.py +++ b/lib/galaxy/webapps/galaxy/api/short_term_storage.py @@ -33,6 +33,7 @@ class FastAPIShortTermStorage: @router.get( "/api/short_term_storage/{storage_request_id}", + public=True, summary="Serve the staged download specified by request ID.", response_description="Raw contents of the file.", response_class=GalaxyFileResponse, diff --git a/lib/galaxy/webapps/galaxy/api/tasks.py b/lib/galaxy/webapps/galaxy/api/tasks.py index 158222b1bec..4a0692b464c 100644 --- a/lib/galaxy/webapps/galaxy/api/tasks.py +++ b/lib/galaxy/webapps/galaxy/api/tasks.py @@ -24,6 +24,7 @@ class FastAPITasks: @router.get( "/api/tasks/{task_id}/state", + public=True, summary="Determine state of task ID", response_description="String indicating task state.", ) diff --git a/lib/galaxy/webapps/galaxy/api/tool_data.py b/lib/galaxy/webapps/galaxy/api/tool_data.py index 49598f1ef8c..cf758dc1e13 100644 --- a/lib/galaxy/webapps/galaxy/api/tool_data.py +++ b/lib/galaxy/webapps/galaxy/api/tool_data.py @@ -54,7 +54,7 @@ class FastAPIToolData: "/api/tool_data", summary="Lists all available data tables", response_description="A list with details on individual data tables.", - require_admin=False, + public=True, ) async def index(self) -> ToolDataEntryList: """Get the list of all available data tables.""" diff --git a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py index 2e111de21f5..5a7696dc7ed 100644 --- a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py +++ b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py @@ -413,6 +413,7 @@ class FastAPIToolShedRepositories: @router.get( "/api/tool_shed_repositories", + public=True, summary="Lists installed tool shed repositories.", response_description="A list of installed tool shed repository objects.", ) @@ -444,6 +445,7 @@ class FastAPIToolShedRepositories: @router.get( "/api/tool_shed_repositories/{id}", + public=True, summary="Show installed tool shed repository.", ) def show( diff --git a/lib/galaxy/webapps/galaxy/api/tours.py b/lib/galaxy/webapps/galaxy/api/tours.py index d1205888bf6..52a2924fa9e 100644 --- a/lib/galaxy/webapps/galaxy/api/tours.py +++ b/lib/galaxy/webapps/galaxy/api/tours.py @@ -23,12 +23,12 @@ router = Router(tags=["tours"]) class FastAPITours: registry: ToursRegistry = depends(ToursRegistry) # type: ignore[type-abstract] # https://github.com/python/mypy/issues/4717 - @router.get("/api/tours") + @router.get("/api/tours", public=True) def index(self) -> TourList: """Return list of available tours.""" return self.registry.get_tours() - @router.get("/api/tours/{tour_id}") + @router.get("/api/tours/{tour_id}", public=True) def show(self, tour_id: str) -> TourDetails: """Return a tour definition.""" return self.registry.tour_contents(tour_id)