import { FtrProviderContext } from '../../../../ftr_provider_context' ; interface Processor { [ key ] : { [ key ] : unknown ; } ; } interface Pipeline { id : string ; body : { description : string ; processors : Processor [ ] ; version ? : number ; } ; } param { ElasticsearchClient } es export const registerEsHelpers = ( getService ) => { let pipelinesCreated = [ ] ; const es = getService ( 'es' ) ; const createPipeline = ( pipeline , cachePipeline ? ) => { if ( cachePipeline ) { pipelinesCreated . push ( pipeline . id ) ; } return es . ingest . putPipeline ( pipeline ) ; } ; const deletePipeline = ( pipelineId ) => es . ingest . deletePipeline ( { id : pipelineId } ) ; const cleanupPipelines = ( ) => Promise . all ( pipelinesCreated . map ( deletePipeline ) ) . then ( ( ) => { pipelinesCreated = [ ] ; } ) . catch ( ( err ) => { console . log ( `[Cleanup error] Error deleting ES resources: ${ err . message }` ) ; } ) ; const createIndex = ( index ) => { return es . index ( index ) ; } ; const deleteIndex = ( indexName ) => { return es . indices . delete ( { index : indexName } ) ; } ; return { createPipeline , deletePipeline , cleanupPipelines , createIndex , deleteIndex , } ; } ;