Skip to content

Commit

Permalink
Fix ndjson APIs (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor authored May 6, 2022
1 parent 2cc0fd4 commit bda15ca
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 98 deletions.
166 changes: 87 additions & 79 deletions docs/reference.asciidoc

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/api/api/async_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export default class AsyncSearch {
return await this.transport.request({ path, method, querystring, body }, options)
}

async get<TDocument = unknown> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchGetResponse<TDocument>>
async get<TDocument = unknown> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchGetResponse<TDocument>, unknown>>
async get<TDocument = unknown> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchGetResponse<TDocument>>
async get<TDocument = unknown> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<any> {
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchGetResponse<TDocument, TAggregations>, unknown>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const querystring: Record<string, any> = {}
const body = undefined
Expand Down Expand Up @@ -109,10 +109,10 @@ export default class AsyncSearch {
return await this.transport.request({ path, method, querystring, body }, options)
}

async submit<TDocument = unknown> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchSubmitResponse<TDocument>>
async submit<TDocument = unknown> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchSubmitResponse<TDocument>, unknown>>
async submit<TDocument = unknown> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchSubmitResponse<TDocument>>
async submit<TDocument = unknown> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchSubmitResponse<TDocument, TAggregations>, unknown>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const querystring: Record<string, any> = {}
Expand Down
2 changes: 1 addition & 1 deletion src/api/api/bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ export default async function BulkApi<TDocument = unknown, TPartialDocument = un
method = 'POST'
path = '/_bulk'
}
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}
2 changes: 1 addition & 1 deletion src/api/api/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class Fleet {
method = body != null ? 'POST' : 'GET'
path = '/_fleet/_fleet_msearch'
}
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}

async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetSearchResponse<TDocument>>
Expand Down
2 changes: 1 addition & 1 deletion src/api/api/ml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ export default class Ml {

const method = 'POST'
const path = `/_ml/anomaly_detectors/${encodeURIComponent(params.job_id.toString())}/_data`
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}

async previewDataFrameAnalytics (this: That, params?: T.MlPreviewDataFrameAnalyticsRequest | TB.MlPreviewDataFrameAnalyticsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.MlPreviewDataFrameAnalyticsResponse>
Expand Down
2 changes: 1 addition & 1 deletion src/api/api/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ export default class Monitoring {

const method = 'POST'
const path = '/_monitoring/bulk'
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}
}
2 changes: 1 addition & 1 deletion src/api/api/msearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ export default async function MsearchApi<TDocument = unknown, TAggregations = Re
method = body != null ? 'POST' : 'GET'
path = '/_msearch'
}
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}
2 changes: 1 addition & 1 deletion src/api/api/msearch_template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ export default async function MsearchTemplateApi<TDocument = unknown, TAggregati
method = body != null ? 'POST' : 'GET'
path = '/_msearch/template'
}
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}
2 changes: 1 addition & 1 deletion src/api/api/text_structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ export default class TextStructure {

const method = 'POST'
const path = '/_text_structure/find_structure'
return await this.transport.request({ path, method, querystring, body }, options)
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
}
}
4 changes: 2 additions & 2 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5634,7 +5634,7 @@ export interface AsyncSearchGetRequest extends RequestBase {
wait_for_completion_timeout?: Time
}

export type AsyncSearchGetResponse<TDocument = unknown, AsyncSearchTAggregations = unknown> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, AsyncSearchTAggregations>
export type AsyncSearchGetResponse<TDocument = unknown, TAggregations = Record<AggregateName, AggregationsAggregate>> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, TAggregations>

export interface AsyncSearchStatusRequest extends RequestBase {
id: Id
Expand Down Expand Up @@ -5714,7 +5714,7 @@ export interface AsyncSearchSubmitRequest extends RequestBase {
runtime_mappings?: MappingRuntimeFields
}

export type AsyncSearchSubmitResponse<TDocument = unknown, AsyncSearchTAggregations = unknown> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, AsyncSearchTAggregations>
export type AsyncSearchSubmitResponse<TDocument = unknown, TAggregations = Record<AggregateName, AggregationsAggregate>> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, TAggregations>

export interface AutoscalingAutoscalingPolicy {
roles: string[]
Expand Down
4 changes: 2 additions & 2 deletions src/api/typesWithBodyKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5734,7 +5734,7 @@ export interface AsyncSearchGetRequest extends RequestBase {
wait_for_completion_timeout?: Time
}

export type AsyncSearchGetResponse<TDocument = unknown, AsyncSearchTAggregations = unknown> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, AsyncSearchTAggregations>
export type AsyncSearchGetResponse<TDocument = unknown, TAggregations = Record<AggregateName, AggregationsAggregate>> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, TAggregations>

export interface AsyncSearchStatusRequest extends RequestBase {
id: Id
Expand Down Expand Up @@ -5831,7 +5831,7 @@ export interface AsyncSearchSubmitRequest extends RequestBase {
}
}

export type AsyncSearchSubmitResponse<TDocument = unknown, AsyncSearchTAggregations = unknown> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, AsyncSearchTAggregations>
export type AsyncSearchSubmitResponse<TDocument = unknown, TAggregations = Record<AggregateName, AggregationsAggregate>> = AsyncSearchAsyncSearchDocumentResponseBase<TDocument, TAggregations>

export interface AutoscalingAutoscalingPolicy {
roles: string[]
Expand Down

0 comments on commit bda15ca

Please sign in to comment.