From 2a164b5ec8754709f7b034ba881650d1b9632261 Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 12:58:53 +0100 Subject: [PATCH 1/8] Update connecting.asciidoc remove tuple version of API Key replace tuple with encoding version of API Key --- docs/guide/connecting.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/connecting.asciidoc b/docs/guide/connecting.asciidoc index 34f62298a..91968f256 100644 --- a/docs/guide/connecting.asciidoc +++ b/docs/guide/connecting.asciidoc @@ -265,7 +265,7 @@ es.options( # You can persist the authenticated client to use # later or use for multiple API calls: auth_client = es.options( - api_key=("api-key-id", "api-key-secret") + api_key="api_key" ) for i in range(10): auth_client.index( @@ -321,8 +321,8 @@ es = Elasticsearch( ==== API Key authentication You can configure the client to use {es}'s API Key for connecting to your -cluster. Note that you need the values of `id` and `api_key` to -https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[authenticate via an API Key]. +cluster. Note that you need the API Key credential representing the Base64-encoding of the id and api_key value +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[generated from the API Key]. [source,python] ---- @@ -332,7 +332,7 @@ from elasticsearch import Elasticsearch es = Elasticsearch( "https://localhost:9200", ca_certs="/path/to/http_ca.crt", - api_key=("api_key.id", "api_key.api_key") + api_key="api_key" ) ---- From 3d2e2ac56bd08c80ef964b39a743a91f478ff716 Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 13:00:49 +0100 Subject: [PATCH 2/8] Update getting-started.asciidoc changed API Key tuple replaced API Key tuple with encoding --- docs/guide/getting-started.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/getting-started.asciidoc b/docs/guide/getting-started.asciidoc index aef383f5d..ad1ad9297 100644 --- a/docs/guide/getting-started.asciidoc +++ b/docs/guide/getting-started.asciidoc @@ -36,7 +36,7 @@ from elasticsearch import Elasticsearch client = Elasticsearch( "https://...", # Elasticsearch endpoint - api_key=('api-key-id', 'api-key-secret'), # API key ID and secret + api_key='api_key', # API key encoding ) ---- From ea58fbfe4954dc4d860f4cc309302beef6e93f4a Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 13:07:24 +0100 Subject: [PATCH 3/8] Update migration.asciidoc changed API Key tuple --- docs/guide/migration.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/migration.asciidoc b/docs/guide/migration.asciidoc index 7a01f2ec8..1230399d7 100644 --- a/docs/guide/migration.asciidoc +++ b/docs/guide/migration.asciidoc @@ -91,7 +91,7 @@ client = Elasticsearch( # Include your authentication like 'api_key' # 'basic_auth', or 'bearer_auth' here: - api_key=("", "") + api_key="api_key" ) ------------------------------------ @@ -133,7 +133,7 @@ from elasticsearch import Elasticsearch client = Elasticsearch("http://localhost:9200") # 8.0+ SUPPORTED USAGE: -client.options(api_key=("id", "api_key")).search(index="blogs") +client.options(api_key="api_key").search(index="blogs") # 7.x DEPRECATED USAGE (Don't do this!): client.search(index="blogs", api_key=("id", "api_key")) @@ -171,7 +171,7 @@ with the `security.grant_api_key` API: resp = ( client.options( # This is the API key being used for the request - api_key=("request-id", "request-api-key") + api_key="request-api-key" ).security.grant_api_key( # This is the API key being granted api_key={ @@ -209,7 +209,7 @@ Starting with the 8.12 client, using a body parameter is fully supported again, resp = ( client.options( # This is the API key being used for the request - api_key=("request-id", "request-api-key") + api_key="request-api-key" ).security.grant_api_key( body={ # This is the API key being granted From af8e883d2ff915440118206fb47887cd76f7e80d Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 14:14:32 +0100 Subject: [PATCH 4/8] Update __init__.py remove api_key tuple --- elasticsearch/_sync/client/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index d0b710367..cde603197 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -122,12 +122,12 @@ class Elasticsearch(BaseClient): # Set 'api_key' on the constructor client = Elasticsearch( "http://localhost:9200", - api_key=("id", "api_key") + api_key="api_key" ) client.search(...) # Set 'api_key' per request - client.options(api_key=("id", "api_key")).search(...) + client.options(api_key="api_key").search(...) """ def __init__( From e06f240c2fba4381e1d7b933d78b6052da85c06d Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 14:35:18 +0100 Subject: [PATCH 5/8] Update getting-started.asciidoc --- docs/guide/getting-started.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/getting-started.asciidoc b/docs/guide/getting-started.asciidoc index ad1ad9297..9639856da 100644 --- a/docs/guide/getting-started.asciidoc +++ b/docs/guide/getting-started.asciidoc @@ -36,7 +36,7 @@ from elasticsearch import Elasticsearch client = Elasticsearch( "https://...", # Elasticsearch endpoint - api_key='api_key', # API key encoding + api_key='api_key', ) ---- From 81487e3193ec9945ed290ebcfdcb1899b8a44750 Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 14:38:14 +0100 Subject: [PATCH 6/8] Update connecting.asciidoc --- docs/guide/connecting.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/connecting.asciidoc b/docs/guide/connecting.asciidoc index 91968f256..b8caeac73 100644 --- a/docs/guide/connecting.asciidoc +++ b/docs/guide/connecting.asciidoc @@ -321,8 +321,8 @@ es = Elasticsearch( ==== API Key authentication You can configure the client to use {es}'s API Key for connecting to your -cluster. Note that you need the API Key credential representing the Base64-encoding of the id and api_key value -https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[generated from the API Key]. +cluster. Note that you need the API Key encoding you can +https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[generated in Kibana]. [source,python] ---- From 686b6ce2bf5d404d429be00defaf8de876d94fe1 Mon Sep 17 00:00:00 2001 From: Iulia Feroli Date: Wed, 20 Mar 2024 16:37:19 +0100 Subject: [PATCH 7/8] Update connecting.asciidoc --- docs/guide/connecting.asciidoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/guide/connecting.asciidoc b/docs/guide/connecting.asciidoc index b8caeac73..0d578865c 100644 --- a/docs/guide/connecting.asciidoc +++ b/docs/guide/connecting.asciidoc @@ -320,9 +320,7 @@ es = Elasticsearch( [[auth-apikey]] ==== API Key authentication -You can configure the client to use {es}'s API Key for connecting to your -cluster. Note that you need the API Key encoding you can -https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[generated in Kibana]. +You can configure the client to use {es}'s API Key for connecting to your cluster. These can be generated through the https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Elasticsearch Create API key API] or https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[Kibana Stack Management]. [source,python] ---- From 48d654d2dd0e68d75ee6762a8d1e6f5a56e0253f Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 21 Mar 2024 11:21:22 +0400 Subject: [PATCH 8/8] Fix formatting --- docs/guide/connecting.asciidoc | 11 ++++++----- docs/guide/getting-started.asciidoc | 2 +- elasticsearch/_sync/client/__init__.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/guide/connecting.asciidoc b/docs/guide/connecting.asciidoc index 0d578865c..a6f41a97b 100644 --- a/docs/guide/connecting.asciidoc +++ b/docs/guide/connecting.asciidoc @@ -264,9 +264,7 @@ es.options( # You can persist the authenticated client to use # later or use for multiple API calls: -auth_client = es.options( - api_key="api_key" -) +auth_client = es.options(api_key="api_key") for i in range(10): auth_client.index( index="example-index", @@ -320,7 +318,10 @@ es = Elasticsearch( [[auth-apikey]] ==== API Key authentication -You can configure the client to use {es}'s API Key for connecting to your cluster. These can be generated through the https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Elasticsearch Create API key API] or https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[Kibana Stack Management]. +You can configure the client to use {es}'s API Key for connecting to your +cluster. These can be generated through the +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Elasticsearch Create API key API] +or https://www.elastic.co/guide/en/kibana/current/api-keys.html#create-api-key[Kibana Stack Management]. [source,python] ---- @@ -330,7 +331,7 @@ from elasticsearch import Elasticsearch es = Elasticsearch( "https://localhost:9200", ca_certs="/path/to/http_ca.crt", - api_key="api_key" + api_key="api_key", ) ---- diff --git a/docs/guide/getting-started.asciidoc b/docs/guide/getting-started.asciidoc index 9639856da..db0a8095b 100644 --- a/docs/guide/getting-started.asciidoc +++ b/docs/guide/getting-started.asciidoc @@ -36,7 +36,7 @@ from elasticsearch import Elasticsearch client = Elasticsearch( "https://...", # Elasticsearch endpoint - api_key='api_key', + api_key="api_key", ) ---- diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index cde603197..d342466b8 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -122,7 +122,7 @@ class Elasticsearch(BaseClient): # Set 'api_key' on the constructor client = Elasticsearch( "http://localhost:9200", - api_key="api_key" + api_key="api_key", ) client.search(...)