Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add encode ID API endpoint #17510

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading