Source: api/api/info.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. /*
  11. * Licensed to Elasticsearch B.V. under one or more contributor
  12. * license agreements. See the NOTICE file distributed with
  13. * this work for additional information regarding copyright
  14. * ownership. Elasticsearch B.V. licenses this file to you under
  15. * the Apache License, Version 2.0 (the "License"); you may
  16. * not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at
  18. *
  19. * http://www.apache.org/licenses/LICENSE-2.0
  20. *
  21. * Unless required by applicable law or agreed to in writing,
  22. * software distributed under the License is distributed on an
  23. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24. * KIND, either express or implied. See the License for the
  25. * specific language governing permissions and limitations
  26. * under the License.
  27. */
  28. 'use strict';
  29. /* eslint camelcase: 0 */
  30. /* eslint no-unused-vars: 0 */
  31. const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
  32. const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
  33. const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
  34. /**
  35. * Returns basic information about the cluster.
  36. *
  37. * @memberOf API-Cluster
  38. *
  39. * @param {Object} params - (Unused)
  40. * @param {Object} options - Options for {@link Transport#request}
  41. * @param {function} callback - Callback that handles errors and response
  42. *
  43. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  44. */
  45. function infoApi(params, options, callback) {
  46. [params, options, callback] = normalizeArguments(params, options, callback);
  47. let { method, body, ...querystring } = params;
  48. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  49. let path = '';
  50. if (method == null) method = 'GET';
  51. path = '/';
  52. // build request object
  53. const request = {
  54. method,
  55. path,
  56. body: null,
  57. querystring,
  58. };
  59. return this.transport.request(request, options, callback);
  60. }
  61. module.exports = infoApi;