import { createStaticDataView } from './create_static_data_view' ; import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository' ; import { setupRequest } from '../../lib/helpers/setup_request' ; import { getDynamicDataView } from './get_dynamic_data_view' ; import { createApmServerRoute } from '../apm_routes/create_apm_server_route' ; const staticDataViewRoute = createApmServerRoute ( { endpoint : 'POST /internal/apm/data_view/static' , options : { tags : [ 'access:apm' ] } , handler : async ( resources ) => { const { request , core , plugins : { spaces } , config , } = resources ; const setupPromise = setupRequest ( resources ) ; const clientPromise = core . start ( ) . then ( ( coreStart ) => coreStart . savedObjects . createInternalRepository ( ) ) ; const setup = await setupPromise ; const savedObjectsClient = await clientPromise ; const spaceId = spaces ?. setup . spacesService . getSpaceId ( request ) ; const didCreateDataView = await createStaticDataView ( { setup , config , savedObjectsClient , spaceId , } ) ; return { created : didCreateDataView } ; } , } ) ; const dynamicDataViewRoute = createApmServerRoute ( { endpoint : 'GET /internal/apm/data_view/dynamic' , options : { tags : [ 'access:apm' ] } , handler : async ( { context , config , logger } ) => { const dynamicDataView = await getDynamicDataView ( { context , config , logger , } ) ; return { dynamicDataView } ; } , } ) ; export const dataViewRouteRepository = createApmServerRouteRepository ( ) . add ( staticDataViewRoute ) . add ( dynamicDataViewRoute ) ;