85 lines
3.2 KiB
TypeScript
85 lines
3.2 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and contributors
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/* eslint-disable import/export */
|
|
/* eslint-disable @typescript-eslint/no-misused-new */
|
|
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
|
|
// This file was automatically generated by elastic/elastic-client-generator-js
|
|
// DO NOT MODIFY IT BY HAND. Instead, modify the source open api file,
|
|
// and elastic/elastic-client-generator-js to regenerate this file again.
|
|
|
|
import {
|
|
Transport,
|
|
TransportRequestMetadata,
|
|
TransportRequestOptions,
|
|
TransportRequestOptionsWithMeta,
|
|
TransportRequestOptionsWithOutMeta,
|
|
TransportResult
|
|
} from '@elastic/transport'
|
|
import * as T from '../types'
|
|
|
|
interface That {
|
|
transport: Transport
|
|
}
|
|
|
|
const acceptedParams: Record<string, { path: string[], body: string[], query: string[] }> = {
|
|
delete_by_query_rethrottle: {
|
|
path: [
|
|
'task_id'
|
|
],
|
|
body: [],
|
|
query: [
|
|
'requests_per_second'
|
|
]
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Throttle a delete by query operation. Change the number of requests per second for a particular delete by query operation. Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.
|
|
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-by-query-rethrottle | Elasticsearch API documentation}
|
|
*/
|
|
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.DeleteByQueryRethrottleResponse>
|
|
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.DeleteByQueryRethrottleResponse, unknown>>
|
|
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<T.DeleteByQueryRethrottleResponse>
|
|
export default async function DeleteByQueryRethrottleApi (this: That, params: T.DeleteByQueryRethrottleRequest, options?: TransportRequestOptions): Promise<any> {
|
|
const {
|
|
path: acceptedPath
|
|
} = acceptedParams.delete_by_query_rethrottle
|
|
|
|
const userQuery = params?.querystring
|
|
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
|
|
|
|
let body: Record<string, any> | string | undefined
|
|
const userBody = params?.body
|
|
if (userBody != null) {
|
|
if (typeof userBody === 'string') {
|
|
body = userBody
|
|
} else {
|
|
body = { ...userBody }
|
|
}
|
|
}
|
|
|
|
for (const key in params) {
|
|
if (acceptedPath.includes(key)) {
|
|
continue
|
|
} else if (key !== 'body' && key !== 'querystring') {
|
|
// @ts-expect-error
|
|
querystring[key] = params[key]
|
|
}
|
|
}
|
|
|
|
const method = 'POST'
|
|
const path = `/_delete_by_query/${encodeURIComponent(params.task_id.toString())}/_rethrottle`
|
|
const meta: TransportRequestMetadata = {
|
|
name: 'delete_by_query_rethrottle',
|
|
pathParts: {
|
|
task_id: params.task_id
|
|
}
|
|
}
|
|
return await this.transport.request({ path, method, querystring, body, meta }, options)
|
|
}
|