Source: api/api/cat.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. /** @namespace API-CAT */
  32. const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
  33. const acceptedQuerystring = [
  34. 'format',
  35. 'local',
  36. 'h',
  37. 'help',
  38. 's',
  39. 'v',
  40. 'expand_wildcards',
  41. 'pretty',
  42. 'human',
  43. 'error_trace',
  44. 'source',
  45. 'filter_path',
  46. 'bytes',
  47. 'cluster_manager_timeout',
  48. 'master_timeout',
  49. 'fields',
  50. 'time',
  51. 'ts',
  52. 'health',
  53. 'pri',
  54. 'include_unloaded_segments',
  55. 'allow_no_match',
  56. 'allow_no_datafeeds',
  57. 'allow_no_jobs',
  58. 'from',
  59. 'size',
  60. 'full_id',
  61. 'include_bootstrap',
  62. 'active_only',
  63. 'detailed',
  64. 'index',
  65. 'ignore_unavailable',
  66. 'nodes',
  67. 'actions',
  68. 'parent_task_id',
  69. 'pri',
  70. ];
  71. const snakeCase = {
  72. expandWildcards: 'expand_wildcards',
  73. errorTrace: 'error_trace',
  74. filterPath: 'filter_path',
  75. clusterManagerTimeout: 'cluster_manager_timeout',
  76. masterTimeout: 'master_timeout',
  77. includeUnloadedSegments: 'include_unloaded_segments',
  78. allowNoMatch: 'allow_no_match',
  79. allowNoDatafeeds: 'allow_no_datafeeds',
  80. allowNoJobs: 'allow_no_jobs',
  81. fullId: 'full_id',
  82. includeBootstrap: 'include_bootstrap',
  83. activeOnly: 'active_only',
  84. ignoreUnavailable: 'ignore_unavailable',
  85. parentTaskId: 'parent_task_id',
  86. };
  87. function CatApi(transport, ConfigurationError) {
  88. this.transport = transport;
  89. this[kConfigurationError] = ConfigurationError;
  90. }
  91. /**
  92. * The CAT aliases operation lists the mapping of aliases to indices, plus routing and filtering information.
  93. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-aliases/ OpenSearch - CAT aliases}
  94. *
  95. * @memberOf API-CAT
  96. *
  97. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  98. * @param {string} [params.name] - To limit the information to specific aliases, provide the alias names seperated by commas.
  99. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster manager node.
  100. * @param {string} [params.expand_wildcards=open] - Expands wildcard expressions to concrete indices. Combine multiple values with commas. Supported values are 'all', 'open', 'closed', 'hidden', and 'none'. Default is 'open'.
  101. *
  102. * @param {Object} [options] - Options for {@link Transport#request}
  103. * @param {function} [callback] - Callback that handles errors and response
  104. *
  105. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-aliases/#response CAT aliases Response}
  106. */
  107. CatApi.prototype.aliases = function catAliasesApi(params, options, callback) {
  108. [params, options, callback] = normalizeArguments(params, options, callback);
  109. let { method, body, name, ...querystring } = params;
  110. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  111. let path = '';
  112. if (name != null) {
  113. if (method == null) method = 'GET';
  114. path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name);
  115. } else {
  116. if (method == null) method = 'GET';
  117. path = '/' + '_cat' + '/' + 'aliases';
  118. }
  119. // build request object
  120. const request = {
  121. method,
  122. path,
  123. body: null,
  124. querystring,
  125. };
  126. return this.transport.request(request, options, callback);
  127. };
  128. /**
  129. * The CAT allocation operation lists the allocation of disk space for indices and the number of shards on each node.
  130. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-allocation/ OpenSearch - CAT allocation}
  131. *
  132. * @memberOf API-CAT
  133. *
  134. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  135. * @param {string} [params.node_id] - To limit the information to specific nodes, provide the node names seperated by commas.
  136. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster manager node.
  137. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  138. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  139. *
  140. * @param {Object} [options] - Options for {@link Transport#request}
  141. * @param {function} [callback] - Callback that handles errors and response
  142. *
  143. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-allocation/#response CAT allocation Response}
  144. */
  145. CatApi.prototype.allocation = function catAllocationApi(params, options, callback) {
  146. [params, options, callback] = normalizeArguments(params, options, callback);
  147. let { method, body, nodeId, node_id, ...querystring } = params;
  148. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  149. let path = '';
  150. if ((node_id || nodeId) != null) {
  151. if (method == null) method = 'GET';
  152. path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId);
  153. } else {
  154. if (method == null) method = 'GET';
  155. path = '/' + '_cat' + '/' + 'allocation';
  156. }
  157. // build request object
  158. const request = {
  159. method,
  160. path,
  161. body: null,
  162. querystring,
  163. };
  164. return this.transport.request(request, options, callback);
  165. };
  166. /**
  167. * The CAT count operation lists the number of documents in your cluster.
  168. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-count/ OpenSearch - CAT count}
  169. *
  170. * @memberOf API-CAT
  171. *
  172. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  173. * @param {string} [params.index] - To see the number of documents in specific indices or aliases, provide the index/alias names seperated by commas.
  174. *
  175. * @param {Object} [options] - Options for {@link Transport#request}
  176. * @param {function} [callback] - Callback that handles errors and response
  177. *
  178. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-count/#response CAT count Response}
  179. */
  180. CatApi.prototype.count = function catCountApi(params, options, callback) {
  181. [params, options, callback] = normalizeArguments(params, options, callback);
  182. let { method, body, index, ...querystring } = params;
  183. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  184. let path = '';
  185. if (index != null) {
  186. if (method == null) method = 'GET';
  187. path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index);
  188. } else {
  189. if (method == null) method = 'GET';
  190. path = '/' + '_cat' + '/' + 'count';
  191. }
  192. // build request object
  193. const request = {
  194. method,
  195. path,
  196. body: null,
  197. querystring,
  198. };
  199. return this.transport.request(request, options, callback);
  200. };
  201. /**
  202. * The CAT fielddata operation lists the memory size used by each field per node.
  203. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-field-data/ OpenSearch - CAT fielddata}
  204. *
  205. * @memberOf API-CAT
  206. *
  207. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  208. * @param {string} [params.fields] - To limit the information to specific fields, provide the field names seperated by commas.
  209. *
  210. * @param {Object} [options] - Options for {@link Transport#request}
  211. * @param {function} [callback] - Callback that handles errors and response
  212. *
  213. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-field-data/#response CAT fielddata Response}
  214. */
  215. CatApi.prototype.fielddata = function catFielddataApi(params, options, callback) {
  216. [params, options, callback] = normalizeArguments(params, options, callback);
  217. let { method, body, fields, ...querystring } = params;
  218. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  219. let path = '';
  220. if (fields != null) {
  221. if (method == null) method = 'GET';
  222. path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields);
  223. } else {
  224. if (method == null) method = 'GET';
  225. path = '/' + '_cat' + '/' + 'fielddata';
  226. }
  227. // build request object
  228. const request = {
  229. method,
  230. path,
  231. body: null,
  232. querystring,
  233. };
  234. return this.transport.request(request, options, callback);
  235. };
  236. /**
  237. * The CAT health operation lists the status of the cluster, how long the cluster has been up, the number of nodes,
  238. * and other useful information that helps you analyze the health of your cluster.
  239. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-health/ OpenSearch - CAT health}
  240. *
  241. * @memberOf API-CAT
  242. *
  243. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  244. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  245. * @param {boolean} [params.ts=true] - If true, returns HH:MM:SS and Unix epoch timestamps.
  246. *
  247. * @param {Object} [options] - Options for {@link Transport#request}
  248. * @param {function} [callback] - Callback that handles errors and response
  249. *
  250. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-health/#response CAT health Response}
  251. */
  252. CatApi.prototype.health = function catHealthApi(params, options, callback) {
  253. [params, options, callback] = normalizeArguments(params, options, callback);
  254. let { method, body, ...querystring } = params;
  255. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  256. let path = '';
  257. if (method == null) method = 'GET';
  258. path = '/' + '_cat' + '/' + 'health';
  259. // build request object
  260. const request = {
  261. method,
  262. path,
  263. body: null,
  264. querystring,
  265. };
  266. return this.transport.request(request, options, callback);
  267. };
  268. /**
  269. * See the available operations in the CAT API
  270. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/index OpenSearch - CAT}
  271. *
  272. * @memberOf API-CAT
  273. *
  274. * @param {Object} params - (ignored)
  275. * @param {Object} [options] - Options for {@link Transport#request}
  276. * @param {function} [callback] - Callback that handles errors and response
  277. *
  278. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  279. */
  280. CatApi.prototype.help = function catHelpApi(params, options, callback) {
  281. [params, options, callback] = normalizeArguments(params, options, callback);
  282. let { method, body, ...querystring } = params;
  283. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  284. let path = '';
  285. if (method == null) method = 'GET';
  286. path = '/' + '_cat';
  287. // build request object
  288. const request = {
  289. method,
  290. path,
  291. body: null,
  292. querystring,
  293. };
  294. return this.transport.request(request, options, callback);
  295. };
  296. /**
  297. * The CAT indices operation lists information related to indices—how much disk space they are using, how many shards they have, their health status, and so on.
  298. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-indices/ OpenSearch - CAT indices}
  299. *
  300. * @memberOf API-CAT
  301. *
  302. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  303. * @param {string} [params.index] - To limit the information to specific indices, provide the index names seperated by commas.
  304. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  305. * @param {string} [params.health] - Limit indices based on their health status. Supported values are 'green', 'yellow', and 'red'.
  306. * @param {boolean} [params.include_unloaded_segments=false] - Whether to include information from segments not loaded into memory.
  307. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  308. * @param {boolean} [params.pri=false] - Whether to return information only from the primary shards.
  309. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  310. * @param {string} [params.expand_wildcards=open] - Expands wildcard expressions to concrete indices. Combine multiple values with commas. Supported values are 'all', 'open', 'closed', 'hidden', and 'none'.
  311. *
  312. * @param {Object} [options] - Options for {@link Transport#request}
  313. * @param {function} [callback] - Callback that handles errors and response
  314. *
  315. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-indices/#response CAT indices Response}
  316. */
  317. CatApi.prototype.indices = function catIndicesApi(params, options, callback) {
  318. [params, options, callback] = normalizeArguments(params, options, callback);
  319. let { method, body, index, ...querystring } = params;
  320. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  321. let path = '';
  322. if (index != null) {
  323. if (method == null) method = 'GET';
  324. path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index);
  325. } else {
  326. if (method == null) method = 'GET';
  327. path = '/' + '_cat' + '/' + 'indices';
  328. }
  329. // build request object
  330. const request = {
  331. method,
  332. path,
  333. body: null,
  334. querystring,
  335. };
  336. return this.transport.request(request, options, callback);
  337. };
  338. /**
  339. * The CAT cluster manager operation lists information that helps identify the elected cluster manager node.
  340. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-cluster_manager/ OpenSearch - CAT cluster manager}
  341. *
  342. * @memberOf API-CAT
  343. *
  344. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters}
  345. * @param {Object} [options] - Options for {@link Transport#request}
  346. * @param {function} [callback] - Callback that handles errors and response
  347. *
  348. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-cluster_manager/#response CAT cluster manager Response}
  349. */
  350. CatApi.prototype.cluster_manager = function catClusterManagerApi(params, options, callback) {
  351. [params, options, callback] = normalizeArguments(params, options, callback);
  352. let { method, body, ...querystring } = params;
  353. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  354. let path = '';
  355. if (method == null) method = 'GET';
  356. path = '/' + '_cat' + '/' + 'cluster_manager';
  357. // build request object
  358. const request = {
  359. method,
  360. path,
  361. body: null,
  362. querystring,
  363. };
  364. return this.transport.request(request, options, callback);
  365. };
  366. /**
  367. * // TODO: delete CatApi.prototype.master when it is removed from OpenSearch
  368. * @deprecated use CatApi.prototype.cluster_manager instead
  369. */
  370. CatApi.prototype.master = function catMasterApi(params, options, callback) {
  371. [params, options, callback] = normalizeArguments(params, options, callback);
  372. let { method, body, ...querystring } = params;
  373. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  374. let path = '';
  375. if (method == null) method = 'GET';
  376. path = '/' + '_cat' + '/' + 'master';
  377. // build request object
  378. const request = {
  379. method,
  380. path,
  381. body: null,
  382. querystring,
  383. };
  384. return this.transport.request(request, options, callback);
  385. };
  386. /**
  387. * The CAT nodeattrs operation lists the attributes of custom nodes.
  388. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-nodeattrs/ OpenSearch - CAT aliases}
  389. *
  390. * @memberOf API-CAT
  391. *
  392. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  393. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster manager node.
  394. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  395. *
  396. * @param {Object} [options] - Options for {@link Transport#request}
  397. * @param {function} [callback] - Callback that handles errors and response
  398. *
  399. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-nodeattrs/#response CAT nodeattrs Response}
  400. */
  401. CatApi.prototype.nodeattrs = function catNodeattrsApi(params, options, callback) {
  402. [params, options, callback] = normalizeArguments(params, options, callback);
  403. let { method, body, ...querystring } = params;
  404. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  405. let path = '';
  406. if (method == null) method = 'GET';
  407. path = '/' + '_cat' + '/' + 'nodeattrs';
  408. // build request object
  409. const request = {
  410. method,
  411. path,
  412. body: null,
  413. querystring,
  414. };
  415. return this.transport.request(request, options, callback);
  416. };
  417. /**
  418. * The CAT nodes operation lists node-level information, including node roles and load metrics.
  419. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-nodes/ OpenSearch - CAT nodes}
  420. *
  421. * @memberOf API-CAT
  422. *
  423. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  424. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  425. * @param {boolean} [params.full_id=false] - If true, return the full node ID. If false, return the shortened node ID.
  426. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster_manager node.
  427. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  428. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  429. * @param {boolean} [params.include_unloaded_segments=false] - Whether to include information from segments not loaded into memory.
  430. *
  431. * @param {Object} [options] - Options for {@link Transport#request}
  432. * @param {function} [callback] - Callback that handles errors and response
  433. *
  434. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-nodes/#response CAT nodes Response}
  435. */
  436. CatApi.prototype.nodes = function catNodesApi(params, options, callback) {
  437. [params, options, callback] = normalizeArguments(params, options, callback);
  438. let { method, body, ...querystring } = params;
  439. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  440. let path = '';
  441. if (method == null) method = 'GET';
  442. path = '/' + '_cat' + '/' + 'nodes';
  443. // build request object
  444. const request = {
  445. method,
  446. path,
  447. body: null,
  448. querystring,
  449. };
  450. return this.transport.request(request, options, callback);
  451. };
  452. /**
  453. * The CAT pending tasks operation lists the progress of all pending tasks, including task priority and time in queue.
  454. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-pending-tasks/ OpenSearch - CAT pending tasks}
  455. *
  456. * @memberOf API-CAT
  457. *
  458. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  459. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster_manager node.
  460. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  461. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  462. *
  463. * @param {Object} [options] - Options for {@link Transport#request}
  464. * @param {function} [callback] - Callback that handles errors and response
  465. *
  466. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-pending-tasks/#response CAT pending tasks Response}
  467. */
  468. CatApi.prototype.pendingTasks = function catPendingTasksApi(params, options, callback) {
  469. [params, options, callback] = normalizeArguments(params, options, callback);
  470. let { method, body, ...querystring } = params;
  471. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  472. let path = '';
  473. if (method == null) method = 'GET';
  474. path = '/' + '_cat' + '/' + 'pending_tasks';
  475. // build request object
  476. const request = {
  477. method,
  478. path,
  479. body: null,
  480. querystring,
  481. };
  482. return this.transport.request(request, options, callback);
  483. };
  484. /**
  485. * The CAT plugins operation lists the names, components, and versions of the installed plugins.
  486. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-plugins/ OpenSearch - CAT plugins}
  487. *
  488. * @memberOf API-CAT
  489. *
  490. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  491. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster_manager node.
  492. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  493. *
  494. * @param {Object} [options] - Options for {@link Transport#request}
  495. * @param {function} [callback] - Callback that handles errors and response
  496. *
  497. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-plugins/#response CAT plugins Response}
  498. */
  499. CatApi.prototype.plugins = function catPluginsApi(params, options, callback) {
  500. [params, options, callback] = normalizeArguments(params, options, callback);
  501. let { method, body, ...querystring } = params;
  502. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  503. let path = '';
  504. if (method == null) method = 'GET';
  505. path = '/' + '_cat' + '/' + 'plugins';
  506. // build request object
  507. const request = {
  508. method,
  509. path,
  510. body: null,
  511. querystring,
  512. };
  513. return this.transport.request(request, options, callback);
  514. };
  515. /**
  516. * The CAT recovery operation lists all completed and ongoing index and shard recoveries.
  517. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-recovery/ OpenSearch - CAT recovery}
  518. *
  519. * @memberOf API-CAT
  520. *
  521. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  522. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  523. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  524. * @param {boolean} [params.active_only=false] - Whether to only include ongoing shard recoveries.
  525. * @param {boolean} [params.detailed=false] - Whether to only include ongoing shard recoveries.
  526. *
  527. * @param {Object} [options] - Options for {@link Transport#request}
  528. * @param {function} [callback] - Callback that handles errors and response
  529. *
  530. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-recovery/#response CAT recovery Response}
  531. */
  532. CatApi.prototype.recovery = function catRecoveryApi(params, options, callback) {
  533. [params, options, callback] = normalizeArguments(params, options, callback);
  534. let { method, body, index, ...querystring } = params;
  535. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  536. let path = '';
  537. if (index != null) {
  538. if (method == null) method = 'GET';
  539. path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index);
  540. } else {
  541. if (method == null) method = 'GET';
  542. path = '/' + '_cat' + '/' + 'recovery';
  543. }
  544. // build request object
  545. const request = {
  546. method,
  547. path,
  548. body: null,
  549. querystring,
  550. };
  551. return this.transport.request(request, options, callback);
  552. };
  553. /**
  554. * The CAT repositories operation lists all completed and ongoing index and shard recoveries.
  555. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-repositories/ OpenSearch - CAT repositories}
  556. *
  557. * @memberOf API-CAT
  558. *
  559. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  560. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster_manager node.
  561. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  562. *
  563. * @param {Object} [options] - Options for {@link Transport#request}
  564. * @param {function} [callback] - Callback that handles errors and response
  565. *
  566. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-repositories/#response CAT repositories Response}
  567. */
  568. CatApi.prototype.repositories = function catRepositoriesApi(params, options, callback) {
  569. [params, options, callback] = normalizeArguments(params, options, callback);
  570. let { method, body, ...querystring } = params;
  571. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  572. let path = '';
  573. if (method == null) method = 'GET';
  574. path = '/' + '_cat' + '/' + 'repositories';
  575. // build request object
  576. const request = {
  577. method,
  578. path,
  579. body: null,
  580. querystring,
  581. };
  582. return this.transport.request(request, options, callback);
  583. };
  584. /**
  585. * The cat segments operation lists Lucene segment-level information for each index.
  586. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-segments/ OpenSearch - CAT segments}
  587. *
  588. * @memberOf API-CAT
  589. *
  590. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  591. * @param {string} [params.index] - To see only the information about segments of specific indices, provide the index names seperated by commas.
  592. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  593. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  594. *
  595. * @param {Object} [options] - Options for {@link Transport#request}
  596. * @param {function} [callback] - Callback that handles errors and response
  597. *
  598. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-segments/#response CAT segments Response}
  599. */
  600. CatApi.prototype.segments = function catSegmentsApi(params, options, callback) {
  601. [params, options, callback] = normalizeArguments(params, options, callback);
  602. let { method, body, index, ...querystring } = params;
  603. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  604. let path = '';
  605. if (index != null) {
  606. if (method == null) method = 'GET';
  607. path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index);
  608. } else {
  609. if (method == null) method = 'GET';
  610. path = '/' + '_cat' + '/' + 'segments';
  611. }
  612. // build request object
  613. const request = {
  614. method,
  615. path,
  616. body: null,
  617. querystring,
  618. };
  619. return this.transport.request(request, options, callback);
  620. };
  621. /**
  622. * The CAT shards operation lists the state of all primary and replica shards and how they are distributed.
  623. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-shards/ OpenSearch - CAT shards}
  624. *
  625. * @memberOf API-CAT
  626. *
  627. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  628. * @param {string} [params.index] - To see only the information about shards of specific indices, provide the index names seperated by commas.
  629. * @param {string} [params.bytes] - Specify the units for byte size. For example, '7kb' or '6gb'.
  630. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster_manager node.
  631. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  632. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  633. *
  634. * @param {Object} [options] - Options for {@link Transport#request}
  635. * @param {function} [callback] - Callback that handles errors and response
  636. *
  637. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-shards/#response CAT shards Response}
  638. */
  639. CatApi.prototype.shards = function catShardsApi(params, options, callback) {
  640. [params, options, callback] = normalizeArguments(params, options, callback);
  641. let { method, body, index, ...querystring } = params;
  642. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  643. let path = '';
  644. if (index != null) {
  645. if (method == null) method = 'GET';
  646. path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index);
  647. } else {
  648. if (method == null) method = 'GET';
  649. path = '/' + '_cat' + '/' + 'shards';
  650. }
  651. // build request object
  652. const request = {
  653. method,
  654. path,
  655. body: null,
  656. querystring,
  657. };
  658. return this.transport.request(request, options, callback);
  659. };
  660. /**
  661. * The CAT snapshots operation lists all snapshots for a repository.
  662. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-snapshots/ OpenSearch - CAT snapshots}
  663. *
  664. * @memberOf API-CAT
  665. *
  666. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  667. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  668. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  669. *
  670. * @param {Object} [options] - Options for {@link Transport#request}
  671. * @param {function} [callback] - Callback that handles errors and response
  672. *
  673. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-snapshots/#response CAT snapshots Response}
  674. */
  675. CatApi.prototype.snapshots = function catSnapshotsApi(params, options, callback) {
  676. [params, options, callback] = normalizeArguments(params, options, callback);
  677. let { method, body, repository, ...querystring } = params;
  678. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  679. let path = '';
  680. if (repository != null) {
  681. if (method == null) method = 'GET';
  682. path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository);
  683. } else {
  684. if (method == null) method = 'GET';
  685. path = '/' + '_cat' + '/' + 'snapshots';
  686. }
  687. // build request object
  688. const request = {
  689. method,
  690. path,
  691. body: null,
  692. querystring,
  693. };
  694. return this.transport.request(request, options, callback);
  695. };
  696. /**
  697. * The CAT tasks operation lists the progress of all tasks currently running on your cluster.
  698. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-tasks/ OpenSearch - CAT tasks}
  699. *
  700. * @memberOf API-CAT
  701. *
  702. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  703. * @param {string} [params.nodes] - A comma-separated list of node IDs or names to limit the returned information. Use '_local' to return information from the node you’re connecting to, specify the node name to get information from specific nodes, or keep the parameter empty to get information from all nodes.
  704. * @param {string} [params.time] - Specify the units for time. For example, '5d' or '7h'.
  705. * @param {boolean} [params.detailed=false] - Returns detailed task information.
  706. * @param {string} [params.parent_task_id] - Returns tasks with a specified parent task ID (node_id:task_number). Keep empty or set to -1 to return all.
  707. *
  708. * @param {Object} [options] - Options for {@link Transport#request}
  709. * @param {function} [callback] - Callback that handles errors and response
  710. *
  711. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-tasks/#response CAT tasks Response}
  712. */
  713. CatApi.prototype.tasks = function catTasksApi(params, options, callback) {
  714. [params, options, callback] = normalizeArguments(params, options, callback);
  715. let { method, body, ...querystring } = params;
  716. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  717. let path = '';
  718. if (method == null) method = 'GET';
  719. path = '/' + '_cat' + '/' + 'tasks';
  720. // build request object
  721. const request = {
  722. method,
  723. path,
  724. body: null,
  725. querystring,
  726. };
  727. return this.transport.request(request, options, callback);
  728. };
  729. /**
  730. * The CAT templates operation lists the names, patterns, order numbers, and version numbers of index templates.
  731. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-templates/ OpenSearch - CAT templates}
  732. *
  733. * @memberOf API-CAT
  734. *
  735. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  736. * @param {boolean} [params.name] - If you want to limit it to a specific template or pattern, provide the template name or pattern.
  737. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster manager node.
  738. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  739. *
  740. * @param {Object} [options] - Options for {@link Transport#request}
  741. * @param {function} [callback] - Callback that handles errors and response
  742. *
  743. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-templates/#response CAT templates Response}
  744. */
  745. CatApi.prototype.templates = function catTemplatesApi(params, options, callback) {
  746. [params, options, callback] = normalizeArguments(params, options, callback);
  747. let { method, body, name, ...querystring } = params;
  748. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  749. let path = '';
  750. if (name != null) {
  751. if (method == null) method = 'GET';
  752. path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name);
  753. } else {
  754. if (method == null) method = 'GET';
  755. path = '/' + '_cat' + '/' + 'templates';
  756. }
  757. // build request object
  758. const request = {
  759. method,
  760. path,
  761. body: null,
  762. querystring,
  763. };
  764. return this.transport.request(request, options, callback);
  765. };
  766. /**
  767. * The CAT thread pool operation lists the active, queued, and rejected threads of different thread pools on each node.
  768. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cat/cat-thread-pool/ OpenSearch - CAT thread pool}
  769. *
  770. * @memberOf API-CAT
  771. *
  772. * @param {Object} params - Accepts {@link https://opensearch.org/docs/latest/api-reference/cat/index#optional-query-parameters - common CAT parameters} along with the following unique parameters:
  773. * @param {boolean} [params.local=false] - Whether to return information from the local node only instead of from the cluster manager node.
  774. * @param {string} [params.cluster_manager_timeout=30s] - The amount of time to wait for a connection to the cluster manager node.
  775. *
  776. * @param {Object} [options] - Options for {@link Transport#request}
  777. * @param {function} [callback] - Callback that handles errors and response
  778. *
  779. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/api-reference/cat/cat-thread-pool/#response CAT thread pool Response}
  780. */
  781. CatApi.prototype.threadPool = function catThreadPoolApi(params, options, callback) {
  782. [params, options, callback] = normalizeArguments(params, options, callback);
  783. let { method, body, threadPoolPatterns, thread_pool_patterns, ...querystring } = params;
  784. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  785. let path = '';
  786. if ((thread_pool_patterns || threadPoolPatterns) != null) {
  787. if (method == null) method = 'GET';
  788. path =
  789. '/' +
  790. '_cat' +
  791. '/' +
  792. 'thread_pool' +
  793. '/' +
  794. encodeURIComponent(thread_pool_patterns || threadPoolPatterns);
  795. } else {
  796. if (method == null) method = 'GET';
  797. path = '/' + '_cat' + '/' + 'thread_pool';
  798. }
  799. // build request object
  800. const request = {
  801. method,
  802. path,
  803. body: null,
  804. querystring,
  805. };
  806. return this.transport.request(request, options, callback);
  807. };
  808. Object.defineProperties(CatApi.prototype, {
  809. pending_tasks: {
  810. get() {
  811. return this.pendingTasks;
  812. },
  813. },
  814. thread_pool: {
  815. get() {
  816. return this.threadPool;
  817. },
  818. },
  819. });
  820. module.exports = CatApi;