egalpin commented on code in PR #25024:
URL: https://github.com/apache/beam/pull/25024#discussion_r1072860908
##########
sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java:
##########
@@ -501,29 +506,55 @@ public ConnectionConfiguration withPassword(String
password) {
}
/**
- * If Elasticsearch authentication is enabled, provide an API key.
+ * If Elasticsearch authentication is enabled, provide an API key. Be
aware that you can only
+ * use one of {@Code withApiToken()}, {@code withBearerToken()} and {@code
withDefaultHeaders}
+ * at the same time, as they (potentially) use the same header.
*
* @param apiKey the API key used to authenticate to Elasticsearch
* @return a {@link ConnectionConfiguration} describes a connection
configuration to
* Elasticsearch.
*/
public ConnectionConfiguration withApiKey(String apiKey) {
checkArgument(!Strings.isNullOrEmpty(apiKey), "apiKey can not be null or
empty");
+ checkArgument(getBearerToken() == null, "apiKey can not be combined with
bearerToken");
+ checkArgument(getDefaultHeaders() == null, "apiKey can not be combined
with defaultHeaders");
return builder().setApiKey(apiKey).build();
}
/**
- * If Elasticsearch authentication is enabled, provide a bearer token.
+ * If Elasticsearch authentication is enabled, provide a bearer token. Be
aware that you can
+ * only use one of {@Code withApiToken()}, {@code withBearerToken()} and
{@code
+ * withDefaultHeaders} at the same time, as they (potentially) use the
same header.
*
* @param bearerToken the bearer token used to authenticate to
Elasticsearch
* @return a {@link ConnectionConfiguration} describes a connection
configuration to
* Elasticsearch.
*/
public ConnectionConfiguration withBearerToken(String bearerToken) {
checkArgument(!Strings.isNullOrEmpty(bearerToken), "bearerToken can not
be null or empty");
+ checkArgument(getApiKey() == null, "bearerToken can not be combined with
apiKey");
+ checkArgument(getDefaultHeaders() == null, "apiKey can not be combined
with defaultHeaders");
Review Comment:
nit: `apiKey` was copied over, should be `bearerToken`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]