Files
opensearch-pyd/opensearchpy/client/nodes.py
T

223 lines
8.4 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# 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.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
#
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
2020-04-23 11:22:08 -05:00
2022-10-04 00:15:18 +05:30
# ----------------------------------------------------
# THIS CODE IS GENERATED AND MANUAL EDITS WILL BE LOST.
#
# To contribute, kindly make essential modifications through either the "opensearch-py client generator":
# https://github.com/opensearch-project/opensearch-py/blob/main/utils/generate-api.py
# or the "OpenSearch API specification" available at:
# https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json
# -----------------------------------------------------
2023-11-06 13:08:19 -05:00
from typing import Any
from .utils import NamespacedClient, _make_path, query_params
2014-01-18 01:16:29 +01:00
2019-03-29 09:25:23 -06:00
2014-01-18 01:16:29 +01:00
class NodesClient(NamespacedClient):
@query_params("timeout")
2020-04-23 11:20:33 -05:00
def reload_secure_settings(
2023-11-06 13:08:19 -05:00
self,
body: Any = None,
node_id: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
2019-03-29 09:25:23 -06:00
"""
2019-12-17 22:31:35 +01:00
Reloads secure settings.
2020-10-20 13:02:15 -05:00
2019-03-29 09:25:23 -06:00
:arg body: An object containing the password for the opensearch
keystore
:arg node_id: Comma-separated list of node IDs to span the
2019-12-17 22:31:35 +01:00
reload/reinit call. Should stay empty because reloading usually involves
all cluster nodes.
:arg timeout: Operation timeout.
2019-03-29 09:25:23 -06:00
"""
return self.transport.perform_request(
2019-12-17 22:31:35 +01:00
"POST",
_make_path("_nodes", node_id, "reload_secure_settings"),
params=params,
2020-03-11 16:33:15 -05:00
headers=headers,
2020-04-23 11:20:33 -05:00
body=body,
2019-03-29 09:25:23 -06:00
)
@query_params("flat_settings", "timeout")
2023-11-06 13:08:19 -05:00
def info(
self,
node_id: Any = None,
metric: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
2014-01-18 01:16:29 +01:00
"""
2019-12-17 22:31:35 +01:00
Returns information about nodes in the cluster.
2020-10-20 13:02:15 -05:00
2014-01-18 01:16:29 +01:00
:arg node_id: 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, leave empty to get information from all
nodes.
:arg metric: Comma-separated list of metrics you wish returned.
Leave empty to return all. Valid choices are settings, os, process, jvm,
thread_pool, transport, http, plugins, ingest.
:arg flat_settings: Return settings in flat format. Default is
false.
:arg timeout: Operation timeout.
2014-01-18 01:16:29 +01:00
"""
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"GET", _make_path("_nodes", node_id, metric), params=params, headers=headers
2019-03-29 09:25:23 -06:00
)
2015-08-25 01:21:16 +02:00
2019-03-29 09:25:23 -06:00
@query_params(
"completion_fields",
"fielddata_fields",
"fields",
"groups",
"include_segment_file_sizes",
"level",
"timeout",
"types",
)
2020-03-11 16:33:15 -05:00
def stats(
2023-11-06 13:08:19 -05:00
self,
node_id: Any = None,
metric: Any = None,
index_metric: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
2014-01-18 01:16:29 +01:00
"""
2019-12-17 22:31:35 +01:00
Returns statistical information about nodes in the cluster.
2020-10-20 13:02:15 -05:00
2014-01-18 01:16:29 +01:00
:arg node_id: 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, leave empty to get information from all
nodes.
2019-12-17 22:31:35 +01:00
:arg metric: Limit the information returned to the specified
metrics. Valid choices are _all, breaker, fs, http, indices, jvm, os,
process, thread_pool, transport, discovery, indexing_pressure.
2019-12-17 22:31:35 +01:00
:arg index_metric: Limit the information returned for `indices`
metric to the specific index metrics. Isn't used if `indices` (or `all`)
metric isn't specified. Valid choices are _all, store, indexing, get,
search, merge, flush, refresh, query_cache, fielddata, docs, warmer,
completion, segments, translog, suggest, request_cache, recovery.
:arg completion_fields: Comma-separated list of fields for
`fielddata` and `suggest` index metric (supports wildcards).
:arg fielddata_fields: Comma-separated list of fields for
`fielddata` index metric (supports wildcards).
:arg fields: Comma-separated list of fields for `fielddata` and
`completion` index metric (supports wildcards).
:arg groups: Comma-separated list of search groups for `search`
index metric.
2019-12-17 22:31:35 +01:00
:arg include_segment_file_sizes: Whether to report the
aggregated disk usage of each one of the Lucene index files (only
applies if segment stats are requested). Default is false.
2019-12-17 22:31:35 +01:00
:arg level: Return indices stats aggregated at index, node or
shard level. Valid choices are indices, node, shards.
:arg timeout: Operation timeout.
:arg types: Comma-separated list of document types for the
`indexing` index metric.
2014-01-18 01:16:29 +01:00
"""
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"GET",
_make_path("_nodes", node_id, "stats", metric, index_metric),
params=params,
2020-03-11 16:33:15 -05:00
headers=headers,
2019-03-29 09:25:23 -06:00
)
2015-08-25 01:21:16 +02:00
2019-03-29 09:25:23 -06:00
@query_params(
"doc_type", "ignore_idle_threads", "interval", "snapshots", "threads", "timeout"
2019-03-29 09:25:23 -06:00
)
2023-11-06 13:08:19 -05:00
def hot_threads(
self,
node_id: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
2014-01-18 01:16:29 +01:00
"""
2019-12-17 22:31:35 +01:00
Returns information about hot threads on each node in the cluster.
2020-10-20 13:02:15 -05:00
2014-01-18 01:16:29 +01:00
:arg node_id: 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, leave empty to get information from all
nodes.
:arg doc_type: The type to sample. Valid choices are cpu, wait,
block.
2019-12-17 22:31:35 +01:00
:arg ignore_idle_threads: Don't show threads that are in known-
idle places, such as waiting on a socket select or pulling from an empty
task queue. Default is True.
:arg interval: The interval for the second sampling of threads.
:arg snapshots: Number of samples of thread stacktrace. Default
is 10.
2019-12-17 22:31:35 +01:00
:arg threads: Specify the number of threads to provide
information for. Default is 3.
:arg timeout: Operation timeout.
2014-01-18 01:16:29 +01:00
"""
2019-12-17 22:31:35 +01:00
# type is a reserved word so it cannot be used, use doc_type instead
if "doc_type" in params:
params["type"] = params.pop("doc_type")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"GET",
_make_path("_nodes", node_id, "hot_threads"),
params=params,
headers=headers,
2019-03-29 09:25:23 -06:00
)
2017-07-31 19:17:52 -04:00
2019-12-17 22:31:35 +01:00
@query_params("timeout")
2023-11-06 13:08:19 -05:00
def usage(
self,
node_id: Any = None,
metric: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
2017-07-31 19:17:52 -04:00
"""
2019-12-17 22:31:35 +01:00
Returns low-level information about REST actions usage on nodes.
2020-10-20 13:02:15 -05:00
2017-07-31 19:17:52 -04:00
:arg node_id: 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, leave empty to get information from all
nodes.
2019-12-17 22:31:35 +01:00
:arg metric: Limit the information returned to the specified
metrics. Valid choices are _all, rest_actions.
:arg timeout: Operation timeout.
2017-07-31 19:17:52 -04:00
"""
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"GET",
_make_path("_nodes", node_id, "usage", metric),
params=params,
headers=headers,
2019-03-29 09:25:23 -06:00
)