mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-30 02:13:33 -04:00
61 lines
1.4 KiB
Text
61 lines
1.4 KiB
Text
[NOTE]
|
|
====
|
|
The user needs the cluster privileges `manage_api_key`, `manage_connector` and `write_connector_secrets` to generate API keys programmatically.
|
|
====
|
|
|
|
To create an API key for the connector:
|
|
|
|
. Run the following command, replacing values where indicated.
|
|
Note the `id` and `encoded` return values from the response:
|
|
+
|
|
[source, console,subs="+attributes"]
|
|
----
|
|
POST /_security/api_key
|
|
{
|
|
"name": "my-connector-api-key",
|
|
"role_descriptors": {
|
|
"my-connector-connector-role": {
|
|
"cluster": [
|
|
"monitor",
|
|
"manage_connector"
|
|
],
|
|
"indices": [
|
|
{
|
|
"names": [
|
|
"my-index_name",
|
|
".search-acl-filter-my-index_name",
|
|
".elastic-connectors*"
|
|
],
|
|
"privileges": [
|
|
"all"
|
|
],
|
|
"allow_restricted_indices": false
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
----
|
|
+
|
|
. Use the `encoded` value to store a connector secret, and note the `id` return value from this response:
|
|
+
|
|
[source, console,subs="+attributes"]
|
|
----
|
|
POST _connector/_secret
|
|
{
|
|
"value": "encoded_api_key"
|
|
}
|
|
----
|
|
// TEST[skip:need to retrieve ids from the response]
|
|
+
|
|
. Use the API key `id` and the connector secret `id` to update the connector:
|
|
+
|
|
[source, console,subs="+attributes"]
|
|
----
|
|
PUT /_connector/my_connector_id>/_api_key_id
|
|
{
|
|
"api_key_id": "API key_id",
|
|
"api_key_secret_id": "secret_id"
|
|
}
|
|
----
|
|
// TEST[skip:need to retrieve ids from the response]
|