Skip to content

Commit

Permalink
Update docs on how to connect with Amazon OpenSearch Service via HTTP. (
Browse files Browse the repository at this point in the history
#8987)

* Update python-low-level.md to detail how to connect with Amazon OpenSearch service via HTTP

This commit enhances the documentation on how to connect with Amazon OpenSearch service via HTTP.

Signed-off-by: Adriel Martins <[email protected]>

* Apply suggestions from code review

Co-authored-by: kolchfa-aws <[email protected]>
Signed-off-by: Adriel Martins <[email protected]>

---------

Signed-off-by: Adriel Martins <[email protected]>
Co-authored-by: kolchfa-aws <[email protected]>
(cherry picked from commit ca2e7f4)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and kolchfa-aws committed Dec 30, 2024
1 parent 288d9da commit 549f154
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions _clients/python-low-level.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ client = OpenSearch(

## Connecting to Amazon OpenSearch Service

The following example illustrates connecting to Amazon OpenSearch Service:
The following example illustrates connecting to Amazon OpenSearch Service using IAM credentials:

```python
from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth
Expand All @@ -127,6 +127,25 @@ client = OpenSearch(
pool_maxsize = 20
)
```

To connect to Amazon OpenSearch Service through HTTP with a username and password, use the following code:

```python
from opensearchpy import OpenSearch

auth = ('admin', 'admin') # For testing only. Don't store credentials in code.

client = OpenSearch(
hosts=[{"host": host, "port": 443}],
http_auth=auth,
http_compress=True, # enables gzip compression for request bodies
use_ssl=True,
verify_certs=True,
ssl_assert_hostname=False,
ssl_show_warn=False,
)
```

{% include copy.html %}

## Connecting to Amazon OpenSearch Serverless
Expand Down Expand Up @@ -359,4 +378,4 @@ print(response)
## Next steps

- For Python client API, see the [`opensearch-py` API documentation](https://opensearch-project.github.io/opensearch-py/).
- For Python code samples, see [Samples](https://github.com/opensearch-project/opensearch-py/tree/main/samples).
- For Python code samples, see [Samples](https://github.com/opensearch-project/opensearch-py/tree/main/samples).

0 comments on commit 549f154

Please sign in to comment.