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 Data connection saved-object type for external connections #7925

Merged
merged 2 commits into from
Sep 4, 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
2 changes: 2 additions & 0 deletions changelogs/fragments/7925.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Introduce a data-connection saved-object type for external data connections ([#7925](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7925))
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { SavedObjectAttributes } from 'src/core/types';

export const DATA_CONNECTION_SAVED_OBJECT_TYPE = 'data-connection';

/**
* Represents the attributes of a data connection saved object.
* @property connectionId: The name of the data connection.
* @property type: The type of the data connection based on enum DataConnectionType
* @property meta: Additional metadata associated with the data connection.
*/
export interface DataConnectionSavedObjectAttributes extends SavedObjectAttributes {
connectionId: string;
goyamegh marked this conversation as resolved.
Show resolved Hide resolved
type: DataConnectionType;
goyamegh marked this conversation as resolved.
Show resolved Hide resolved
meta?: string;
}

export enum DataConnectionType {
CloudWatch = 'AWS CloudWatch',
SecurityLake = 'AWS Security Lake',
NA = 'None',
}

export const DATA_CONNECTION_ID_LENGTH_LIMIT = 32;
6 changes: 6 additions & 0 deletions src/plugins/data_source/common/data_connections/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './data_connection_saved_object_attributes';
3 changes: 2 additions & 1 deletion src/plugins/data_source/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { DataSourcePluginConfigType } from '../config';
import { LoggingAuditor } from './audit/logging_auditor';
import { CryptographyService, CryptographyServiceSetup } from './cryptography_service';
import { DataSourceService, DataSourceServiceSetup } from './data_source_service';
import { DataSourceSavedObjectsClientWrapper, dataSource } from './saved_objects';
import { dataConnection, dataSource, DataSourceSavedObjectsClientWrapper } from './saved_objects';
import { AuthenticationMethod, DataSourcePluginSetup, DataSourcePluginStart } from './types';
import { DATA_SOURCE_SAVED_OBJECT_TYPE } from '../common';

Expand Down Expand Up @@ -55,6 +55,7 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc

// Register data source saved object type
core.savedObjects.registerType(dataSource);
core.savedObjects.registerType(dataConnection);

const config: DataSourcePluginConfigType = await this.config$.pipe(first()).toPromise();

Expand Down
32 changes: 32 additions & 0 deletions src/plugins/data_source/server/saved_objects/data_connection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { SavedObjectsType } from 'opensearch-dashboards/server';

export const dataConnection: SavedObjectsType = {
name: 'data-connection',
namespaceType: 'agnostic',
hidden: false,
management: {
icon: 'apps',
defaultSearchField: 'connectionId',
importableAndExportable: true,
},
mappings: {
dynamic: false,
properties: {
connectionId: {
type: 'text',
},
type: {
type: 'text',
},
meta: {
type: 'text',
Comment on lines +21 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these types be keyword? and what is meta?

},
},
},
migrations: {},
};
2 changes: 2 additions & 0 deletions src/plugins/data_source/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@

export { dataSource } from './data_source';
export { DataSourceSavedObjectsClientWrapper } from './data_source_saved_objects_client_wrapper';

export { dataConnection } from './data_connection';
Loading