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 Rollup { transport : Transport ; constructor ( transport ) { this . transport = transport ; } async deleteJob ( this , params , options ? ) ; async deleteJob ( this , params , options ? ) ; async deleteJob ( this , params , options ? ) ; async deleteJob ( this , params , options ? ) { const acceptedPath = [ '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 = 'DELETE' ; const path = `/_rollup/job/${ encodeURIComponent ( params . id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async getJobs ( this , params ? , options ? ) ; async getJobs ( this , params ? , options ? ) ; async getJobs ( this , params ? , options ? ) ; async getJobs ( this , params ? , options ? ) { const acceptedPath = [ '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 . id != null ) { method = 'GET' ; path = `/_rollup/job/${ encodeURIComponent ( params . id . toString ( ) ) }` ; } else { method = 'GET' ; path = '/_rollup/job/' ; } return await this . transport . request ( { path , method , querystring , body } , options ) ; } async getRollupCaps ( this , params ? , options ? ) ; async getRollupCaps ( this , params ? , options ? ) ; async getRollupCaps ( this , params ? , options ? ) ; async getRollupCaps ( this , params ? , options ? ) { const acceptedPath = [ '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 . id != null ) { method = 'GET' ; path = `/_rollup/data/${ encodeURIComponent ( params . id . toString ( ) ) }` ; } else { method = 'GET' ; path = '/_rollup/data/' ; } return await this . transport . request ( { path , method , querystring , body } , options ) ; } async getRollupIndexCaps ( this , params , options ? ) ; async getRollupIndexCaps ( this , params , options ? ) ; async getRollupIndexCaps ( this , params , options ? ) ; async getRollupIndexCaps ( this , params , options ? ) { const acceptedPath = [ 'index' ] ; 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 = `/${ encodeURIComponent ( params . index . toString ( ) ) }/_rollup/data` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async putJob ( this , params , options ? ) ; async putJob ( this , params , options ? ) ; async putJob ( this , params , options ? ) ; async putJob ( this , params , options ? ) { const acceptedPath = [ 'id' ] ; const acceptedBody = [ 'cron' , 'groups' , 'index_pattern' , 'metrics' , 'page_size' , 'rollup_index' , 'timeout' , 'headers' ] ; const querystring = { } ; const userBody = params ?. body ; let body ; if ( typeof userBody === 'string' ) { body = userBody ; } else { body = userBody != null ? { ... userBody } : undefined ; } for ( const key in params ) { if ( acceptedBody . includes ( key ) ) { body = body ?? { } ; body [ key ] = params [ key ] ; } else if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } const method = 'PUT' ; const path = `/_rollup/job/${ encodeURIComponent ( params . id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async rollup ( this , params , options ? ) ; async rollup ( this , params , options ? ) ; async rollup ( this , params , options ? ) ; async rollup ( this , params , options ? ) { const acceptedPath = [ 'index' , 'rollup_index' ] ; const acceptedBody = [ 'config' ] ; const querystring = { } ; let body = params . body ?? undefined ; for ( const key in params ) { if ( acceptedBody . includes ( key ) ) { body = params [ key ] ; } else if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } const method = 'POST' ; const path = `/${ encodeURIComponent ( params . index . toString ( ) ) }/_rollup/${ encodeURIComponent ( params . rollup_index . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async rollupSearch < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; async rollupSearch < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; async rollupSearch < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; async rollupSearch < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) { const acceptedPath = [ 'index' ] ; const acceptedBody = [ 'aggregations' , 'aggs' , 'query' , 'size' ] ; const querystring = { } ; const userBody = params ?. body ; let body ; if ( typeof userBody === 'string' ) { body = userBody ; } else { body = userBody != null ? { ... userBody } : undefined ; } for ( const key in params ) { if ( acceptedBody . includes ( key ) ) { body = body ?? { } ; body [ key ] = params [ key ] ; } else if ( acceptedPath . includes ( key ) ) { continue ; } else if ( key !== 'body' ) { querystring [ key ] = params [ key ] ; } } const method = body != null ? 'POST' : 'GET' ; const path = `/${ encodeURIComponent ( params . index . toString ( ) ) }/_rollup_search` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async startJob ( this , params , options ? ) ; async startJob ( this , params , options ? ) ; async startJob ( this , params , options ? ) ; async startJob ( this , params , options ? ) { const acceptedPath = [ '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 = 'POST' ; const path = `/_rollup/job/${ encodeURIComponent ( params . id . toString ( ) ) }/_start` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async stopJob ( this , params , options ? ) ; async stopJob ( this , params , options ? ) ; async stopJob ( this , params , options ? ) ; async stopJob ( this , params , options ? ) { const acceptedPath = [ '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 = 'POST' ; const path = `/_rollup/job/${ encodeURIComponent ( params . id . toString ( ) ) }/_stop` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } }