Skip to content

Commit

Permalink
Merge pull request #17510 from mira-miracoli/encode-api
Browse files Browse the repository at this point in the history
add encode ID API endpoint
  • Loading branch information
bgruening authored Feb 23, 2024
2 parents 38a17a0 + 8f788d9 commit 685912f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
39 changes: 39 additions & 0 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/galaxy/managers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
16 changes: 16 additions & 0 deletions lib/galaxy/webapps/galaxy/api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 685912f

Please sign in to comment.