Connection Types
- class opensearchpy.Connection(host='localhost', port=None, use_ssl=False, url_prefix='', timeout=10, headers=None, http_compress=None, opaque_id=None, **kwargs)[source]
Bases:
object
Class responsible for maintaining a connection to an OpenSearch node. It holds persistent connection pool to it and its main interface (perform_request) is thread-safe.
Also responsible for logging.
- Parameters:
host (str) – hostname of the node (default: localhost)
port (int | None) – port to use (integer, default: 9200)
use_ssl (bool) – use ssl for the connection if True
url_prefix (str) – optional url prefix for opensearch
timeout (int) – default timeout in seconds (float, default: 10)
http_compress (bool | None) – Use gzip compression
opaque_id (str | None) – Send this value in the ‘X-Opaque-Id’ HTTP header For tracing all requests made by this transport.
host –
port –
use_ssl –
url_prefix –
timeout –
http_compress –
opaque_id –
kwargs (Any) –
- _raise_error(status_code, raw_data, content_type=None)[source]
Locate appropriate exception and raise it.
- _raise_warnings(warning_headers)[source]
If ‘headers’ contains a ‘Warning’ header raise the warnings to be seen by the user. Takes an iterable of string values from any number of ‘Warning’ headers.
- Parameters:
warning_headers (Any) –
- Return type:
None
- static default_ca_certs()[source]
Get the default CA certificate bundle, preferring those configured in the standard OpenSSL environment variables before those provided by certifi (if available)
- Return type:
str | None
- class opensearchpy.RequestsHttpConnection(host='localhost', port=None, http_auth=None, use_ssl=False, verify_certs=True, ssl_show_warn=True, ca_certs=None, client_cert=None, client_key=None, headers=None, http_compress=None, opaque_id=None, pool_maxsize=None, metrics=<opensearchpy.metrics.metrics_none.MetricsNone object>, **kwargs)[source]
Bases:
Connection
Connection using the requests library.
- Parameters:
http_auth (Any) – optional http auth information as either ‘:’ separated string or a tuple. Any value will be passed into requests as auth.
use_ssl (bool) – use ssl for the connection if True
verify_certs (bool) – whether to verify SSL certificates
ssl_show_warn (bool) – show warning when verify certs is disabled
ca_certs (Any) – optional path to CA bundle. Defaults to configured OpenSSL bundles from environment variables and then certifi before falling back to the standard requests bundle to improve consistency with other Connection implementations
client_cert (Any) – path to the file containing the private key and the certificate, or cert only if using client_key
client_key (Any) – path to the file containing the private key if using separate cert and key files (client_cert will contain only the cert)
headers (Any) – any custom http headers to be add to requests
http_compress (Any) – Use gzip compression
opaque_id (Any) – Send this value in the ‘X-Opaque-Id’ HTTP header For tracing all requests made by this transport.
pool_maxsize (Any) – Maximum connection pool size used by pool-manager For custom connection-pooling on current session
metrics (Metrics) – metrics is an instance of a subclass of the
Metrics
class, used for collecting and reporting metrics related to the client’s operations;host (str) –
port (int | None) –
http_auth –
use_ssl –
verify_certs –
ssl_show_warn –
ca_certs –
client_cert –
client_key –
headers –
http_compress –
opaque_id –
pool_maxsize –
metrics –
kwargs (Any) –
- class opensearchpy.Urllib3HttpConnection(host='localhost', port=None, http_auth=None, use_ssl=False, verify_certs=<object object>, ssl_show_warn=<object object>, ca_certs=None, client_cert=None, client_key=None, ssl_version=None, ssl_assert_hostname=None, ssl_assert_fingerprint=None, pool_maxsize=None, headers=None, ssl_context=None, http_compress=None, opaque_id=None, metrics=<opensearchpy.metrics.metrics_none.MetricsNone object>, **kwargs)[source]
Bases:
Connection
Default connection class using the urllib3 library and the http protocol.
- Parameters:
host (str) – hostname of the node (default: localhost)
port (int | None) – port to use (integer, default: 9200)
url_prefix – optional url prefix for opensearch
timeout – default timeout in seconds (float, default: 10)
http_auth (Any) – optional http auth information as either ‘:’ separated string or a tuple
use_ssl (bool) – use ssl for the connection if True
verify_certs (Any) – whether to verify SSL certificates
ssl_show_warn (Any) – show warning when verify certs is disabled
ca_certs (Any) – optional path to CA bundle. See https://urllib3.readthedocs.io/en/latest/security.html#using-certifi-with-urllib3 for instructions how to get default set
client_cert (Any) – path to the file containing the private key and the certificate, or cert only if using client_key
client_key (Any) – path to the file containing the private key if using separate cert and key files (client_cert will contain only the cert)
ssl_version (Any) – version of the SSL protocol to use. Choices are: SSLv23 (default) SSLv2 SSLv3 TLSv1 (see
PROTOCOL_*
constants in thessl
module for exact options for your environment).ssl_assert_hostname (Any) – use hostname verification if not False
ssl_assert_fingerprint (Any) – verify the supplied certificate fingerprint if not None
pool_maxsize (Any) – the number of connections which will be kept open to this host. See https://urllib3.readthedocs.io/en/1.4/pools.html#api for more information.
headers (Any) – any custom http headers to be add to requests
http_compress (Any) – Use gzip compression
opaque_id (Any) – Send this value in the ‘X-Opaque-Id’ HTTP header For tracing all requests made by this transport.
metrics (Metrics) – metrics is an instance of a subclass of the
Metrics
class, used for collecting and reporting metrics related to the client’s operations;host –
port –
http_auth –
use_ssl –
verify_certs –
ssl_show_warn –
ca_certs –
client_cert –
client_key –
ssl_version –
ssl_assert_hostname –
ssl_assert_fingerprint –
pool_maxsize –
headers –
ssl_context (Any) –
http_compress –
opaque_id –
metrics –
kwargs (Any) –
- class opensearchpy.AIOHttpConnection(host='localhost', port=None, url_prefix='', timeout=10, http_auth=None, use_ssl=False, verify_certs=<object object>, ssl_show_warn=<object object>, ca_certs=None, client_cert=None, client_key=None, ssl_version=None, ssl_assert_hostname=True, ssl_assert_fingerprint=None, maxsize=10, headers=None, ssl_context=None, http_compress=None, opaque_id=None, loop=None, trust_env=False, **kwargs)[source]
Bases:
AsyncConnection
Default connection class for
AsyncOpenSearch
using the aiohttp library and the http protocol.- Parameters:
host (str) – hostname of the node (default: localhost)
port (int | None) – port to use (integer, default: 9200)
url_prefix (str) – optional url prefix for opensearch
timeout (int) – default timeout in seconds (float, default: 10)
http_auth (Any) – optional http auth information as either ‘:’ separated string or a tuple
use_ssl (bool) – use ssl for the connection if True
verify_certs (Any) – whether to verify SSL certificates
ssl_show_warn (Any) – show warning when verify certs is disabled
ca_certs (Any) – optional path to CA bundle. See https://urllib3.readthedocs.io/en/latest/security.html#using-certifi-with-urllib3 for instructions how to get default set
client_cert (Any) – path to the file containing the private key and the certificate, or cert only if using client_key
client_key (Any) – path to the file containing the private key if using separate cert and key files (client_cert will contain only the cert)
ssl_version (Any) – version of the SSL protocol to use. Choices are: SSLv23 (default) SSLv2 SSLv3 TLSv1 (see
PROTOCOL_*
constants in thessl
module for exact options for your environment).ssl_assert_hostname (bool) – use hostname verification if not False
ssl_assert_fingerprint (str | None) – verify the supplied certificate fingerprint if not None
maxsize (int | None) – the number of connections which will be kept open to this host. See https://urllib3.readthedocs.io/en/1.4/pools.html#api for more information.
headers (Any) – any custom http headers to be add to requests
http_compress (bool | None) – Use gzip compression
opaque_id (str | None) – Send this value in the ‘X-Opaque-Id’ HTTP header For tracing all requests made by this transport.
loop (Any) – asyncio Event Loop to use with aiohttp. This is set by default to the currently running loop.
host –
port –
url_prefix –
timeout –
http_auth –
use_ssl –
verify_certs –
ssl_show_warn –
ca_certs –
client_cert –
client_key –
ssl_version –
ssl_assert_hostname –
ssl_assert_fingerprint –
maxsize –
headers –
ssl_context (Any) –
http_compress –
opaque_id –
loop –
trust_env (bool | None) –
kwargs (Any) –
- opensearchpy.connections
alias of <module ‘opensearchpy.connection.connections’ from ‘/home/runner/work/opensearch-py/opensearch-py/.nox/docs/lib/python3.8/site-packages/opensearchpy/connection/connections.py’>