Source: api/api/get_all_pits.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. * Returns all PITs in the OpenSearch cluster.
  18. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#list-all-pits|Opensearch - List all PITs}
  19. * @memberOf API-PIT
  20. *
  21. * @param {Object} params
  22. *
  23. * @param {Object} [options] - Options for {@link Transport#request}
  24. * @param {function} [callback] - Callback that handles errors and response
  25. *
  26. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response-1|List all PITs Response}
  27. */
  28. function getAllPitsApi(params, options, callback) {
  29. [params, options, callback] = normalizeArguments(params, options, callback);
  30. let { method, body, ...querystring } = params;
  31. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  32. let path = '';
  33. if (method == null) method = 'GET';
  34. path = '/' + '_search' + '/' + 'point_in_time' + '/' + '_all';
  35. // build request object
  36. const request = {
  37. method,
  38. path,
  39. body: null,
  40. querystring,
  41. };
  42. return this.transport.request(request, options, callback);
  43. }
  44. module.exports = getAllPitsApi;