import { wrapError } from '../client/error_wrapper' ; import { RouteInitialization } from '../types' ; import { indicesSchema } from './schemas/indices_schema' ; /**
 * Indices routes.
 */ export function indicesRoutes ( { router , routeGuard } ) { apiGroup api apiName apiDescription apiSchema router . post ( { path : '/api/ml/indices/field_caps' , validate : { body : indicesSchema , } , options : { tags : [ 'access:ml:canAccessML' ] , } , } , routeGuard . fullLicenseAPIGuard ( async ( { client , request , response } ) => { try { const { body : { index , fields : requestFields } , } = request ; const fields = requestFields !== undefined && Array . isArray ( requestFields ) ? requestFields . join ( ',' ) : '*' ; const { body } = await client . asCurrentUser . fieldCaps ( { index , fields } ) ; return response . ok ( { body } ) ; } catch ( e ) { return response . customError ( wrapError ( e ) ) ; } } ) ) ; }