import { ApmPluginRequestHandlerContext } from '../typings' ; import { ApiKey } from '../../../../security/common/model' ; export async function getAgentKeys ( { context , } ) { const body = { size : 1000 , query : { bool : { filter : [ { term : { 'metadata.application' : 'apm' , } , } , ] , } , } , } ; const esClient = context . core . elasticsearch . client ; const apiResponse = await esClient . asCurrentUser . transport . request < { api_keys : ApiKey [ ] ; } > ( { method : 'GET' , path : '_security/_query/api_key' , body , } ) ; const agentKeys = apiResponse . body . api_keys . filter ( ( { invalidated } ) => ! invalidated ) ; return { agentKeys , } ; }