-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for rest compatibility headers to the HLRC #78490
Merged
+338
−17
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1955512
Add support for rest compatibility headers to the LLRC
dakrone 23cdd59
Spotless
dakrone 1a0ba09
Merge remote-tracking branch 'origin/master' into hlrc-support-compat
dakrone 66a2602
Fixup RestClient
dakrone 96651a3
Add necessary gradle dependency
dakrone d62beac
Fix tests
dakrone 35cc9f4
Spotleeeessssss
dakrone 4ef7aac
Merge remote-tracking branch 'origin/master' into hlrc-support-compat
dakrone 98548b2
Remove from low-level client
dakrone c55608a
WIP move compatibility handler into HLRC instead of LLRC
dakrone 3f89e93
Use equalsIgnoreCase for header comparison
dakrone ef743ba
Copy headers before modifying them
dakrone 2604955
Remove LLRC tests
dakrone 1cbbc3c
Fix precommit
dakrone fc47e1b
Remove unused import
dakrone f0ec7a8
Merge branch 'master' into hlrc-support-compat
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...nt/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.search.SearchRequest; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.core.CheckedConsumer; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Helper to build a {@link RestHighLevelClient}, allowing setting the low-level client that | ||
* should be used as well as whether API compatibility should be used. | ||
*/ | ||
|
||
public class RestHighLevelClientBuilder { | ||
private final RestClient restClient; | ||
private CheckedConsumer<RestClient, IOException> closeHandler = RestClient::close; | ||
private List<NamedXContentRegistry.Entry> namedXContentEntries = Collections.emptyList(); | ||
private Boolean apiCompatibilityMode = null; | ||
|
||
public RestHighLevelClientBuilder(RestClient restClient) { | ||
this.restClient = restClient; | ||
} | ||
|
||
public RestHighLevelClientBuilder closeHandler(CheckedConsumer<RestClient, IOException> closeHandler) { | ||
this.closeHandler = closeHandler; | ||
return this; | ||
} | ||
|
||
public RestHighLevelClientBuilder namedXContentEntries(List<NamedXContentRegistry.Entry> namedXContentEntries) { | ||
this.namedXContentEntries = namedXContentEntries; | ||
return this; | ||
} | ||
|
||
public RestHighLevelClientBuilder setApiCompatibilityMode(Boolean enabled) { | ||
this.apiCompatibilityMode = enabled; | ||
return this; | ||
} | ||
|
||
public RestHighLevelClient build() { | ||
return new RestHighLevelClient(this.restClient, this.closeHandler, this.namedXContentEntries, this.apiCompatibilityMode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for
RequestOptions
,equals
should beequalsIgnoreCase
.