From 61653ffd57b9621e3cbbacb7bc9bede5c4ed9c56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 15 Apr 2024 19:37:03 +0000 Subject: [PATCH] Remove duplicate data source attribute interface (#6437) Signed-off-by: Bandini Bhopi (cherry picked from commit e785fd361f62e9eac8711478252559a66fbdf734) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- .../data_source/common/data_sources/types.ts | 5 ++- .../server/client/configure_client_utils.ts | 3 +- .../data_source_management/public/types.ts | 44 ++++--------------- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/plugins/data_source/common/data_sources/types.ts b/src/plugins/data_source/common/data_sources/types.ts index 38c14d18ccc4..c28b82861b32 100644 --- a/src/plugins/data_source/common/data_sources/types.ts +++ b/src/plugins/data_source/common/data_sources/types.ts @@ -9,12 +9,13 @@ export interface DataSourceAttributes extends SavedObjectAttributes { title: string; description?: string; endpoint: string; + dataSourceVersion?: string; + installedPlugins?: string[]; auth: { - type: AuthType; + type: AuthType | string; credentials: UsernamePasswordTypedContent | SigV4Content | undefined | AuthTypeContent; }; lastUpdatedTime?: string; - name: AuthType | string; } export interface AuthTypeContent { diff --git a/src/plugins/data_source/server/client/configure_client_utils.ts b/src/plugins/data_source/server/client/configure_client_utils.ts index f8fa8b212c2e..fd98d225133d 100644 --- a/src/plugins/data_source/server/client/configure_client_utils.ts +++ b/src/plugins/data_source/server/client/configure_client_utils.ts @@ -141,6 +141,5 @@ export const getAuthenticationMethod = ( dataSourceAttr: DataSourceAttributes, authRegistry?: IAuthenticationMethodRegistry ): AuthenticationMethod => { - const name = dataSourceAttr.name ?? dataSourceAttr.auth.type; - return authRegistry?.getAuthenticationMethod(name) as AuthenticationMethod; + return authRegistry?.getAuthenticationMethod(dataSourceAttr.auth.type) as AuthenticationMethod; }; diff --git a/src/plugins/data_source_management/public/types.ts b/src/plugins/data_source_management/public/types.ts index 6aa94a982a20..d7c3dfe213fa 100644 --- a/src/plugins/data_source_management/public/types.ts +++ b/src/plugins/data_source_management/public/types.ts @@ -14,8 +14,8 @@ import { HttpSetup, } from 'src/core/public'; import { ManagementAppMountParams } from 'src/plugins/management/public'; -import { SavedObjectAttributes } from 'src/core/types'; import { i18n } from '@osd/i18n'; +import { AuthType } from '../../data_source/common/data_sources'; import { SigV4ServiceName } from '../../data_source/common/data_sources'; import { OpenSearchDashboardsReactContextValue } from '../../opensearch_dashboards_react/public'; import { AuthenticationMethodRegistry } from './auth_registry'; @@ -53,13 +53,6 @@ export type DataSourceManagementContextValue = OpenSearchDashboardsReactContextV DataSourceManagementContext >; -/* Datasource types */ -export enum AuthType { - NoAuth = 'no_auth', - UsernamePasswordType = 'username_password', - SigV4 = 'sigv4', -} - export const defaultAuthType = AuthType.UsernamePasswordType; export const noAuthCredentialOption = { @@ -136,35 +129,14 @@ export const credentialSourceOptions = [ sigV4CredentialOption, ]; -export interface DataSourceAttributes extends SavedObjectAttributes { - title: string; - description?: string; - endpoint?: string; - dataSourceVersion?: string; - installedPlugins?: string[]; - auth: { - type: AuthType | string; - credentials: - | UsernamePasswordTypedContent - | SigV4Content - | { [key: string]: string } - | undefined; - }; -} - -export interface UsernamePasswordTypedContent extends SavedObjectAttributes { - username: string; - password?: string; -} - -export interface SigV4Content extends SavedObjectAttributes { - accessKey: string; - secretKey: string; - region: string; - service?: SigV4ServiceName; -} - export interface MenuPanelItem { name?: string; disabled: boolean; } + +export { + AuthType, + UsernamePasswordTypedContent, + SigV4Content, + DataSourceAttributes, +} from '../../data_source/common/data_sources';