Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-generated code for main #2636

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7152,7 +7152,7 @@ client.indices.putMapping({ index })
** *`dynamic_date_formats` (Optional, string[])*: If date detection is enabled then new string fields are checked
against 'dynamic_date_formats' and if the value matches then
a new date field is added instead of string.
** *`dynamic_templates` (Optional, Record<string, { mapping, runtime, match, path_match, unmatch, path_unmatch, match_mapping_type, unmatch_mapping_type, match_pattern }> | Record<string, { mapping, runtime, match, path_match, unmatch, path_unmatch, match_mapping_type, unmatch_mapping_type, match_pattern }>[])*: Specify dynamic templates for the mapping.
** *`dynamic_templates` (Optional, Record<string, { mapping, runtime, match, path_match, unmatch, path_unmatch, match_mapping_type, unmatch_mapping_type, match_pattern }>[])*: Specify dynamic templates for the mapping.
** *`_field_names` (Optional, { enabled })*: Control whether field names are enabled for the index.
** *`_meta` (Optional, Record<string, User-defined value>)*: A mapping type can have custom meta data associated with it. These are
not used at all by Elasticsearch, but can be used to store
Expand Down
156 changes: 148 additions & 8 deletions src/api/api/async_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,133 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }

interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}

const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']

export default class AsyncSearch {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'async_search.delete': {
path: [
'id'
],
body: [],
query: []
},
'async_search.get': {
path: [
'id'
],
body: [],
query: [
'keep_alive',
'typed_keys',
'wait_for_completion_timeout'
]
},
'async_search.status': {
path: [
'id'
],
body: [],
query: [
'keep_alive'
]
},
'async_search.submit': {
path: [
'index'
],
body: [
'aggregations',
'aggs',
'collapse',
'explain',
'ext',
'from',
'highlight',
'track_total_hits',
'indices_boost',
'docvalue_fields',
'knn',
'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'
],
query: [
'wait_for_completion_timeout',
'keep_alive',
'keep_on_completion',
'allow_no_indices',
'allow_partial_search_results',
'analyzer',
'analyze_wildcard',
'batched_reduce_size',
'ccs_minimize_roundtrips',
'default_operator',
'df',
'docvalue_fields',
'expand_wildcards',
'explain',
'ignore_throttled',
'ignore_unavailable',
'lenient',
'max_concurrent_shard_requests',
'preference',
'request_cache',
'routing',
'search_type',
'stats',
'stored_fields',
'suggest_field',
'suggest_mode',
'suggest_size',
'suggest_text',
'terminate_after',
'timeout',
'track_total_hits',
'track_scores',
'typed_keys',
'rest_total_hits_as_int',
'version',
'_source',
'_source_excludes',
'_source_includes',
'seq_no_primary_term',
'q',
'size',
'from',
'sort'
]
}
}
}

/**
Expand All @@ -51,7 +172,10 @@ export default class AsyncSearch {
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchDeleteResponse, unknown>>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchDeleteResponse>
async delete (this: That, params: T.AsyncSearchDeleteRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.delete']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -93,7 +217,10 @@ export default class AsyncSearch {
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.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, options?: TransportRequestOptions): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.get']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -135,7 +262,10 @@ export default class AsyncSearch {
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchStatusResponse, unknown>>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchStatusResponse>
async status (this: That, params: T.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['id']
const {
path: acceptedPath
} = this.acceptedParams['async_search.status']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -177,8 +307,12 @@ export default class AsyncSearch {
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.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, options?: TransportRequestOptions): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'knn', '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 {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['async_search.submit']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand All @@ -205,8 +339,14 @@ export default class AsyncSearch {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

Expand Down
82 changes: 74 additions & 8 deletions src/api/api/autoscaling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,59 @@ import {
TransportResult
} from '@elastic/transport'
import * as T from '../types'
interface That { transport: Transport }

interface That {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
}

const commonQueryParams = ['error_trace', 'filter_path', 'human', 'pretty']

export default class Autoscaling {
transport: Transport
acceptedParams: Record<string, { path: string[], body: string[], query: string[] }>
constructor (transport: Transport) {
this.transport = transport
this.acceptedParams = {
'autoscaling.delete_autoscaling_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout',
'timeout'
]
},
'autoscaling.get_autoscaling_capacity': {
path: [],
body: [],
query: [
'master_timeout'
]
},
'autoscaling.get_autoscaling_policy': {
path: [
'name'
],
body: [],
query: [
'master_timeout'
]
},
'autoscaling.put_autoscaling_policy': {
path: [
'name'
],
body: [
'policy'
],
query: [
'master_timeout',
'timeout'
]
}
}
}

/**
Expand All @@ -51,7 +98,10 @@ export default class Autoscaling {
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingDeleteAutoscalingPolicyResponse, unknown>>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingDeleteAutoscalingPolicyResponse>
async deleteAutoscalingPolicy (this: That, params: T.AutoscalingDeleteAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.delete_autoscaling_policy']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -93,7 +143,10 @@ export default class Autoscaling {
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingCapacityResponse, unknown>>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingCapacityResponse>
async getAutoscalingCapacity (this: That, params?: T.AutoscalingGetAutoscalingCapacityRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.get_autoscaling_capacity']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -133,7 +186,10 @@ export default class Autoscaling {
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingGetAutoscalingPolicyResponse, unknown>>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingGetAutoscalingPolicyResponse>
async getAutoscalingPolicy (this: That, params: T.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const {
path: acceptedPath
} = this.acceptedParams['autoscaling.get_autoscaling_policy']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand Down Expand Up @@ -175,8 +231,12 @@ export default class Autoscaling {
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AutoscalingPutAutoscalingPolicyResponse, unknown>>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<T.AutoscalingPutAutoscalingPolicyResponse>
async putAutoscalingPolicy (this: That, params: T.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['name']
const acceptedBody: string[] = ['policy']
const {
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this.acceptedParams['autoscaling.put_autoscaling_policy']

const userQuery = params?.querystring
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}

Expand All @@ -188,8 +248,14 @@ export default class Autoscaling {
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

Expand Down
Loading
Loading