Skip to content

Commit

Permalink
Remove duplicate data source attribute interface (#6437)
Browse files Browse the repository at this point in the history
Signed-off-by: Bandini Bhopi <bandinib@amazon.com>
(cherry picked from commit e785fd3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] authored and bandinib-amzn committed Apr 15, 2024
1 parent 4ca0243 commit 9ea06c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 40 deletions.
5 changes: 3 additions & 2 deletions src/plugins/data_source/common/data_sources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
44 changes: 8 additions & 36 deletions src/plugins/data_source_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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';

0 comments on commit 9ea06c3

Please sign in to comment.