import { schema } from '@kbn/config-schema' ; import { PLUGIN_ID } from '../../../common' ; import { IRouter } from '../../../../../../src/core/server' ; import { OsqueryAppContext } from '../../lib/osquery_app_context_services' ; export const getAgentsRoute = ( router , osqueryContext ) => { router . get ( { path : '/internal/osquery/fleet_wrapper/agents' , validate : { query : schema . object ( { } , { unknowns : 'allow' } ) , } , options : { tags : [ `access:${ PLUGIN_ID }-read` ] } , } , async ( context , request , response ) => { let agents ; try { agents = await osqueryContext . service . getAgentService ( ) ?. asInternalUser . listAgents ( request . query ) ; } catch ( error ) { return response . badRequest ( { body : error } ) ; } return response . ok ( { body : agents } ) ; } ) ; } ;