diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d4ec919e3d..5a0bd6108f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -149,6 +149,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110)) - [Multiple Datasource] Move data source selectable to its own folder, fix test and a few type errors for data source selectable component ([#6287](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6287)) - Remove KUI usage in `disabled_lab_visualization` ([#5462](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5462)) +- [Multiple Datasource] Remove duplicate data source attribute interface from `data_source_management` ([#6437](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6437)) ### 🔩 Tests 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 2748ddfd5ca4..9a76eaf6f19a 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';