Skip to content

Commit d8ed032

Browse files
github-actions[bot]iuliaferolipquentin
authored
[Backport 8.13] Changed API Key from tuple to encoding in the docs (#2494)
Co-authored-by: Iulia Feroli <iuliaferoli@gmail.com> Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
1 parent 4cdff67 commit d8ed032

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

docs/guide/connecting.asciidoc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ es.options(
264264
265265
# You can persist the authenticated client to use
266266
# later or use for multiple API calls:
267-
auth_client = es.options(
268-
api_key=("api-key-id", "api-key-secret")
269-
)
267+
auth_client = es.options(api_key="api_key")
270268
for i in range(10):
271269
auth_client.index(
272270
index="example-index",
@@ -320,9 +318,10 @@ es = Elasticsearch(
320318
[[auth-apikey]]
321319
==== API Key authentication
322320

323-
You can configure the client to use {es}'s API Key for connecting to your
324-
cluster. Note that you need the values of `id` and `api_key` to
325-
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[authenticate via an API Key].
321+
You can configure the client to use {es}'s API Key for connecting to your
322+
cluster. These can be generated through the
323+
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Elasticsearch Create API key API]
324+
or https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[Kibana Stack Management].
326325

327326
[source,python]
328327
----
@@ -332,7 +331,7 @@ from elasticsearch import Elasticsearch
332331
es = Elasticsearch(
333332
"https://localhost:9200",
334333
ca_certs="/path/to/http_ca.crt",
335-
api_key=("api_key.id", "api_key.api_key")
334+
api_key="api_key",
336335
)
337336
----
338337

docs/guide/getting-started.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ from elasticsearch import Elasticsearch
3636
3737
client = Elasticsearch(
3838
"https://...", # Elasticsearch endpoint
39-
api_key=('api-key-id', 'api-key-secret'), # API key ID and secret
39+
api_key="api_key",
4040
)
4141
----
4242

docs/guide/migration.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ client = Elasticsearch(
9191
9292
# Include your authentication like 'api_key'
9393
# 'basic_auth', or 'bearer_auth' here:
94-
api_key=("<name>", "<key>")
94+
api_key="api_key"
9595
)
9696
------------------------------------
9797

@@ -133,7 +133,7 @@ from elasticsearch import Elasticsearch
133133
client = Elasticsearch("http://localhost:9200")
134134
135135
# 8.0+ SUPPORTED USAGE:
136-
client.options(api_key=("id", "api_key")).search(index="blogs")
136+
client.options(api_key="api_key").search(index="blogs")
137137
138138
# 7.x DEPRECATED USAGE (Don't do this!):
139139
client.search(index="blogs", api_key=("id", "api_key"))
@@ -171,7 +171,7 @@ with the `security.grant_api_key` API:
171171
resp = (
172172
client.options(
173173
# This is the API key being used for the request
174-
api_key=("request-id", "request-api-key")
174+
api_key="request-api-key"
175175
).security.grant_api_key(
176176
# This is the API key being granted
177177
api_key={
@@ -209,7 +209,7 @@ Starting with the 8.12 client, using a body parameter is fully supported again,
209209
resp = (
210210
client.options(
211211
# This is the API key being used for the request
212-
api_key=("request-id", "request-api-key")
212+
api_key="request-api-key"
213213
).security.grant_api_key(
214214
body={
215215
# This is the API key being granted

elasticsearch/_async/client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ class AsyncElasticsearch(BaseClient):
122122
# Set 'api_key' on the constructor
123123
client = Elasticsearch(
124124
"http://localhost:9200",
125-
api_key=("id", "api_key")
125+
api_key="api_key",
126126
)
127127
client.search(...)
128128
129129
# Set 'api_key' per request
130-
client.options(api_key=("id", "api_key")).search(...)
130+
client.options(api_key="api_key").search(...)
131131
"""
132132

133133
def __init__(

elasticsearch/_sync/client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ class Elasticsearch(BaseClient):
122122
# Set 'api_key' on the constructor
123123
client = Elasticsearch(
124124
"http://localhost:9200",
125-
api_key=("id", "api_key")
125+
api_key="api_key",
126126
)
127127
client.search(...)
128128
129129
# Set 'api_key' per request
130-
client.options(api_key=("id", "api_key")).search(...)
130+
client.options(api_key="api_key").search(...)
131131
"""
132132

133133
def __init__(

0 commit comments

Comments
 (0)