Transport classes and utilities shared among Python Elastic client libraries
Project description
elastic-transport-python
Transport classes and utilities shared among Python Elastic client libraries
This library was lifted from elasticsearch-py
and then transformed to be used across all Elastic services
rather than only Elasticsearch.
User Guide
For almost all use-cases you should not need this library. The below use-cases are the common ones:
Installing from PyPI
$ python -m pip install elastic-transport
Creating your own Connection Class
If you need to have custom behavior for a Connection
you can subclass the
base connection class you want and then pass the class in via connection_class
:
from elastic_transport import Urllib3HttpConnection
from elastic_enterprise_search import EnterpriseSearch
class CustomHttpConnection(Urllib3HttpConnection):
... # Custom HTTP behavior
# Create the Client with 'connection_class' defined
client = EnterpriseSearch(
...,
connection_class=CustomHttpConnection
)
The above also works for ConnectionPool
(via connection_pool_class
) and Transport
(via transport_class
).
Connection Classes
elastic-transport-python
supports two HTTP client libraries:
Urllib3HttpConnection
This is the default connection class. This connection class uses urllib3` to issue requests. Read more about urllib3 on Read the Docs.
RequestsHttpConnection
This connection class requires the Requests library to be installed to use:
$ python -m pip install requests
This class is often useful when using libraries that integrate with Requests. Read more about Requests on Read the Docs.
Supported Connection Options
The two connection classes support a variety of options, some connection classes only support a subset of the total options:
Option | Description | Default | Supported by urllib3 | Supported by requests |
---|---|---|---|---|
host | TCP host to connect | localhost | ✓ | ✓ |
port | TCP port to connect | ✓ | ✓ | |
use_ssl | Should connect via TLS/SSL? | False | ✓ | ✓ |
url_prefix | Path prefix for all requests | "" | ✓ | ✓ |
request_timeout | Default request timeout | 10.0 | ✓ | ✓ |
headers | HTTP headers to add to every request | {} | ✓ | ✓ |
user_agent | Default User-Agent HTTP header | None | ✓ | ✓ |
connections_per_host | Number of HTTP connections per host | 10 | ✓ | |
verify_certs | Whether to verify server certificate | True | ✓ | ✓ |
ca_certs | CA certificates to use with TLS/SSL | certifi | ✓ | ✓ |
client_cert | Client certificate to present during TLS/SSL handshake | None | ✓ | ✓ |
client_key | Client certificate key that goes with client_cert | None | ✓ | ✓ |
ssl_version | Version of TLS/SSL to use | None | ✓ | |
ssl_assert_hostname | Host to verify on the server TLS certificate. Set to False to disable certificate hostname verification | None | ✓ | |
ssl_assert_fingerprint | Checksum to verify against the server TLS certificate | None | ✓ | |
ssl_context | Preconfigured SSLContext instance | None | ✓ |
License
elastic-transport-python
is available under the Apache-2.0 license.
For more details see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for elastic-transport-7.11.0b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e982e094b5a99d65ff93b188980c9fe5c58e05171db945afaa37161be713b0a |
|
MD5 | baf351b510ef03a89c30d41f50fc244c |
|
BLAKE2b-256 | 2b76c6196d76a2035d1068439618e30a200d7b57806477326330d93f54c5b9f0 |
Hashes for elastic_transport-7.11.0b1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32576f6b8eb564ff0c6880fcd3841ee63c9f038ef56a49bb3453c1cd148f58b8 |
|
MD5 | 8d0db0805c6688a01e26e42445faeeeb |
|
BLAKE2b-256 | 2b4d1f0a8b52c9bd0604a34a70a2a0ca0c24f3b9e074a61d88fb532e876104b6 |