Skip to content

Commit

Permalink
Added Rollups and Transforms APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Jun 13, 2024
1 parent 708812e commit 742a15b
Show file tree
Hide file tree
Showing 8 changed files with 1,093 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
- Added Rollups API ([744](https://github.com/opensearch-project/opensearch-js/issues/744))
- Added Transforms API ([744](https://github.com/opensearch-project/opensearch-js/issues/744))
### Dependencies
- Bumps `@types/node` from 20.14.0 to 20.14.2
- Bumps `@babel/eslint-parser` from 7.24.6 to 7.24.7
Expand Down Expand Up @@ -247,4 +249,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `tsd` from 0.22.0 to 0.24.1
- Bumps `semver` from 7.3.7 to 7.3.8
### Fixed
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
249 changes: 249 additions & 0 deletions api/api/rollups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
/*
* 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.
*
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the 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';

/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */

const {
handleError,
encodePathParam,
normalizeArguments,
kConfigurationError,
} = require('../utils');

/** @namespace API-Rollups */

function RollupsApi(transport, ConfigurationError) {
this.transport = transport;
this[kConfigurationError] = ConfigurationError;
}
/**
* Delete index rollup.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#delete-an-index-rollup-job - rollups.delete}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {string} params.id - Rollup to access
*
* @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>|*}
*/
RollupsApi.prototype.delete = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
method = 'DELETE';
body = body || '';

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

/**
* Get an index rollup.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#get-an-index-rollup-job - rollups.get}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {string} params.id - Rollup to access
*
* @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>|*}
*/
RollupsApi.prototype.get = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
method = 'GET';
body = body || '';

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

/**
* Create or update index rollup.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job - rollups.put}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {number} [params.if_seq_no] - Only perform the operation if the document has this sequence number.
* @param {number} [params.if_primary_term] - Only perform the operation if the document has this primary term.
* @param {string} params.id - Rollup to access
* @param {object} [params.body]
*
* @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>|*}
*/
RollupsApi.prototype.put = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
method = 'PUT';
body = body || '';

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

/**
* Get a rollup's current status.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#explain-an-index-rollup-job - rollups.explain}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {string} params.id - Rollup to access
*
* @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>|*}
*/
RollupsApi.prototype.explain = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id, '_explain'].filter((c) => c != null).join('/');
method = 'GET';
body = body || '';

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

/**
* Start rollup.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job - rollups.start}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {string} params.id - Rollup to access
*
* @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>|*}
*/
RollupsApi.prototype.start = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id, '_start'].filter((c) => c != null).join('/');
method = 'POST';
body = body || '';

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

/**
* Stop rollup.
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job - rollups.stop}
*
* @memberOf API-Rollups
*
* @param {object} params
* @param {string} params.id - Rollup to access
*
* @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>|*}
*/
RollupsApi.prototype.stop = function (params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

if (params.id == null) {
const err = new this[kConfigurationError]('Missing required parameter: id');
return handleError(err, callback);
}

let { method, body, id, ...querystring } = params;
id = encodePathParam(id);

let path = ['_plugins', '_rollup', 'jobs', id, '_stop'].filter((c) => c != null).join('/');
method = 'POST';
body = body || '';

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

module.exports = RollupsApi;
Loading

0 comments on commit 742a15b

Please sign in to comment.