diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index c66cb4c0675d..32c9e4e063a3 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -47,6 +47,13 @@ export interface paths { */ get: operations["dynamic_tool_confs_api_configuration_dynamic_tool_confs_get"]; }; + "/api/configuration/encode/{decoded_id}": { + /** + * Encode a given id + * @description Decode a given id. + */ + get: operations["encode_id_api_configuration_encode__decoded_id__get"]; + }; "/api/configuration/tool_lineages": { /** * Return tool lineages for tools that have them @@ -11518,6 +11525,38 @@ export interface operations { }; }; }; + encode_id_api_configuration_encode__decoded_id__get: { + /** + * Encode a given id + * @description Decode a given id. + */ + parameters: { + /** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */ + header?: { + "run-as"?: string | null; + }; + /** @description Decoded id to be encoded */ + path: { + decoded_id: number; + }; + }; + responses: { + /** @description Encoded id */ + 200: { + content: { + "application/json": { + [key: string]: string | undefined; + }; + }; + }; + /** @description Validation Error */ + 422: { + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; tool_lineages_api_configuration_tool_lineages_get: { /** * Return tool lineages for tools that have them diff --git a/lib/galaxy/managers/configuration.py b/lib/galaxy/managers/configuration.py index d15b2d941d75..bb010dfd909d 100644 --- a/lib/galaxy/managers/configuration.py +++ b/lib/galaxy/managers/configuration.py @@ -56,6 +56,13 @@ def decode_id( decoded_id = self._app.security.decode_id(encoded_id) return {"decoded_id": decoded_id} + def encode_id( + self, + decoded_id: int, + ) -> Dict[str, str]: + encoded_id = self._app.security.encode_id(decoded_id) + return {"encoded_id": encoded_id} + def tool_lineages(self) -> List[Dict[str, Dict]]: rval = [] for id, tool in self._app.toolbox.tools(): diff --git a/lib/galaxy/webapps/galaxy/api/configuration.py b/lib/galaxy/webapps/galaxy/api/configuration.py index fff240830645..51c23813a007 100644 --- a/lib/galaxy/webapps/galaxy/api/configuration.py +++ b/lib/galaxy/webapps/galaxy/api/configuration.py @@ -39,6 +39,12 @@ description="Encoded id to be decoded", ) +DecodedIdPathParam = Path( + ..., + title="Decoded id", + description="Decoded id to be encoded", +) + @router.cbv class FastAPIConfiguration: @@ -103,6 +109,16 @@ def decode_id(self, encoded_id: str = EncodedIdPathParam) -> Dict[str, int]: """Decode a given id.""" return self.configuration_manager.decode_id(encoded_id) + @router.get( + "/api/configuration/encode/{decoded_id}", + require_admin=True, + summary="Encode a given id", + response_description="Encoded id", + ) + def encode_id(self, decoded_id: int = DecodedIdPathParam) -> Dict[str, str]: + """Decode a given id.""" + return self.configuration_manager.encode_id(decoded_id) + @router.get( "/api/configuration/tool_lineages", require_admin=True,