Skip to content

Commit

Permalink
Add the server setup
Browse files Browse the repository at this point in the history
Co-authored-by: Shenoy Pratik <sgguruda@amazon.com>
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 and ps48 committed Jul 19, 2024
1 parent 9ff084a commit 9322336
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "dataSourceManagement",
"version": "opensearchDashboards",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": ["management", "indexPatternManagement"],
"optionalPlugins": ["dataSource"],
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/data_source_management/sever/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { PluginInitializerContext } from 'opensearch-dashboards/server';
import { DataSourceManagementPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, OpenSearch Dashboards Platform `plugin()` initializer.

export function plugin(initializerContext: PluginInitializerContext) {
return new DataSourceManagementPlugin(initializerContext);
}

export { DataSourceManagementPluginSetup, DataSourceManagementPluginStart } from './types';
41 changes: 41 additions & 0 deletions src/plugins/data_source_management/sever/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
} from 'opensearch-dashboards/server';

import { defineRoutes } from './routes';
import { DataSourceManagementPluginSetup, DataSourceManagementPluginStart } from './types';

export class DataSourceManagementPlugin
implements Plugin<DataSourceManagementPluginSetup, DataSourceManagementPluginStart> {
private readonly logger: Logger;

constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}

public setup(core: CoreSetup) {
this.logger.debug('dataSourceManagement: Setup');
const router = core.http.createRouter();

// Register server side APIs
defineRoutes(router);

return {};
}

public start(core: CoreStart) {
this.logger.debug('dataSourceManagement: Started');
return {};
}

public stop() {}
}
22 changes: 22 additions & 0 deletions src/plugins/data_source_management/sever/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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

export function defineRoutes(router: IRouter) {
router.get(
{
path: '/api/data_source_management/example',
validate: false,
},
async (context, request, response) => {
return response.ok({
body: {
time: new Date().toISOString(),
},
});
}
);
}
9 changes: 9 additions & 0 deletions src/plugins/data_source_management/sever/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataSourceManagementPluginSetup {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataSourceManagementPluginStart {}

0 comments on commit 9322336

Please sign in to comment.