in dashboards-reports/server/plugin.ts [54:110]
public async setup(core: CoreSetup) {
this.logger.debug('reports-dashboards: Setup');
try {
const config = await buildConfig(
this.initializerContext,
core,
this.logger
);
this.reportingConfig = config;
this.logger.debug('Setup complete');
} catch (error) {
this.logger.error(
`Error in Reporting setup, reporting may not function properly`
);
this.logger.error(error);
}
if (!this.reportingConfig) {
throw new Error('Reporting Config is not initialized');
}
const router = core.http.createRouter();
// Deprecated API. Switch to the new opensearch client as soon as https://github.com/elastic/kibana/issues/35508 done.
const opensearchReportsClient: ILegacyClusterClient = core.opensearch.legacy.createClient(
'opensearch_reports',
{
plugins: [opensearchReportsPlugin, NotificationsPlugin],
}
);
const notificationsClient: ILegacyClusterClient = core.opensearch.legacy.createClient(
'opensearch_notifications',
{
plugins: [NotificationsPlugin],
}
);
// Register server side APIs
registerRoutes(router, this.reportingConfig);
// put logger into route handler context, so that we don't need to pass through parameters
core.http.registerRouteHandlerContext(
//@ts-ignore
'reporting_plugin',
(context, request) => {
return {
logger: this.logger,
semaphore: this.semaphore,
opensearchReportsClient,
notificationsClient,
};
}
);
return {};
}