Allow passing trust_env to aiohttp.ClientSession (#438)

Fixes #368

Signed-off-by: Michael Oliver <michael@michaeloliver.dev>
This commit is contained in:
Michael Oliver
2023-07-19 14:02:04 +01:00
committed by GitHub
parent 49d75c2e7d
commit 4dba35deea
5 changed files with 51 additions and 0 deletions
+31
View File
@@ -35,6 +35,7 @@
- [Pre-requisites to use `AWSV4SignerAuth`](#pre-requisites-to-use-awsv4signerauth)
- [Using IAM authentication with an async client](#using-iam-authentication-with-an-async-client)
- [Using Kerberos](#using-kerberos)
- [Using environment settings for proxy configuration](#using-environment-settings-for-proxy-configuration)
# User guide of OpenSearch Python client
@@ -686,3 +687,33 @@ client = OpenSearch(
health = client.cluster.health()
```
## Using environment settings for proxy configuration
Tell connection to get proxy information from `HTTP_PROXY` / `HTTPS_PROXY` environment variables or `~/.netrc` file if present.
```python
from opensearchpy import OpenSearch, RequestsHttpConnection
OpenSearch(
hosts=["htps://..."],
use_ssl=True,
verify_certs=True,
connection_class=RequestsHttpConnection,
trust_env=True,
)
```
```python
from opensearchpy import AsyncOpenSearch, AIOHttpConnection
client = AsyncOpenSearch(
hosts=["htps://..."],
use_ssl=True,
verify_certs=True,
connection_class=AIOHttpConnection,
trust_env=True,
)
```