Skip to content

Commit

Permalink
Auto Generated API - 3.0.0-beta.4
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Aug 16, 2024
1 parent 5ca2ecb commit 64b9cfc
Show file tree
Hide file tree
Showing 790 changed files with 48,534 additions and 37,120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- name: Install
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
ruby-version: 16.x
node-version: 18.x
- name: Install Tools
run: |
sudo apt install -y jq
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
fail-fast: false
matrix:
entry:
- { node_version: '16.x', opensearch_ref: '1.x' }
- { node_version: '16.x', opensearch_ref: '2.0' }
- { node_version: '16.x', opensearch_ref: '2.x' }
- { node_version: '16.x', opensearch_ref: 'main' }
- { node_version: '18.x', opensearch_ref: '1.x' }
- { node_version: '18.x', opensearch_ref: '2.0' }
- { node_version: '18.x', opensearch_ref: '2.x' }
- { node_version: '18.x', opensearch_ref: 'main' }
steps:
- name: Checkout OpenSearch
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]

env:
SECURE_INTEGRATION: false
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]

env:
SECURE_INTEGRATION: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macOS-13]

steps:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jspm_packages
.idea

# opensearch repo or binary files
opensearch*
!opensearch_dashboards*
!opensearchDashboards*

Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [3.0.0]
### Added
### Dependencies
### Changed
- All API functions are now generated from the OpenSearch API specification.
- API request and response types are now generated from the OpenSearch API specification.
- Overhauled API codebase and break it into smaller, more manageable files for better readability and maintainability.
- API modules and functions are now lazily loaded to improve performance.
### Deprecated
### Removed
- *BREAKING* Removed support for API param aliases. That is, the API functions now only accept params with the exact names specified in the OpenSearch API specification.
- *BREAKING* Removed support for snake_cased API function names. All API functions are now camelCased only to conform to JavaScript naming conventions.
- *BREAKING* Removed support for Node.js 10 through 16. The minimum supported Node.js version is now 18.
### Fixed
### Security

## [Unreleased]
### Added
### Dependencies
Expand Down
1,403 changes: 1,403 additions & 0 deletions api/OpenSearchAPI.d.ts

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions api/OpenSearchAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* This file was generated from OpenSearch API Spec. Do not edit it
* manually. If you want to make changes, either update the spec or
* the API generator.
*/

'use strict'

const { kConfigErr, apiFunc } = require('./utils')
const kApiModules = Symbol('api modules')
const kApiLoader = Symbol('api loader')

class OpenSearchAPI {
constructor (opts) {
this[kConfigErr] = opts.ConfigurationError
this[kApiModules] = {}
this[kApiLoader] = function (path) {
if (this[kApiModules][path] === undefined) {
const ApiModule = require(path)
this[kApiModules][path] = new ApiModule(this)
}
return this[kApiModules][path]
}

// Setup Root API Functions
/** @namespace API-Core */
const cache = {}
this.bulk = apiFunc(this, cache, './_core/bulk')
this.clearScroll = apiFunc(this, cache, './_core/clear_scroll')
this.count = apiFunc(this, cache, './_core/count')
this.create = apiFunc(this, cache, './_core/create')
this.createPit = apiFunc(this, cache, './_core/create_pit')
this.delete = apiFunc(this, cache, './_core/delete')
this.deleteAllPits = apiFunc(this, cache, './_core/delete_all_pits')
this.deleteByQuery = apiFunc(this, cache, './_core/delete_by_query')
this.deleteByQueryRethrottle = apiFunc(this, cache, './_core/delete_by_query_rethrottle')
this.deletePit = apiFunc(this, cache, './_core/delete_pit')
this.deleteScript = apiFunc(this, cache, './_core/delete_script')
this.exists = apiFunc(this, cache, './_core/exists')
this.existsSource = apiFunc(this, cache, './_core/exists_source')
this.explain = apiFunc(this, cache, './_core/explain')
this.fieldCaps = apiFunc(this, cache, './_core/field_caps')
this.get = apiFunc(this, cache, './_core/get')
this.getAllPits = apiFunc(this, cache, './_core/get_all_pits')
this.getScript = apiFunc(this, cache, './_core/get_script')
this.getScriptContext = apiFunc(this, cache, './_core/get_script_context')
this.getScriptLanguages = apiFunc(this, cache, './_core/get_script_languages')
this.getSource = apiFunc(this, cache, './_core/get_source')
this.index = apiFunc(this, cache, './_core/index')
this.info = apiFunc(this, cache, './_core/info')
this.mget = apiFunc(this, cache, './_core/mget')
this.msearch = apiFunc(this, cache, './_core/msearch')
this.msearchTemplate = apiFunc(this, cache, './_core/msearch_template')
this.mtermvectors = apiFunc(this, cache, './_core/mtermvectors')
this.ping = apiFunc(this, cache, './_core/ping')
this.putScript = apiFunc(this, cache, './_core/put_script')
this.rankEval = apiFunc(this, cache, './_core/rank_eval')
this.reindex = apiFunc(this, cache, './_core/reindex')
this.reindexRethrottle = apiFunc(this, cache, './_core/reindex_rethrottle')
this.renderSearchTemplate = apiFunc(this, cache, './_core/render_search_template')
this.scriptsPainlessExecute = apiFunc(this, cache, './_core/scripts_painless_execute')
this.scroll = apiFunc(this, cache, './_core/scroll')
this.search = apiFunc(this, cache, './_core/search')
this.searchShards = apiFunc(this, cache, './_core/search_shards')
this.searchTemplate = apiFunc(this, cache, './_core/search_template')
this.termvectors = apiFunc(this, cache, './_core/termvectors')
this.update = apiFunc(this, cache, './_core/update')
this.updateByQuery = apiFunc(this, cache, './_core/update_by_query')
this.updateByQueryRethrottle = apiFunc(this, cache, './_core/update_by_query_rethrottle')

// Setup API Modules
Object.defineProperties(this, {
cat: { get() { return this[kApiLoader]('./cat/_api') } },
cluster: { get() { return this[kApiLoader]('./cluster/_api') } },
danglingIndices: { get() { return this[kApiLoader]('./dangling_indices/_api') } },
http: { get() { return this[kApiLoader]('./http/_api') } },
indices: { get() { return this[kApiLoader]('./indices/_api') } },
ingest: { get() { return this[kApiLoader]('./ingest/_api') } },
knn: { get() { return this[kApiLoader]('./knn/_api') } },
ml: { get() { return this[kApiLoader]('./ml/_api') } },
nodes: { get() { return this[kApiLoader]('./nodes/_api') } },
notifications: { get() { return this[kApiLoader]('./notifications/_api') } },
ppl: { get() { return this[kApiLoader]('./ppl/_api') } },
remoteStore: { get() { return this[kApiLoader]('./remote_store/_api') } },
rollups: { get() { return this[kApiLoader]('./rollups/_api') } },
searchPipeline: { get() { return this[kApiLoader]('./search_pipeline/_api') } },
security: { get() { return this[kApiLoader]('./security/_api') } },
snapshot: { get() { return this[kApiLoader]('./snapshot/_api') } },
sql: { get() { return this[kApiLoader]('./sql/_api') } },
tasks: { get() { return this[kApiLoader]('./tasks/_api') } },
transforms: { get() { return this[kApiLoader]('./transforms/_api') } },
})
}
}

