69 lines
1.5 KiB
Plaintext
69 lines
1.5 KiB
Plaintext
[[connecting]]
|
|
== Connecting
|
|
|
|
This page contains the information you need to connect the Client with {es}.
|
|
|
|
|
|
[discrete]
|
|
[[authentication]]
|
|
=== Authentication
|
|
|
|
This section contains code snippets to show you how to connect to various {es}
|
|
providers.
|
|
|
|
|
|
[discrete]
|
|
[[auth-ec]]
|
|
==== Elastic Cloud
|
|
|
|
Cloud ID is an easy way to configure your client to work with your Elastic Cloud
|
|
deployment. Combine the `cloud_id` with either `http_auth` or `api_key` to
|
|
authenticate with your Elastic Cloud deployment.
|
|
|
|
Using `cloud_id` enables TLS verification and HTTP compression by default and
|
|
sets the port to 443 unless otherwise overwritten via the port parameter or the
|
|
port value encoded within `cloud_id`. Using Cloud ID also disables sniffing.
|
|
|
|
[source,py]
|
|
----------------------------
|
|
from elasticsearch import Elasticsearch
|
|
|
|
es = Elasticsearch(
|
|
cloud_id=”cluster-1:dXMa5Fx...”
|
|
)
|
|
----------------------------
|
|
|
|
|
|
[discrete]
|
|
[[auth-http]]
|
|
==== HTTP Authentication
|
|
|
|
HTTP authentication uses the `http_auth` parameter by passing in a username and
|
|
password within a tuple:
|
|
|
|
[source,py]
|
|
----------------------------
|
|
from elasticsearch import Elasticsearch
|
|
|
|
es = Elasticsearch(
|
|
http_auth=(“username”, “password”)
|
|
)
|
|
----------------------------
|
|
|
|
|
|
[discrete]
|
|
[[auth-apikey]]
|
|
==== ApiKey authentication
|
|
|
|
You can configure the client to use {es}'s API Key for connecting to your
|
|
cluster.
|
|
|
|
[source,py]
|
|
----------------------------
|
|
from elasticsearch import Elasticsearch
|
|
|
|
es = Elasticsearch(
|
|
api_key=(“api_key_id”, “api_key_secret”)
|
|
)
|
|
----------------------------
|