-
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
REST high-level client: add get ingest pipeline API #30847
Conversation
Pinging @elastic/es-core-infra |
@elasticmachine add to whitelist |
696b0ab
to
7e97845
Compare
* Get an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Get Pipeline API on elastic.co</a> |
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.
TODO: Fix javadoc link.
@@ -178,4 +156,27 @@ public void testPutPipeline() throws IOException { | |||
execute(request, highLevelClient().cluster()::putPipeline, highLevelClient().cluster()::putPipelineAsync); | |||
assertTrue(putPipelineResponse.isAcknowledged()); | |||
} | |||
|
|||
public void testGetPipeline() throws IOException { | |||
String id = "get_pipeline_id"; |
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.
Change this to some_pipeline_id
for uniformity.
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.
I left just one question. Other than that it looks good!
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class GetPipelineResponseTests extends ESTestCase { |
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.
What about making this an AbstractStreamableXContentTestCase
like you did in #30793?
public void getPipelineAsync(GetPipelineRequest request, ActionListener<GetPipelineResponse> listener, Header... headers) { | ||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline, | ||
GetPipelineResponse::fromXContent, listener, emptySet(), headers); | ||
} |
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.
Along the lines of the other comment I left on #30793 , this API should be added under the ingest namespace rather than the cluster one.
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.
I would prefer to pick up moving to a new namespace after this and #30865 have been merged. Is this okay? Or do I need to bundle it with this change?
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.
sure fine with me
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.
LGTM besides the comment I left on the API namespace
Relates to elastic#27205 (cherry picked from commit 696b0ab2d09d4d25806b3fbfd4f82b6fc9f7218b)
ecb9bf9
to
8e2aeec
Compare
-- Also fixed strings -- removed getPipelineConfigs method and switched to pipelines() method.
8e2aeec
to
e0288f1
Compare
clonePipelines.add(createRandomPipeline("pipeline_" + clonePipelines.size() + 1)); | ||
return new GetPipelineResponse(clonePipelines); | ||
} catch (IOException e) { | ||
return null; |
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.
rather throw UncheckedIOException ?
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.
Thanks for the tip. I didn't know these existed.
@Override | ||
protected GetPipelineResponse mutateInstance(GetPipelineResponse response) { | ||
try { | ||
ArrayList<PipelineConfiguration> clonePipelines = new ArrayList<>(response.pipelines()); |
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.
nit: can you declare it as a list on the left side?
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.
You mean left side?
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.
yes :) I have edited my comment right after posting it :)
} catch (IOException e) { | ||
// If we fail to construct an instance we return `null` which would make the user of this method | ||
// fail the test. | ||
return null; |
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.
I would rather throw UncheckedIOException here
int result = 1; | ||
for (PipelineConfiguration pipeline: pipelines) { | ||
// We only take the sum here to ensure that the order does not matter. | ||
result += (pipeline == null ? 0 : pipeline.getConfigAsMap().hashCode()); |
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.
shall we add equals and hashcode to PipelineConfiguration ?
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.
It is already there. Unfortunately, it uses the BytesReference
to do this. This depends on the XContentType
and hence is not useful for comparison. Do you want me to change the implementation there?
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.
I think we could, I am assuming that we need these only for tests and making equals/hashcode work with the map representation would not hurt. You can try and run IngestMetadaTests
, PipelineConfigurationTests
, PipelineExecutionServiceTests
and PipelineStoreTests
to check whether they remain green after the change.
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.
Cool thanks! Will do the change.
@@ -48,8 +50,13 @@ public GetPipelineResponse(List<PipelineConfiguration> pipelines) { | |||
this.pipelines = pipelines; |
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.
@javanna Should I change this constructor to Set<PipelineConfiguration>
instead of List<PipelineConfiguration>
to keep it more in line with the actual JSON response? Then we don't need to do tricky stuff in the equals
and hashcode
. I did not do this before because PipelineConfiguration
did not have the ideal equals
and hashcode
.
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.
I would be ok with that, but let's first see whether tests are fine with this change, my assumptions may be wrong :)
-- also throw UncheckedIOException instead of returning null
@sohaibiftikhar when I build the docs I get
could you please look into that? |
@javanna I am confused. Line 14 is a blank line. Plus there is no list item |
Okay, I found it. The |
here is the command that I run (you need to check out the docs repo first) from the root of my elasticsearch checkout:
|
retest this please |
@sohaibiftikhar would you mind pulling master in please? |
nevermind, I took care of it, hopefully tests get green, failures were unrelated to your changes. |
retest this please |
retest this please |
works finally! |
thanks @sohaibiftikhar ! |
* 6.x: Adjust BWC version on client features Introduce client feature tracking (#31020) [DOCS] Make geoshape docs less memory hungry (#31014) Fix handling of percent-encoded spaces in Windows batch files (#31034) [Docs] Fix a typo in Create Index naming limitation (#30891) REST high-level client: add delete ingest pipeline API (#30865) Ensure that index_prefixes settings cannot be changed (#30967) REST high-level client: add get ingest pipeline API (#30847) Cross Cluster Search: preserve remote status code (#30976) High-level client: list tasks failure to not lose nodeId (#31001) Refactor Sniffer and make it testable (#29638) [ML][TEST] Fix bucket count assertion in all tests in ModelPlotsIT (#31026) Add an option to split keyword field on whitespace at query time (#30691) Allow rollup job creation only if cluster is x-pack ready (#30963) Fix interoperability with < 6.3 transport clients (#30971) [Tests] Fix alias names in PutIndexTemplateRequestTests (#30960) [DOCS] Fixes links (#31011) Watcher: Give test a little more time
* master: Avoid randomization bug in FeatureAwareTests Adjust BWC version on client features Add TRACE, CONNECT, and PATCH http methods (#31035) Adjust BWC version on client features [DOCS] Make geoshape docs less memory hungry (#31014) Fix handling of percent-encoded spaces in Windows batch files (#31034) [Docs] Fix a typo in Create Index naming limitation (#30891) Introduce client feature tracking (#31020) Ensure that index_prefixes settings cannot be changed (#30967) REST high-level client: add delete ingest pipeline API (#30865) [ML][TEST] Fix bucket count assertion in all tests in ModelPlotsIT (#31026) Allow rollup job creation only if cluster is x-pack ready (#30963) Fix interoperability with < 6.3 transport clients (#30971) Add an option to split keyword field on whitespace at query time (#30691) [Tests] Fix alias names in PutIndexTemplateRequestTests (#30960) REST high-level client: add get ingest pipeline API (#30847) Cross Cluster Search: preserve remote status code (#30976) High-level client: list tasks failure to not lose nodeId (#31001) [DOCS] Fixes links (#31011) Watcher: Give test a little more time Reuse expiration date of trial licenses (#30950) Remove unused query methods from MappedFieldType. (#30987) Transport client: Don't validate node in handshake (#30737) [DOCS] Clarify not all PKCS12 usable as truststores (#30750) HLRest: Allow caller to set per request options (#30490) Remove version read/write logic in Verify Response (#30879) [DOCS] Update readme for testing x-pack code snippets (#30696) Ensure intended key is selected in SamlAuthenticatorTests (#30993) Core: Remove RequestBuilder from Action (#30966)
Relates to #27205