module.exports = OpenSearchAPI;
49 changes: 49 additions & 0 deletions api/_core/bulk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* This file was generated from OpenSearch API Spec. Do not edit it
* manually. If you want to make changes, either update the spec or
* the API generator.
*/

import { ApiResponse } from '../../lib/Transport'
import * as Global from '../_types/_global'
import * as Core_Search from '../_types/_core.search'
import * as Common from '../_types/_common'
import * as Core_Bulk from '../_types/_core.bulk'

export interface Bulk_Request extends Global.Params {
_source?: Core_Search.SourceConfigParam;
_source_excludes?: Common.Fields;
_source_includes?: Common.Fields;
body: Bulk_RequestBody;
index?: Common.IndexName;
pipeline?: string;
refresh?: Common.Refresh;
require_alias?: boolean;
routing?: Common.Routing;
timeout?: Common.Duration;
type?: string;
wait_for_active_shards?: Common.WaitForActiveShards;
}

export type Bulk_RequestBody = Core_Bulk.OperationContainer | Core_Bulk.UpdateAction | Record<string, any>[]

export interface Bulk_Response extends ApiResponse {
body: Bulk_ResponseBody;
}

export interface Bulk_ResponseBody {
errors: boolean;
ingest_took?: number;
items: Record<string, Core_Bulk.ResponseItem>[];
took: number;
}

58 changes: 58 additions & 0 deletions api/_core/bulk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* This file was generated from OpenSearch API Spec. Do not edit it
* manually. If you want to make changes, either update the spec or
* the API generator.
*/

'use strict'

const { normalizeArguments, parsePathParam, handleMissingParam } = require('../utils');

/**
* Allows to perform multiple index/update/delete operations in a single request.
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk/ - bulk}
*
* @memberOf API-Core
*
* @param {object} params
* @param {string} [params._source] - `true` or `false` to return the `_source` field or not, or a list of fields to return.
* @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude from the response.
* @param {string} [params._source_includes] - A comma-separated list of source fields to include in the response.
* @param {string} [params.pipeline] - ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter.
* @param {string} [params.refresh] - If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`.
* @param {boolean} [params.require_alias=false] - If `true`, the request's actions must target an index alias.
* @param {string} [params.routing] - Custom value used to route operations to a specific shard.
* @param {string} [params.timeout] - Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
* @param {string} [params.type] - Default document type for items which don't provide one.
* @param {string} [params.wait_for_active_shards] - The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
* @param {string} [params.index] - Name of the data stream, index, or index alias to perform bulk actions on.
* @param {array} params.body - The operation definition and data (action-data pairs), separated by newlines
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
*
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
*/
function bulkFunc(params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);
if (params.body == null) return handleMissingParam('body', this, callback);

let { body, index, ...querystring } = params;
index = parsePathParam(index);

const path = ['/', index, '/_bulk'].filter(c => c).join('').replace('//', '/');
const method = index == null ? 'POST' : 'PUT';

return this.transport.request({ method, path, querystring, bulkBody: body }, options, callback);
}

module.exports = bulkFunc;
37 changes: 37 additions & 0 deletions api/_core/clear_scroll.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* This file was generated from OpenSearch API Spec. Do not edit it
* manually. If you want to make changes, either update the spec or
* the API generator.
*/

import { ApiResponse } from '../../lib/Transport'
import * as Global from '../_types/_global'
import * as Common from '../_types/_common'

export interface ClearScroll_Request extends Global.Params {
body?: ClearScroll_RequestBody;
scroll_id?: Common.ScrollIds;
}

export interface ClearScroll_RequestBody {
scroll_id?: Common.ScrollIds;
}

export interface ClearScroll_Response extends ApiResponse {
body: ClearScroll_ResponseBody;
}

export interface ClearScroll_ResponseBody {
num_freed: number;
succeeded: boolean;
}

Loading

0 comments on commit 64b9cfc

Please sign in to comment.