Files
opensearch-pyd/opensearchpy/_async/client/plugins.py
T
florianvazelleandGitHub c60c259d96 Security plugin support (#399)
* feat(plugins): add security client plugin

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

* test(plugins): skip security plugin tests when disabled

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

* fix(security): remove non-ASCII character

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

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

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

* test(plugins): add asynchronous tests version

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

* test: remove some warnings

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

* chore(USER_GUIDE): add a security plugin part

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

* test(security): Split out security plugin tests in its own file

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

* chore: apply reviews

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

---------

Signed-off-by: florian <florian@harfanglab.fr>
2023-06-27 11:01:40 -04:00

53 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.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,
)