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

Add/remote store client #552

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added benchmarks ([#537](https://github.com/opensearch-project/opensearch-py/pull/537))
- Added guide on making raw JSON REST requests ([#542](https://github.com/opensearch-project/opensearch-py/pull/542))
- Added support for AWS SigV4 for urllib3 ([#547](https://github.com/opensearch-project/opensearch-py/pull/547))
- Added `remote store` client APIs ([#552](https://github.com/opensearch-project/opensearch-py/pull/552))
### Changed
- Generate `tasks` client from API specs ([#508](https://github.com/opensearch-project/opensearch-py/pull/508))
- Generate `ingest` client from API specs ([#513](https://github.com/opensearch-project/opensearch-py/pull/513))
Expand Down
2 changes: 2 additions & 0 deletions opensearchpy/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .nodes import NodesClient
from .plugins import PluginsClient
from .remote import RemoteClient
from .remote_store import RemoteStoreClient
from .security import SecurityClient
from .snapshot import SnapshotClient
from .tasks import TasksClient
Expand Down Expand Up @@ -206,6 +207,7 @@ class as kwargs, or a string in the format of ``host[:port]`` which will be
self.security = SecurityClient(self)
self.snapshot = SnapshotClient(self)
self.tasks = TasksClient(self)
self.remote_store = RemoteStoreClient(self)

self.features = FeaturesClient(self)

Expand Down
2 changes: 2 additions & 0 deletions opensearchpy/_async/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ from .indices import IndicesClient
from .ingest import IngestClient
from .nodes import NodesClient
from .remote import RemoteClient
from .remote_store import RemoteStoreClient
from .security import SecurityClient
from .snapshot import SnapshotClient
from .tasks import TasksClient
Expand All @@ -58,6 +59,7 @@ class AsyncOpenSearch(object):
security: SecurityClient
snapshot: SnapshotClient
tasks: TasksClient
remote_store: RemoteStoreClient
def __init__(
self,
hosts: Any = ...,
Expand Down
40 changes: 40 additions & 0 deletions opensearchpy/_async/client/remote_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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.
# ----------------------------------------------------
# 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
# -----------------------------------------------------


from .utils import SKIP_IN_PATH, NamespacedClient, query_params


class RemoteStoreClient(NamespacedClient):
@query_params("cluster_manager_timeout", "wait_for_completion")
async def restore(self, body, params=None, headers=None):
"""
Restores from remote store.


:arg body: Comma-separated list of index IDs
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. (default: false)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

Check warning on line 36 in opensearchpy/_async/client/remote_store.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/_async/client/remote_store.py#L35-L36

Added lines #L35 - L36 were not covered by tests

return await self.transport.perform_request(

Check warning on line 38 in opensearchpy/_async/client/remote_store.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/_async/client/remote_store.py#L38

Added line #L38 was not covered by tests
"POST", "/_remotestore/_restore", params=params, headers=headers, body=body
)
41 changes: 41 additions & 0 deletions opensearchpy/_async/client/remote_store.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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.
# ----------------------------------------------------
# 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
# -----------------------------------------------------

from typing import Any, Collection, MutableMapping, Optional, Tuple, Union

from .utils import NamespacedClient

class RemoteStoreClient(NamespacedClient):
async def restore(
self,
*,
body: Any,
cluster_manager_timeout: Optional[Any] = ...,
wait_for_completion: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
format: Optional[str] = ...,
filter_path: Optional[Union[str, Collection[str]]] = ...,
request_timeout: Optional[Union[int, float]] = ...,
ignore: Optional[Union[int, Collection[int]]] = ...,
opaque_id: Optional[str] = ...,
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> Any: ...
2 changes: 2 additions & 0 deletions opensearchpy/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .nodes import NodesClient
from .plugins import PluginsClient
from .remote import RemoteClient
from .remote_store import RemoteStoreClient
from .security import SecurityClient
from .snapshot import SnapshotClient
from .tasks import TasksClient
Expand Down Expand Up @@ -207,6 +208,7 @@ class as kwargs, or a string in the format of ``host[:port]`` which will be
self.security = SecurityClient(self)
self.snapshot = SnapshotClient(self)
self.tasks = TasksClient(self)
self.remote_store = RemoteStoreClient(self)

self.features = FeaturesClient(self)

Expand Down
2 changes: 2 additions & 0 deletions opensearchpy/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ from .indices import IndicesClient
from .ingest import IngestClient
from .nodes import NodesClient
from .remote import RemoteClient
from .remote_store import RemoteStoreClient
from .security import SecurityClient
from .snapshot import SnapshotClient
from .tasks import TasksClient
Expand All @@ -58,6 +59,7 @@ class OpenSearch(object):
security: SecurityClient
snapshot: SnapshotClient
tasks: TasksClient
remote_store: RemoteStoreClient
def __init__(
self, hosts: Any = ..., transport_class: Type[Transport] = ..., **kwargs: Any
) -> None: ...
Expand Down
40 changes: 40 additions & 0 deletions opensearchpy/client/remote_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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.
# ----------------------------------------------------
# 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
# -----------------------------------------------------


from .utils import SKIP_IN_PATH, NamespacedClient, query_params


class RemoteStoreClient(NamespacedClient):
@query_params("cluster_manager_timeout", "wait_for_completion")
def restore(self, body, params=None, headers=None):
"""
Restores from remote store.


:arg body: Comma-separated list of index IDs
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. (default: false)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

Check warning on line 36 in opensearchpy/client/remote_store.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/client/remote_store.py#L36

Added line #L36 was not covered by tests

return self.transport.perform_request(
"POST", "/_remotestore/_restore", params=params, headers=headers, body=body
)
41 changes: 41 additions & 0 deletions opensearchpy/client/remote_store.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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.
# ----------------------------------------------------
# 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
# -----------------------------------------------------

from typing import Any, Collection, MutableMapping, Optional, Tuple, Union

from .utils import NamespacedClient

class RemoteStoreClient(NamespacedClient):
def restore(
self,
*,
body: Any,
cluster_manager_timeout: Optional[Any] = ...,
wait_for_completion: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
format: Optional[str] = ...,
filter_path: Optional[Union[str, Collection[str]]] = ...,
request_timeout: Optional[Union[int, float]] = ...,
ignore: Optional[Union[int, Collection[int]]] = ...,
opaque_id: Optional[str] = ...,
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> Any: ...
15 changes: 15 additions & 0 deletions test_opensearchpy/test_client/test_remote_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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 test_opensearchpy.test_cases import OpenSearchTestCase


class TestRemoteStore(OpenSearchTestCase):
def test_remote_store_restore(self):
self.client.remote_store.restore(body=["index-1"])
self.assert_url_called("POST", "/_remotestore/_restore")
Loading