Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into proposal/issue-331/…
Browse files Browse the repository at this point in the history
…logs-metrics-collecton-script
  • Loading branch information
Djcarrillo6 committed Nov 17, 2023
2 parents e35700f + 567ede3 commit cc91e93
Show file tree
Hide file tree
Showing 27 changed files with 1,173 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
opensearch_version: [ '1.0.1', '1.1.0', '1.2.4', '1.3.7', '2.0.1', '2.1.0', '2.2.1', '2.3.0', '2.4.0', '2.5.0', '2.6.0', '2.7.0', '2.8.0', '2.9.0', '2.10.0' ]
opensearch_version: [ '1.0.1', '1.1.0', '1.2.4', '1.3.7', '2.0.1', '2.1.0', '2.2.1', '2.3.0', '2.4.0', '2.5.0', '2.6.0', '2.7.0', '2.8.0', '2.9.0', '2.10.0', '2.11.0' ]
secured: [ "true", "false" ]

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
PIP_DISABLE_PIP_VERSION_CHECK: 1
- name: Install Dependencies
run: |
python -m pip install -r dev-requirements.txt
python -m pip install nox
- name: Run Tests
run: |
python setup.py test
python -m nox -rs test-${{ matrix.entry.python-version }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unified-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
stack_version: ['2.3.2']
stack_version: ['2.4.2']

steps:
- name: Checkout
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [2.4.1]
### Added
### Changed
### Deprecated
### Removed
### Fixed
- Fix dependency on `aiohttp` ([#594](https://github.com/opensearch-project/opensearch-py/pull/594))
### Security

## [2.4.0]
### Added
- Added generating imports and headers to API generator ([#467](https://github.com/opensearch-project/opensearch-py/pull/467))
- Added point-in-time APIs (create_pit, delete_pit, delete_all_pits, get_all_pits) and Security Client APIs (health and update_audit_configuration) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
- Added guide on using index templates ([#531](https://github.com/opensearch-project/opensearch-py/pull/531))
Expand All @@ -16,7 +33,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `samples`, `benchmarks` and `docs` to `nox -rs format` ([#556](https://github.com/opensearch-project/opensearch-py/pull/556))
- Added guide on the document lifecycle API(s) ([#559](https://github.com/opensearch-project/opensearch-py/pull/559))
- Added Windows CI ([#569](https://github.com/opensearch-project/opensearch-py/pull/569))
- Added guide on using a Python logging integration with OpenSearch logs ([#]())
- Added `client.http` JSON REST request API helpers ([#544](https://github.com/opensearch-project/opensearch-py/pull/544))
- Added guide on using a Python logging integration with OpenSearch logs ([#579](https://github.com/opensearch-project/opensearch-py/pull/579))
### 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 All @@ -39,6 +57,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Security
### Dependencies
- Bumps `sphinx` from <7.1 to <7.3
- Bumps `coverage` from <7.0.0 to <8.0.0

## [2.3.2]
### Added
Expand Down
7 changes: 1 addition & 6 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ The below matrix shows the compatibility of the [`opensearch-py`](https://pypi.o
| --- | --- | --- |
| 1.0.0 | 1.0.0-1.2.4 | |
| 1.1.0 | 1.3.0-1.3.7 | |
| 2.0.x | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.1.x | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.2.0 | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.3.0 | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.3.1 | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.3.2 | 1.0.0-2.10.0 | client works against Opensearch Version 1.x as long as features removed in 2.0 are not used |
| 2.x.x | 1.0.0-2.11.0 | client works against OpenSearch 1.x as long as features removed in 2.0 are not used |

## Upgrading

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ The release process is standard across repositories in this org and is run by a
1. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and a draft release will be created.
1. This draft release triggers the [jenkins release workflow](https://build.ci.opensearch.org/job/opensearch-py-release/) as a result of which opensearch-py client is released on [PyPi](https://pypi.org/project/opensearch-py/).
1. Once the above release workflow is successful, the drafted release on GitHub is published automatically.
1. Increment "version" in [_version.py](./opensearchpy/_version.py) to the next patch release, e.g. v2.1.1. See [example](https://github.com/opensearch-project/opensearch-py/pull/167).
1. Add an "Unreleased" section to CHANGELOG, and increment version to the next patch release, e.g. v2.1.1. See [example](https://github.com/opensearch-project/opensearch-py/pull/593).
2 changes: 1 addition & 1 deletion benchmarks/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/api-ref/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ titlesonly:
maxdepth: 1
---
clients/http_client
clients/cat_client
clients/cluster_client
clients/dangling_indices_client
Expand Down
5 changes: 5 additions & 0 deletions docs/source/api-ref/clients/http_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Http Client

```{eval-rst}
.. autoclass:: opensearchpy.client.http.HttpClient
```
46 changes: 30 additions & 16 deletions guides/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,75 @@

# Making Raw JSON REST Requests

The OpenSearch client implements many high-level REST DSLs that invoke OpenSearch APIs. However you may find yourself in a situation that requires you to invoke an API that is not supported by the client. Use `client.transport.perform_request` to do so. See [samples/json](../samples/json) for a complete working sample.
The OpenSearch client implements many high-level REST DSLs that invoke OpenSearch APIs. However you may find yourself in a situation that requires you to invoke an API that is not supported by the client. Use `client.http.get`, `head` , `put`, `post`, and `delete` to do so. See [samples/json](../samples/json) for a complete working sample.

## GET

The following example returns the server version information via `GET /`.

```python
info = client.transport.perform_request('GET', '/')
print(f"Welcome to {info['version']['distribution']} {info['version']['number']}!")
info = client.get("/")
print(f"Welcome to {info["version"]["distribution"]} {info["version"]["number"]}!")
```

Note that the client will parse the response as JSON when appropriate.

These methods are also available in the asynchronous client.

```python
info = await client.http.get("/")
print(f"Welcome to {info["version"]["distribution"]} {info["version"]["number"]}!")
```

Use `perform_request` in older versions (<= 2.3.x), and `client.http.get` and others in newer ones.

```python
info = client.transport.perform_request("GET", "/")
print(f"Welcome to {info["version"]["distribution"]} {info["version"]["number"]}!")
```

## PUT

The following example creates an index.

```python
index_body = {
'settings': {
'index': {
'number_of_shards': 4
"settings": {
"index": {
"number_of_shards": 4
}
}
}

client.transport.perform_request("PUT", "/movies", body=index_body)
client.http.put("/movies", body=index_body)
```

Note that the client will raise errors automatically. For example, if the index already exists, an `opensearchpy.exceptions.RequestError: RequestError(400, 'resource_already_exists_exception',` will be thrown.
Note that the client will raise errors automatically. For example, if the index already exists, an `opensearchpy.exceptions.RequestError: RequestError(400, "resource_already_exists_exception",` will be thrown.

## POST

The following example searches for a document.

```python
q = 'miller'
q = "miller"

query = {
'size': 5,
'query': {
'multi_match': {
'query': q,
'fields': ['title^2', 'director']
"size": 5,
"query": {
"multi_match": {
"query": q,
"fields": ["title^2", "director"]
}
}
}

client.transport.perform_request("POST", "/movies/_search", body = query)
client.http.post("/movies/_search", body = query)
```

## DELETE

The following example deletes an index.

```python
client.transport.perform_request("DELETE", "/movies")
client.http.delete("/movies")
```
10 changes: 9 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]) # type: ignore
def test(session: Any) -> None:
session.install(".")
# ensure client can be imported without aiohttp
session.run("python", "-c", "import opensearchpy\nprint(opensearchpy.OpenSearch())")
# ensure client can be imported with aiohttp
session.install(".[async]")
session.run(
"python", "-c", "import opensearchpy\nprint(opensearchpy.AsyncOpenSearch())"
)

session.install("-r", "dev-requirements.txt")

session.run("python", "setup.py", "test")


@nox.session() # type: ignore
@nox.session(python=["3.7"]) # type: ignore
def format(session: Any) -> None:
session.install("black", "isort")

Expand Down
36 changes: 19 additions & 17 deletions opensearchpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@
logger = logging.getLogger("opensearch")
logger.addHandler(logging.NullHandler())

from ._async.client import AsyncOpenSearch
from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection
from ._async.transport import AsyncTransport
from .client import OpenSearch
from .connection import (
AsyncHttpConnection,
Connection,
RequestsHttpConnection,
Urllib3HttpConnection,
Expand All @@ -76,12 +72,7 @@
UnknownDslObject,
ValidationException,
)
from .helpers import (
AWSV4SignerAsyncAuth,
AWSV4SignerAuth,
RequestsAWSV4SignerAuth,
Urllib3AWSV4SignerAuth,
)
from .helpers import AWSV4SignerAuth, RequestsAWSV4SignerAuth, Urllib3AWSV4SignerAuth
from .helpers.aggs import A
from .helpers.analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
from .helpers.document import Document, InnerDoc, MetaField
Expand Down Expand Up @@ -159,7 +150,6 @@
"JSONSerializer",
"Connection",
"RequestsHttpConnection",
"AsyncHttpConnection",
"Urllib3HttpConnection",
"ImproperlyConfigured",
"OpenSearchException",
Expand All @@ -178,7 +168,6 @@
"AWSV4SignerAuth",
"Urllib3AWSV4SignerAuth",
"RequestsAWSV4SignerAuth",
"AWSV4SignerAsyncAuth",
"A",
"AttrDict",
"AttrList",
Expand Down Expand Up @@ -251,10 +240,23 @@
"normalizer",
"token_filter",
"tokenizer",
"AIOHttpConnection",
"AsyncConnection",
"AsyncTransport",
"AsyncOpenSearch",
"AsyncHttpConnection",
"__versionstr__",
]

try:
from ._async.client import AsyncOpenSearch
from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection
from ._async.transport import AsyncTransport
from .connection import AsyncHttpConnection
from .helpers import AWSV4SignerAsyncAuth

__all__ += [
"AIOHttpConnection",
"AsyncConnection",
"AsyncTransport",
"AsyncOpenSearch",
"AsyncHttpConnection",
"AWSV4SignerAsyncAuth",
]
except (ImportError, SyntaxError):
pass
3 changes: 2 additions & 1 deletion opensearchpy/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .cluster import ClusterClient
from .dangling_indices import DanglingIndicesClient
from .features import FeaturesClient
from .http import HttpClient
from .indices import IndicesClient
from .ingest import IngestClient
from .nodes import NodesClient
Expand Down Expand Up @@ -229,8 +230,8 @@ class as kwargs, or a string in the format of ``host[:port]`` which will be
self.remote_store = RemoteStoreClient(self)

self.features = FeaturesClient(self)

self.plugins = PluginsClient(self)
self.http = HttpClient(self)

def __repr__(self) -> Any:
try:
Expand Down
Loading

0 comments on commit cc91e93

Please sign in to comment.