File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
lib/Search/Elasticsearch/Role Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,22 @@ sub BUILDARGS {
158158 $default_headers {' Content-Type' } = ' application/vnd.elasticsearch+json; compatible-with=7' ;
159159 }
160160
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
161177 $params -> {scheme } = $scheme ;
162178 $params -> {is_https } = $scheme eq ' https' ;
163179 $params -> {host } = $host ;
You can’t perform that action at this time.
0 commit comments