Files
opensearch-pyd/opensearchpy/_async/client/plugins.py
T
florianvazelleandGitHub 2e8d5ce1a5 Index State Management support (#398)
* feat(plugins): add index management client plugin

Signed-off-by: florian <florian@harfanglab.fr>

* chore(CHANGELOG): added entry for ISM api support in changelog

Signed-off-by: florian <florian@harfanglab.fr>

* test(plugins): use assertEqual to compare call parameters

Signed-off-by: florian <florian@harfanglab.fr>

* test(plugins): edit policy to support older versions of opensearch

Signed-off-by: florian <florian@harfanglab.fr>

* test(plugins): ignore plugin tests when opensearch is unreleased

Signed-off-by: florian <florian@harfanglab.fr>

* test(plugins): move plugin tests into separate files

Signed-off-by: florian <florian@harfanglab.fr>

* test(plugins): fix import of OpenSearchTestCase

Signed-off-by: florian <florian@harfanglab.fr>

* chore(USER_GUIDE): add a index management plugin part

Signed-off-by: florian <florian@harfanglab.fr>

---------

Signed-off-by: florian <florian@harfanglab.fr>
2023-06-28 16:56:00 -04:00

54 lines
1.9 KiB
Python

# 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.
import warnings
from ..plugins.alerting import AlertingClient
from ..plugins.index_management import IndexManagementClient
from ..plugins.security import SecurityClient
from .utils import NamespacedClient
class PluginsClient(NamespacedClient):
def __init__(self, client):
super(PluginsClient, self).__init__(client)
# self.query_workbench = QueryWorkbenchClient(client)
# self.reporting = ReportingClient(client)
# self.notebooks = NotebooksClient(client)
self.alerting = AlertingClient(client)
# self.anomaly_detection = AnomalyDetectionClient(client)
# self.trace_analytics = TraceAnalyticsClient(client)
self.index_management = IndexManagementClient(client)
self.security = SecurityClient(client)
self._dynamic_lookup(client)
def _dynamic_lookup(self, client):
# Issue : https://github.com/opensearch-project/opensearch-py/issues/90#issuecomment-1003396742
plugins = [
# "query_workbench",
# "reporting",
# "notebooks",
"alerting",
# "anomaly_detection",
# "trace_analytics",
"index_management",
"security",
]
for plugin in plugins:
if not hasattr(client, plugin):
setattr(client, plugin, getattr(self, plugin))
else:
warnings.warn(
f"Cannot load `{plugin}` directly to AsyncOpenSearch. `{plugin}` already exists in AsyncOpenSearch. Please use `AsyncOpenSearch.plugin.{plugin}` instead.",
category=RuntimeWarning,
stacklevel=2,
)