Skip to content

Commit 65713ad

Browse files
committed
Document change
1 parent 572694b commit 65713ad

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

docs/guide/migration.asciidoc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ with the `security.grant_api_key` API:
167167

168168
[source,python]
169169
------------------------------------
170-
# 8.0+ SUPPORTED USAGES:
170+
# 8.0+ SUPPORTED USAGE:
171171
resp = (
172172
client.options(
173173
# This is the API key being used for the request
@@ -183,13 +183,36 @@ resp = (
183183
)
184184
)
185185
186-
# 7.x DEPRECATED USAGES (Don't do this!):
186+
# 7.x DEPRECATED USAGE (Don't do this!):
187187
resp = (
188188
# This is the API key being used for the request
189189
client.security.grant_api_key(
190190
api_key=("request-id", "request-api-key"),
191-
# This is the API key being granted
192191
body={
192+
# This is the API key being granted
193+
"api_key": {
194+
"name": "granted-api-key"
195+
},
196+
"grant_type": "password",
197+
"username": "elastic",
198+
"password": "changeme"
199+
}
200+
)
201+
)
202+
------------------------------------
203+
204+
Starting with the 8.12 client, using a body parameter is fully supported again, meaning you can also use `grant_api_key` like this:
205+
206+
[source,python]
207+
------------------------------------
208+
# 8.12+ SUPPORTED USAGE:
209+
resp = (
210+
client.options(
211+
# This is the API key being used for the request
212+
api_key=("request-id", "request-api-key")
213+
).security.grant_api_key(
214+
body={
215+
# This is the API key being granted
193216
"api_key": {
194217
"name": "granted-api-key"
195218
},
@@ -295,7 +318,7 @@ from elasticsearch import TransportError, Elasticsearch
295318
try:
296319
client.indices.get(index="index-that-does-not-exist")
297320
298-
# In elasticsearch-python v7.x this would capture the resulting
321+
# In elasticsearch-py v7.x this would capture the resulting
299322
# 'NotFoundError' that would be raised above. But in 8.0.0 this
300323
# 'except TransportError' won't capture 'NotFoundError'.
301324
except TransportError as err:

0 commit comments

Comments
 (0)