in src/api/api/ingest.ts [197:242]
async simulate (this: That, params: T.IngestSimulateRequest | TB.IngestSimulateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.IngestSimulateResponse>
async simulate (this: That, params: T.IngestSimulateRequest | TB.IngestSimulateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.IngestSimulateResponse, unknown>>
async simulate (this: That, params: T.IngestSimulateRequest | TB.IngestSimulateRequest, options?: TransportRequestOptions): Promise<T.IngestSimulateResponse>
async simulate (this: That, params: T.IngestSimulateRequest | TB.IngestSimulateRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const acceptedBody: string[] = ['docs', 'pipeline']
const querystring: Record<string, any> = {}
// @ts-expect-error
const userBody: any = params?.body
let body: Record<string, any> | string
if (typeof userBody === 'string') {
body = userBody
} else {
body = userBody != null ? { ...userBody } : undefined
}
for (const key in params) {
if (acceptedBody.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body') {
// @ts-expect-error
querystring[key] = params[key]
}
}
let method = ''
let path = ''
if (params.id != null) {
method = body != null ? 'POST' : 'GET'
path = `/_ingest/pipeline/${encodeURIComponent(params.id.toString())}/_simulate`
} else {
method = body != null ? 'POST' : 'GET'
path = '/_ingest/pipeline/_simulate'
}
const meta: TransportRequestMetadata = {
name: 'ingest.simulate',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}