-
Notifications
You must be signed in to change notification settings - Fork 122
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
Added point in time APIs #348
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the license header for new added file should be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ananzh I updated as per the suggestion but the license check fails. Do we need to fix that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think currently opensearch-js is using this header here. Pls double check.
Well, we have updated this header to the one I mentioned in the comment. However, it is not updated in opensearch-js and the header check is still checking the old one. To unblock you, I would suggest to use the old one and I will submit an issue or PR to update the header. Sorry for the inconvenience. |
||
* 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. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* eslint camelcase: 0 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the meaning of this two lines of eslint rules? could you provide some explains for adding these two lines? for example, is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just to keep it consistent with the other files, so that once we fix the auto-generation logic, we won't see any changes in these files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well I think I don't understand these two lines. Do you understand why we use these two lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK |
||
/* eslint no-unused-vars: 0 */ | ||
|
||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils'); | ||
const acceptedQuerystring = [ | ||
'allow_partial_pit_creation', | ||
'keep_alive', | ||
'preference', | ||
'routing', | ||
'pretty', | ||
'human', | ||
'error_trace', | ||
'source', | ||
'filter_path', | ||
]; | ||
const snakeCase = { | ||
allowPartialPitCreation: 'allow_partial_pit_creation', | ||
keepAlive: 'keep_alive', | ||
errorTrace: 'error_trace', | ||
filterPath: 'filter_path', | ||
}; | ||
|
||
/** | ||
* Creates a point in time. | ||
* <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#create-a-pit|Opensearch - Create a PIT} | ||
* @memberOf API-PIT | ||
* | ||
* @param {Object} params | ||
* @param {string} params.index - The name(s) of the target index(es) for the PIT. May contain a comma-separated list or a wildcard index pattern. | ||
ajygupta marked this conversation as resolved.
Show resolved
Hide resolved
ananzh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {string} params.keep_alive - The amount of time to keep the PIT | ||
* @param {string} [params.preference=random] - The node or the shard used to perform the search. | ||
* @param {string} [params.routing] - Specifies to route search requests to a specific shard. | ||
* @param {string} [params.expand_wildcards=open] - The type of index that can match the wildcard pattern. Supports comma-separated values. | ||
* @param {string} [params.allow_partial_pit_creation=false] - Specifies whether to create a PIT with partial failures. | ||
* | ||
* @param {Object} [options] - Options for {@link Transport#request} | ||
* @param {function} [callback] - Callback that handles errors and response | ||
* | ||
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response|Create PIT Response} | ||
*/ | ||
|
||
function createPitApi(params, options, callback) { | ||
[params, options, callback] = normalizeArguments(params, options, callback); | ||
|
||
// check required parameters | ||
if (params['index'] == null) { | ||
const err = new this[kConfigurationError]('Missing required parameter: index'); | ||
return handleError(err, callback); | ||
} | ||
|
||
if (params['keep_alive'] == null) { | ||
const err = new this[kConfigurationError]('Missing required parameter: keep_alive'); | ||
return handleError(err, callback); | ||
} | ||
|
||
let { method, body, index, ...querystring } = params; | ||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring); | ||
|
||
let path = ''; | ||
if (method == null) method = 'POST'; | ||
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'point_in_time'; | ||
ananzh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// build request object | ||
const request = { | ||
method, | ||
path, | ||
body: body || '', | ||
querystring, | ||
}; | ||
|
||
return this.transport.request(request, options, callback); | ||
} | ||
|
||
module.exports = createPitApi; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
ajygupta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 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. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* eslint camelcase: 0 */ | ||
/* eslint no-unused-vars: 0 */ | ||
|
||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils'); | ||
const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path']; | ||
const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }; | ||
|
||
/** | ||
* Deletes all PITs in the OpenSearch cluster. The Delete All PITs API deletes only local PITs or mixed PITs (PITs created in both local and remote clusters). It does not delete fully remote PITs. | ||
* <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#delete-pits|Opensearch - Delete PITs} | ||
ananzh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @memberOf API-PIT | ||
* | ||
* @param {Object} params | ||
* | ||
* @param {Object} [options] - Options for {@link Transport#request} | ||
* @param {function} [callback] - Callback that handles errors and response | ||
* | ||
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response-2|Delete all PITs Response} | ||
*/ | ||
function deleteAllPitsApi(params, options, callback) { | ||
[params, options, callback] = normalizeArguments(params, options, callback); | ||
|
||
let { method, body, ...querystring } = params; | ||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring); | ||
|
||
let path = ''; | ||
if (method == null) method = 'DELETE'; | ||
path = '/' + '_search' + '/' + 'point_in_time' + '/' + '_all'; | ||
|
||
// build request object | ||
const request = { | ||
method, | ||
path, | ||
body: body || '', | ||
querystring, | ||
}; | ||
|
||
return this.transport.request(request, options, callback); | ||
} | ||
|
||
module.exports = deleteAllPitsApi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment here for how a user can get this
pit_id
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand this completely. A particular point in time (PIT) is denoted by a
pit_id
. It's like a particular index is denoted by anindex_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we get a pit_id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We get it when we create a point in time.