Skip to content

Commit

Permalink
Document change
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Nov 28, 2023
1 parent 572694b commit 65713ad
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions docs/guide/migration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ with the `security.grant_api_key` API:

[source,python]
------------------------------------
# 8.0+ SUPPORTED USAGES:
# 8.0+ SUPPORTED USAGE:
resp = (
client.options(
# This is the API key being used for the request
Expand All @@ -183,13 +183,36 @@ resp = (
)
)
# 7.x DEPRECATED USAGES (Don't do this!):
# 7.x DEPRECATED USAGE (Don't do this!):
resp = (
# This is the API key being used for the request
client.security.grant_api_key(
api_key=("request-id", "request-api-key"),
# This is the API key being granted
body={
# This is the API key being granted
"api_key": {
"name": "granted-api-key"
},
"grant_type": "password",
"username": "elastic",
"password": "changeme"
}
)
)
------------------------------------

Starting with the 8.12 client, using a body parameter is fully supported again, meaning you can also use `grant_api_key` like this:

[source,python]
------------------------------------
# 8.12+ SUPPORTED USAGE:
resp = (
client.options(
# This is the API key being used for the request
api_key=("request-id", "request-api-key")
).security.grant_api_key(
body={
# This is the API key being granted
"api_key": {
"name": "granted-api-key"
},
Expand Down Expand Up @@ -295,7 +318,7 @@ from elasticsearch import TransportError, Elasticsearch
try:
client.indices.get(index="index-that-does-not-exist")
# In elasticsearch-python v7.x this would capture the resulting
# In elasticsearch-py v7.x this would capture the resulting
# 'NotFoundError' that would be raised above. But in 8.0.0 this
# 'except TransportError' won't capture 'NotFoundError'.
except TransportError as err:
Expand Down

0 comments on commit 65713ad

Please sign in to comment.