File tree 1 file changed +16
-0
lines changed
lib/Search/Elasticsearch/Role
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,22 @@ sub BUILDARGS {
158
158
$default_headers {' Content-Type' } = ' application/vnd.elasticsearch+json; compatible-with=7' ;
159
159
}
160
160
161
+ if (defined $params -> {elastic_cloud_api_key } && defined $params -> {token_api }) {
162
+ throw( ' Request' ,
163
+ " You cannot set elastic_cloud_api_key and token_api together" );
164
+ }
165
+
166
+ # Elastic cloud API key
167
+ if (defined $params -> {elastic_cloud_api_key }) {
168
+ $default_headers {' Authorization' } = sprintf (" ApiKey %s " , $params -> {elastic_cloud_api_key });
169
+ }
170
+
171
+ # Elasticsearch token API (https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html)
172
+ if (defined $params -> {token_api }) {
173
+ $default_headers {' Authorization' } = sprintf (" Bearer %s " , $params -> {token_api });
174
+ }
175
+
176
+ # Elasticsearch
161
177
$params -> {scheme } = $scheme ;
162
178
$params -> {is_https } = $scheme eq ' https' ;
163
179
$params -> {host } = $host ;
You can’t perform that action at this time.
0 commit comments