Skip to content

Commit

Permalink
Merge branch 'main' into idleshard
Browse files Browse the repository at this point in the history
  • Loading branch information
ruai0511 authored Dec 30, 2024
2 parents 4132dbf + ca2e7f4 commit 25aac27
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 25aac27

Please sign in to comment.