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 async function MsearchTemplateApi < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; export default async function MsearchTemplateApi < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; export default async function MsearchTemplateApi < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) ; export default async function MsearchTemplateApi < TDocument = unknown , TAggregations = Record < T . AggregateName , T . AggregationsAggregate > > ( this , params , options ? ) { const acceptedPath = [ 'index' ] ; const acceptedBody = [ 'search_templates' ] ; 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 ] ; } } let method = '' ; let path = '' ; if ( params . index != null ) { method = body != null ? 'POST' : 'GET' ; path = `/${ encodeURIComponent ( params . index . toString ( ) ) }/_msearch/template` ; } else { method = body != null ? 'POST' : 'GET' ; path = '/_msearch/template' ; } return await this . transport . request ( { path , method , querystring , bulkBody : body } , options ) ; }