import { Transport , TransportRequestOptions , TransportRequestOptionsWithMeta , TransportRequestOptionsWithOutMeta , TransportResult } from '@elastic/transport' ; import * as T from '../types' ; import * as TB from '../typesWithBodyKey' ; interface That { transport : Transport ; } export default class Tasks { transport : Transport ; constructor ( transport ) { this . transport = transport ; } async cancel ( this , params ? , options ? ) ; async cancel ( this , params ? , options ? ) ; async cancel ( this , params ? , options ? ) ; async cancel ( this , params ? , options ? ) { const acceptedPath = [ 'task_id' ] ; const querystring = { } ; const body = undefined ; params = params ?? { } ; for ( const key in params ) { if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } let method = '' ; let path = '' ; if ( params . task_id != null ) { method = 'POST' ; path = `/_tasks/${ encodeURIComponent ( params . task_id . toString ( ) ) }/_cancel` ; } else { method = 'POST' ; path = '/_tasks/_cancel' ; } return await this . transport . request ( { path , method , querystring , body } , options ) ; } async get ( this , params , options ? ) ; async get ( this , params , options ? ) ; async get ( this , params , options ? ) ; async get ( this , params , options ? ) { const acceptedPath = [ 'task_id' ] ; const querystring = { } ; const body = undefined ; for ( const key in params ) { if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } const method = 'GET' ; const path = `/_tasks/${ encodeURIComponent ( params . task_id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async list ( this , params ? , options ? ) ; async list ( this , params ? , options ? ) ; async list ( this , params ? , options ? ) ; async list ( this , params ? , options ? ) { const acceptedPath = [ ] ; const querystring = { } ; const body = undefined ; params = params ?? { } ; for ( const key in params ) { if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } const method = 'GET' ; const path = '/_tasks' ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } }