Source: api/api/delete_pit.js

  1. /*
  2. * Copyright OpenSearch Contributors
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * The OpenSearch Contributors require contributions made to
  6. * this file be licensed under the Apache-2.0 license or a
  7. * compatible open source license.
  8. *
  9. */
  10. 'use strict';
  11. /* eslint camelcase: 0 */
  12. /* eslint no-unused-vars: 0 */
  13. const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
  14. const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
  15. const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
  16. /**
  17. * Deletes one or several PITs. PITs are automatically deleted when the keep_alive time period elapses. However, to deallocate resources, you can delete a PIT using the Delete PIT API.
  18. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#delete-pits|Opensearch - Delete PITs}
  19. * @memberOf API-PIT
  20. *
  21. * @param {Object} params
  22. * @param {Object} params.body
  23. * @param {string[]} params.body.pit_id - The PIT IDs of the PITs to be deleted.
  24. *
  25. * @param {Object} [options] - Options for {@link Transport#request}
  26. * @param {function} [callback] - Callback that handles errors and response
  27. *
  28. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response-2|Delete PIT Response}
  29. */
  30. function deletePitApi(params, options, callback) {
  31. [params, options, callback] = normalizeArguments(params, options, callback);
  32. // check required parameters
  33. if (params['body'] == null) {
  34. const err = new this[kConfigurationError]('Missing required parameter: body');
  35. return handleError(err, callback);
  36. }
  37. let { method, body, ...querystring } = params;
  38. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  39. let path = '';
  40. if (method == null) method = 'DELETE';
  41. path = '/' + '_search' + '/' + 'point_in_time';
  42. // build request object
  43. const request = {
  44. method,
  45. path,
  46. body: body || '',
  47. querystring,
  48. };
  49. return this.transport.request(request, options, callback);
  50. }
  51. module.exports = deletePitApi;