OpenSearch-Dashboards
OpenSearch-Dashboards copied to clipboard
[MDS] Refactor several utility functions in data source plugin
Is your feature request related to a problem? Please describe. Currently, there are two functions being repeated in plugins that can simply be extracted into data source plugin utility functions:
- A function that decides whether to use local cluster or remote OpenSearch client based on data source id
- A function that retrieves the data source id based on data source title/name
Describe the solution you'd like There should be three utility functions placed in the data source plugin that will be exposed so that other plugins can consume:
decideClient(context: RequestHandlerContext, dataSourceId?: string, withLongNumeralsSupport: boolean): return the correct clientdecideLegacyClient(context: RequestHandlerContext, dataSourceId?: string): return the correct legacy clientfetchDataSourceNameById(client: SavedObjectsClientCommon, dataSourceTitle: string): return the data source id (if it exists)SavedObjectClientWrappershould be defined in bothpublicandserverfolders for passing type checks
Describe alternatives you've considered
N/A
Additional context
N/A