Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unrestricted body again #2383

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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