diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index adc8898a860e..bb80eab16d9e 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -4710,43 +4710,6 @@ export interface paths { patch?: never; trace?: never; }; - "/api/users/{user_id}/credentials/{user_credentials_id}": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - /** Verifies if credentials have been provided for a specific service */ - get: operations["verify_service_credentials_api_users__user_id__credentials__user_credentials_id__get"]; - /** Updates credentials for a specific secret/variable */ - put: operations["update_credential_api_users__user_id__credentials__user_credentials_id__put"]; - post?: never; - /** Deletes all credentials for a specific service */ - delete: operations["delete_service_credentials_api_users__user_id__credentials__user_credentials_id__delete"]; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/api/users/{user_id}/credentials/{user_credentials_id}/{credentials_id}": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - /** Verifies if a credential have been provided */ - get: operations["verify_credentials_api_users__user_id__credentials__user_credentials_id___credentials_id__get"]; - put?: never; - post?: never; - /** Deletes a specific credential */ - delete: operations["delete_credentials_api_users__user_id__credentials__user_credentials_id___credentials_id__delete"]; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; "/api/users/{user_id}/custom_builds": { parameters: { query?: never; @@ -7447,32 +7410,32 @@ export interface components { */ username: string; }; - /** CredentialPayload */ - CredentialPayload: { + /** CredentialGroupResponse */ + CredentialGroupResponse: { /** - * Credential Name - * @description Name of the credential + * Group ID + * @description ID of the group + * @example 0123456789ABCDEF */ - name: string; + id: string; /** - * Type - * @description Type of the credential(secret/variable) + * Group Name + * @description Name of the group */ - type: components["schemas"]["CredentialType"]; + name: string; /** - * Credential Value - * @description Value of the credential + * Secrets + * @description List of secrets */ - value: string; - }; - /** CredentialResponse */ - CredentialResponse: { + secrets: components["schemas"]["SecretResponse"][]; /** - * ID - * @description ID of the credential - * @example 0123456789ABCDEF + * Variables + * @description List of variables */ - id: string; + variables: components["schemas"]["VariableResponse"][]; + }; + /** CredentialPayload */ + CredentialPayload: { /** * Credential Name * @description Name of the credential @@ -7480,46 +7443,50 @@ export interface components { name: string; /** * Type - * @description Type of the credential + * @description Type of the credential(secret/variable) */ type: components["schemas"]["CredentialType"]; + /** + * Credential Value + * @description Value of the credential + */ + value: string; }; /** * CredentialType * @enum {string} */ CredentialType: "secret" | "variable"; - /** CredentialsListResponse */ - CredentialsListResponse: { + /** CredentialsPayload */ + CredentialsPayload: { /** * Credentials * @description List of credentials */ - credentials: components["schemas"]["CredentialResponse"][]; + credentials: components["schemas"]["CredentialPayload"][]; /** - * Service Reference - * @description Reference to the service + * Group Name + * @description Name of the group + * @default default */ - service_reference: string; + group_name: string | null; /** - * User Credentials ID - * @description ID of the user credentials - * @example 0123456789ABCDEF + * Service Reference + * @description Reference to the service */ - user_credentials_id: string; - }; - /** CredentialsPayload */ - CredentialsPayload: { + reference: string; /** - * Credentials - * @description List of credentials + * Source ID + * @description ID of the source */ - credentials: components["schemas"]["CredentialPayload"][]; + source_id: string; /** - * Service Reference - * @description Reference to the service + * Source Type + * @description Type of the source + * @constant + * @enum {string} */ - service_reference: string; + source_type: "tool"; }; /** CustomArchivedHistoryView */ CustomArchivedHistoryView: { @@ -8471,14 +8438,6 @@ export interface components { * @enum {string} */ DefaultQuotaValues: "unregistered" | "registered" | "no"; - /** DeleteCredentialsResponse */ - DeleteCredentialsResponse: { - /** - * Deleted - * @description Indicates if the credentials were deleted - */ - deleted: boolean; - }; /** DeleteDatasetBatchPayload */ DeleteDatasetBatchPayload: { /** @@ -15892,6 +15851,25 @@ export interface components { } & { [key: string]: unknown; }; + /** SecretResponse */ + SecretResponse: { + /** + * Already Set + * @description Whether the secret is already set + */ + already_set: boolean; + /** + * ID + * @description ID of the credential + * @example 0123456789ABCDEF + */ + id: string; + /** + * Credential Name + * @description Name of the credential + */ + name: string; + }; /** ServerDirElement */ ServerDirElement: { /** Md5 */ @@ -17188,28 +17166,6 @@ export interface components { /** Creator */ creator?: unknown; }; - /** UpdateCredentialPayload */ - UpdateCredentialPayload: { - /** - * ID - * @description ID of the credential - * @example 0123456789ABCDEF - */ - id: string; - /** - * Value - * @description Value of the credential - */ - value: string; - }; - /** UpdateCredentialsPayload */ - UpdateCredentialsPayload: { - /** - * Update Credentials - * @description List of credentials to update - */ - root: components["schemas"]["UpdateCredentialPayload"][]; - }; /** UpdateDatasetPermissionsPayload */ UpdateDatasetPermissionsPayload: { /** Access Ids[] */ @@ -17732,11 +17688,97 @@ export interface components { */ username: string; }; + /** UserCredentialCreateResponse */ + UserCredentialCreateResponse: { + /** + * Current Group Name + * @description Name of the current group + */ + current_group_name: string; + /** + * Group + * @description Group of credentials + */ + group: components["schemas"]["CredentialGroupResponse"]; + /** + * User Credentials ID + * @description ID of the user credentials + * @example 0123456789ABCDEF + */ + id: string; + /** + * Service Reference + * @description Reference to the service + */ + reference: string; + /** + * Source ID + * @description ID of the source + */ + source_id: string; + /** + * Source Type + * @description Type of the source + * @constant + * @enum {string} + */ + source_type: "tool"; + /** + * User ID + * @description ID of the user + * @example 0123456789ABCDEF + */ + user_id: string; + }; /** * UserCredentialsListResponse * @description List of user credentials */ - UserCredentialsListResponse: components["schemas"]["CredentialsListResponse"][]; + UserCredentialsListResponse: components["schemas"]["UserCredentialsResponse"][]; + /** UserCredentialsResponse */ + UserCredentialsResponse: { + /** + * Current Group Name + * @description Name of the current group + */ + current_group_name: string; + /** + * Groups + * @description Groups of credentials + */ + groups: { + [key: string]: components["schemas"]["CredentialGroupResponse"]; + }; + /** + * User Credentials ID + * @description ID of the user credentials + * @example 0123456789ABCDEF + */ + id: string; + /** + * Service Reference + * @description Reference to the service + */ + reference: string; + /** + * Source ID + * @description ID of the source + */ + source_id: string; + /** + * Source Type + * @description Type of the source + * @constant + * @enum {string} + */ + source_type: "tool"; + /** + * User ID + * @description ID of the user + * @example 0123456789ABCDEF + */ + user_id: string; + }; /** UserDeletionPayload */ UserDeletionPayload: { /** @@ -18007,13 +18049,24 @@ export interface components { */ username?: string | null; }; - /** VerifyCredentialsResponse */ - VerifyCredentialsResponse: { + /** VariableResponse */ + VariableResponse: { /** - * Exists - * @description Indicates if the credentials exist + * ID + * @description ID of the credential + * @example 0123456789ABCDEF */ - exists: boolean; + id: string; + /** + * Credential Name + * @description Name of the credential + */ + name: string; + /** + * Value + * @description Value of the credential + */ + value?: string | null; }; /** Visualization */ Visualization: Record; @@ -33974,9 +34027,11 @@ export interface operations { parameters: { query?: { /** @description The type of source to filter by. */ - source_type?: string | null; + source_type?: "tool" | null; /** @description The ID of the source to filter by. */ source_id?: string | null; + /** @description The name of the group to filter by. */ + group_name?: string | null; }; header?: { /** @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. */ @@ -34044,238 +34099,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["CredentialsListResponse"]; - }; - }; - /** @description Request Error */ - "4XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - /** @description Server Error */ - "5XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - }; - }; - verify_service_credentials_api_users__user_id__credentials__user_credentials_id__get: { - parameters: { - query?: never; - header?: { - /** @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. */ - "run-as"?: string | null; - }; - path: { - /** @description The ID of the user. */ - user_id: string; - user_credentials_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["VerifyCredentialsResponse"]; - }; - }; - /** @description Request Error */ - "4XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - /** @description Server Error */ - "5XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - }; - }; - update_credential_api_users__user_id__credentials__user_credentials_id__put: { - parameters: { - query?: never; - header?: { - /** @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. */ - "run-as"?: string | null; - }; - path: { - /** @description The ID of the user. */ - user_id: string; - user_credentials_id: string; - }; - cookie?: never; - }; - requestBody: { - content: { - "application/json": components["schemas"]["UpdateCredentialsPayload"]; - }; - }; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["CredentialsListResponse"]; - }; - }; - /** @description Request Error */ - "4XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - /** @description Server Error */ - "5XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - }; - }; - delete_service_credentials_api_users__user_id__credentials__user_credentials_id__delete: { - parameters: { - query?: never; - header?: { - /** @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. */ - "run-as"?: string | null; - }; - path: { - /** @description The ID of the user. */ - user_id: string; - user_credentials_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["DeleteCredentialsResponse"]; - }; - }; - /** @description Request Error */ - "4XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - /** @description Server Error */ - "5XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - }; - }; - verify_credentials_api_users__user_id__credentials__user_credentials_id___credentials_id__get: { - parameters: { - query?: never; - header?: { - /** @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. */ - "run-as"?: string | null; - }; - path: { - /** @description The ID of the user. */ - user_id: string; - user_credentials_id: string; - credentials_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["VerifyCredentialsResponse"]; - }; - }; - /** @description Request Error */ - "4XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - /** @description Server Error */ - "5XX": { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["MessageExceptionModel"]; - }; - }; - }; - }; - delete_credentials_api_users__user_id__credentials__user_credentials_id___credentials_id__delete: { - parameters: { - query?: never; - header?: { - /** @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. */ - "run-as"?: string | null; - }; - path: { - /** @description The ID of the user. */ - user_id: string; - user_credentials_id: string; - credentials_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["DeleteCredentialsResponse"]; + "application/json": components["schemas"]["UserCredentialCreateResponse"]; }; }; /** @description Request Error */ diff --git a/lib/galaxy/webapps/galaxy/api/credentials.py b/lib/galaxy/webapps/galaxy/api/credentials.py index a670e65194bc..06099f04c5f6 100644 --- a/lib/galaxy/webapps/galaxy/api/credentials.py +++ b/lib/galaxy/webapps/galaxy/api/credentials.py @@ -5,21 +5,17 @@ import logging from typing import Optional -from fastapi import ( - Query, - Response, - status, -) +from fastapi import Query # Response,; status, from galaxy.managers.context import ProvidesUserContext -from galaxy.schema.credentials import ( +from galaxy.schema.credentials import ( # UpdateCredentialsPayload, CredentialsPayload, SOURCE_TYPE, - UpdateCredentialsPayload, UserCredentialCreateResponse, UserCredentialsListResponse, ) -from galaxy.schema.fields import DecodedDatabaseIdField + +# from galaxy.schema.fields import DecodedDatabaseIdField from galaxy.webapps.galaxy.api import ( depends, DependsOnTrans, diff --git a/lib/galaxy/webapps/galaxy/services/credentials.py b/lib/galaxy/webapps/galaxy/services/credentials.py index 36611554fcac..01617f4937b0 100644 --- a/lib/galaxy/webapps/galaxy/services/credentials.py +++ b/lib/galaxy/webapps/galaxy/services/credentials.py @@ -3,15 +3,10 @@ Dict, List, Optional, - Sequence, Tuple, ) -from sqlalchemy import ( - false, - select, - update, -) +from sqlalchemy import select from sqlalchemy.orm import aliased from galaxy import exceptions @@ -22,13 +17,11 @@ UserCredentials, ) from galaxy.model.base import transaction -from galaxy.schema.credentials import ( +from galaxy.schema.credentials import ( # CredentialResponse,; UpdateCredentialsPayload, CredentialGroupResponse, - CredentialResponse, CredentialsPayload, SecretResponse, SOURCE_TYPE, - UpdateCredentialsPayload, UserCredentialCreateResponse, UserCredentialsListResponse, UserCredentialsResponse, @@ -155,7 +148,7 @@ def _user_credentials( stmt = stmt.where(UserCredentials.id == user_credentials_id) result = trans.sa_session.execute(stmt).all() - return [(uc, cg, c) for uc, cg, c in result] + return [(row[0], row[1], row[2]) for row in result] def _user_credentials_to_dict( self, db_user_credentials: List[Tuple[UserCredentials, CredentialsGroup, Credential]] @@ -172,7 +165,7 @@ def _user_credentials_to_dict( source_id=user_credentials.source_id, current_group_id=user_credentials.current_group_id, current_group_name=credentials_group.name, - groups=dict(), + groups={}, ), )