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 Sql { transport : Transport ; constructor ( transport ) { this . transport = transport ; } async clearCursor ( this , params , options ? ) ; async clearCursor ( this , params , options ? ) ; async clearCursor ( this , params , options ? ) ; async clearCursor ( this , params , options ? ) { const acceptedPath = [ ] ; const acceptedBody = [ 'cursor' ] ; 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 = 'POST' ; const path = '/_sql/close' ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async deleteAsync ( this , params ? , options ? ) ; async deleteAsync ( this , params ? , options ? ) ; async deleteAsync ( this , params ? , options ? ) ; async deleteAsync ( 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 ] ; } } const method = 'DELETE' ; const path = `/_sql/async/delete/${ encodeURIComponent ( params . id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async getAsync ( this , params ? , options ? ) ; async getAsync ( this , params ? , options ? ) ; async getAsync ( this , params ? , options ? ) ; async getAsync ( 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 ] ; } } const method = 'GET' ; const path = `/_sql/async/${ encodeURIComponent ( params . id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async getAsyncStatus ( this , params ? , options ? ) ; async getAsyncStatus ( this , params ? , options ? ) ; async getAsyncStatus ( this , params ? , options ? ) ; async getAsyncStatus ( 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 ] ; } } const method = 'GET' ; const path = `/_sql/async/status/${ encodeURIComponent ( params . id . toString ( ) ) }` ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async query ( this , params ? , options ? ) ; async query ( this , params ? , options ? ) ; async query ( this , params ? , options ? ) ; async query ( this , params ? , options ? ) { const acceptedPath = [ ] ; const acceptedBody = [ 'columnar' , 'cursor' , 'fetch_size' , 'filter' , 'query' , 'request_timeout' , 'page_timeout' , 'time_zone' , 'field_multi_value_leniency' ] ; const querystring = { } ; const userBody = params ?. body ; let body ; if ( typeof userBody === 'string' ) { body = userBody ; } else { body = userBody != null ? { ... userBody } : undefined ; } params = params ?? { } ; 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 = '/_sql' ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } async translate ( this , params , options ? ) ; async translate ( this , params , options ? ) ; async translate ( this , params , options ? ) ; async translate ( this , params , options ? ) { const acceptedPath = [ ] ; const acceptedBody = [ 'fetch_size' , 'filter' , 'query' , 'time_zone' ] ; 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 = '/_sql/translate' ; return await this . transport . request ( { path , method , querystring , body } , options ) ; } }