import { schema } from '@kbn/config-schema' ; import { ElasticsearchClient } from 'kibana/server' ; import { RouteDependencies } from '../../../types' ; import { addBasePath } from '../../../services' ; async function deletePolicies ( client , policyName ) { const options = { ignore : [ 404 ] , } ; return client . ilm . deleteLifecycle ( { name : policyName } , options ) ; } const paramsSchema = schema . object ( { policyNames : schema . string ( ) , } ) ; export function registerDeleteRoute ( { router , license , lib : { handleEsError } , } ) { router . delete ( { path : addBasePath ( '/policies/{policyNames}' ) , validate : { params : paramsSchema } } , license . guardApiRoute ( async ( context , request , response ) => { const params = request . params as typeof paramsSchema . type ; const { policyNames } = params ; try { await deletePolicies ( context . core . elasticsearch . client . asCurrentUser , policyNames ) ; return response . ok ( ) ; } catch ( error ) { return handleEsError ( { error , response } ) ; } } ) ) ; }