Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerting Plugins #93

Merged
merged 28 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4b15a5e
Alert Plugin
arnavdas88 Dec 15, 2021
d827041
Merge branch 'opensearch-project:main' into main
arnavdas88 Dec 28, 2021
c76236b
lint file header license
arnavdas88 Dec 29, 2021
d95b6cd
Merge branch 'opensearch-project:main' into main
arnavdas88 Jan 5, 2022
785c5b2
Tests For Alerting[Monitors]
arnavdas88 Jan 5, 2022
7d7f6f4
Merge branch 'opensearch-project:main' into main
arnavdas88 Jan 16, 2022
0b46aa8
Tests For Alerting[Destinations]
arnavdas88 Jan 17, 2022
2ca4d59
dynamic lookup 90#issuecomment-1003396742
arnavdas88 Jan 17, 2022
3b11995
Alerting Async
arnavdas88 Jan 19, 2022
b1f4344
Merge branch 'opensearch-project:main' into main
arnavdas88 Feb 15, 2022
8db89e7
Lint Changes
arnavdas88 Apr 7, 2022
2619cae
Merge branch 'opensearch-project:main' into main
arnavdas88 May 18, 2022
7bd9e17
alerting plugins integration tests
arnavdas88 May 18, 2022
a6fc619
Merge branch 'opensearch-project:main' into main
arnavdas88 May 31, 2022
fc79fdf
Merge branch 'opensearch-project:main' into main
arnavdas88 Jun 18, 2022
e8b1a0e
Merge branch 'opensearch-project:main' into main
arnavdas88 Jul 12, 2022
0d87201
Integ UnitTests Skip on OPENSEARCH_VERSION >= 2.0.0
arnavdas88 Jul 12, 2022
e4c111b
Unit Test Skip Complete
arnavdas88 Jul 12, 2022
be47811
Merge branch 'opensearch-project:main' into main
arnavdas88 Jul 20, 2022
1a990c1
Merge branch 'opensearch-project:main' into main
arnavdas88 Sep 4, 2022
e5d23f6
License Headers fixed
arnavdas88 Sep 7, 2022
e20038c
test_urllib3_connection timeout
arnavdas88 Sep 7, 2022
43268f1
lint
arnavdas88 Sep 7, 2022
853c91c
Fix licenses in all files
harshavamsi Sep 23, 2022
1dfbbaa
Merge pull request #1 from harshavamsi/fix/license
arnavdas88 Sep 23, 2022
37dfd91
Remove elastic search licenses on new files
harshavamsi Sep 29, 2022
86c66cd
Fix formatting
harshavamsi Sep 29, 2022
9c14dae
Merge pull request #2 from harshavamsi/fix/license
arnavdas88 Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/run-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ docker run \
--network=${network_name} \
--env "STACK_VERSION=${STACK_VERSION}" \
--env "OPENSEARCH_URL=${opensearch_url}" \
--env "OPENSEARCH_VERSION=${OPENSEARCH_VERSION}" \
--env "TEST_SUITE=${TEST_SUITE}" \
--env "PYTHON_CONNECTION_CLASS=${PYTHON_CONNECTION_CLASS}" \
--env "TEST_TYPE=server" \
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


import nox

SOURCE_FILES = (
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


# flake8: noqa
from __future__ import absolute_import

Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/_extra_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


# type: ignore

# This file exists for the sole reason of making mypy not
Expand Down
20 changes: 20 additions & 0 deletions opensearchpy/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# 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.


from __future__ import unicode_literals

Expand All @@ -37,6 +55,7 @@
from .indices import IndicesClient
from .ingest import IngestClient
from .nodes import NodesClient
from .plugins import PluginsClient
from .remote import RemoteClient
from .snapshot import SnapshotClient
from .tasks import TasksClient
Expand Down Expand Up @@ -197,6 +216,7 @@ class as kwargs, or a string in the format of ``host[:port]`` which will be
self.remote = RemoteClient(self)
self.snapshot = SnapshotClient(self)
self.tasks = TasksClient(self)
self.plugins = PluginsClient(self)

self.features = FeaturesClient(self)

Expand Down
19 changes: 18 additions & 1 deletion opensearchpy/_async/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# 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.

from __future__ import unicode_literals

Expand Down Expand Up @@ -60,7 +77,7 @@ class AsyncOpenSearch(object):
self,
hosts: Any = ...,
transport_class: Type[AsyncTransport] = ...,
**kwargs: Any,
**kwargs: Any
) -> None: ...
def __repr__(self) -> str: ...
async def __aenter__(self) -> "AsyncOpenSearch": ...
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/dangling_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import NamespacedClient, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import NamespacedClient, _make_path, query_params


Expand Down
51 changes: 51 additions & 0 deletions opensearchpy/_async/client/plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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 .utils import NamespacedClient


class PluginsClient(NamespacedClient):
def __init__(self, client):
super(PluginsClient, self).__init__(client)
# self.query_workbench = QueryWorkbenchClient(client)
arnavdas88 marked this conversation as resolved.
Show resolved Hide resolved
# 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,
)
17 changes: 17 additions & 0 deletions opensearchpy/_async/client/plugins.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
from typing import Any

from ..client import AsyncOpenSearch
from ..plugins.alerting import AlertingClient as AlertingClient
from .utils import NamespacedClient as NamespacedClient

class PluginsClient(NamespacedClient):
alerting: Any
def __init__(self, client: AsyncOpenSearch) -> None: ...
1 change: 1 addition & 0 deletions opensearchpy/_async/client/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import NamespacedClient, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params


Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


import warnings

from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


from ...client.utils import ( # noqa
SKIP_IN_PATH,
NamespacedClient,
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


import asyncio

from ..compat import * # noqa
Expand Down
5 changes: 3 additions & 2 deletions opensearchpy/_async/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


# Licensed to Elasticsearch B.V.under one or more agreements.
# Elasticsearch B.V.licenses this file to you under the Apache 2.0 License.
# See the LICENSE file in the project root for more information
Expand Down Expand Up @@ -203,7 +204,7 @@ async def map_actions():
raise_on_error,
ignore_status,
*args,
**kwargs,
**kwargs
),
):

Expand Down Expand Up @@ -470,5 +471,5 @@ async def _change_doc_index(hits, index):
target_client,
_change_doc_index(docs, target_index),
chunk_size=chunk_size,
**kwargs,
**kwargs
)
5 changes: 3 additions & 2 deletions opensearchpy/_async/http_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.


import asyncio
import os
import ssl
Expand Down Expand Up @@ -97,7 +98,7 @@ def __init__(
http_compress=None,
opaque_id=None,
loop=None,
**kwargs,
**kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Was this change introduced by styling tool? If not, can you revert here and other places? Thanks

):
"""
Default connection class for ``AsyncOpenSearch`` using the `aiohttp` library and the http protocol.
Expand Down Expand Up @@ -142,7 +143,7 @@ def __init__(
headers=headers,
http_compress=http_compress,
opaque_id=opaque_id,
**kwargs,
**kwargs
)

if http_auth is not None:
Expand Down
2 changes: 1 addition & 1 deletion opensearchpy/_async/http_aiohttp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ class AIOHttpConnection(AsyncConnection):
http_compress: Optional[bool] = ...,
opaque_id: Optional[str] = ...,
loop: Any = ...,
**kwargs: Any,
**kwargs: Any
) -> None: ...
8 changes: 8 additions & 0 deletions opensearchpy/_async/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.
8 changes: 8 additions & 0 deletions opensearchpy/_async/plugins/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.
Loading