-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.x: Add TRACE, CONNECT, and PATCH http methods (#31079) Change ObjectParser exception (#31030) Make sure KeywordFieldMapper#clone preserves split_queries_on_whitespace. (#31049) [DOCS] Removes duplicated authentication pages [Rollup] Specialize validation exception for easier management (#30339) Enable customizing REST tests blacklist (#31074) [DOCS] Moves machine learning overview to stack-docs [ML] Add secondary sort to ML events (#31063) QA: Check rollup job creation safety (#31036) Adapt bwc versions after backporting #31045 to 6.3 Remove usage of explicit type in docs (#29667) Move pipeline APIs to ingest namespace (#31027) Adapt bwc versions after backporting #31045 to 6.x Make Persistent Tasks implementations version and feature aware (#31045) Mute MatchPhrase*QueryBuilderTests [Docs] Fix typo in watcher conditions documentation (#30989) Remove wrong link in index phrases doc Reuse expiration date of trial licenses (#31033) Index phrases (#30450) [DOCS] Fixes accounting setting names (#30863) [DOCS] Rewords _field_names documentation (#31029)
- Loading branch information
Showing
116 changed files
with
1,664 additions
and
1,857 deletions.
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
114 changes: 114 additions & 0 deletions
114
client/rest-high-level/src/main/java/org/elasticsearch/client/IngestClient.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,114 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.apache.http.Header; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.ingest.DeletePipelineRequest; | ||
import org.elasticsearch.action.ingest.GetPipelineRequest; | ||
import org.elasticsearch.action.ingest.GetPipelineResponse; | ||
import org.elasticsearch.action.ingest.PutPipelineRequest; | ||
import org.elasticsearch.action.ingest.WritePipelineResponse; | ||
|
||
import java.io.IOException; | ||
|
||
import static java.util.Collections.emptySet; | ||
|
||
/** | ||
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Ingest API. | ||
* <p> | ||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html">Ingest API on elastic.co</a> | ||
*/ | ||
public final class IngestClient { | ||
|
||
private final RestHighLevelClient restHighLevelClient; | ||
|
||
IngestClient(RestHighLevelClient restHighLevelClient) { | ||
this.restHighLevelClient = restHighLevelClient; | ||
} | ||
|
||
/** | ||
* Add a pipeline or update an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Put Pipeline API on elastic.co</a> | ||
*/ | ||
public WritePipelineResponse putPipeline(PutPipelineRequest request, Header... headers) throws IOException { | ||
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, | ||
WritePipelineResponse::fromXContent, emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Asynchronously add a pipeline or update an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Put Pipeline API on elastic.co</a> | ||
*/ | ||
public void putPipelineAsync(PutPipelineRequest request, ActionListener<WritePipelineResponse> listener, Header... headers) { | ||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, | ||
WritePipelineResponse::fromXContent, listener, emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Get an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-pipeline-api.html"> Get Pipeline API on elastic.co</a> | ||
*/ | ||
public GetPipelineResponse getPipeline(GetPipelineRequest request, Header... headers) throws IOException { | ||
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::getPipeline, | ||
GetPipelineResponse::fromXContent, emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Asynchronously get an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html"> Get Pipeline API on elastic.co</a> | ||
*/ | ||
public void getPipelineAsync(GetPipelineRequest request, ActionListener<GetPipelineResponse> listener, Header... headers) { | ||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline, | ||
GetPipelineResponse::fromXContent, listener, emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Delete an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-pipeline-api.html"> | ||
* Delete Pipeline API on elastic.co</a> | ||
*/ | ||
public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Header... headers) throws IOException { | ||
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, | ||
WritePipelineResponse::fromXContent, emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Asynchronously delete an existing pipeline | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-pipeline-api.html"> | ||
* Delete Pipeline API on elastic.co</a> | ||
*/ | ||
public void deletePipelineAsync(DeletePipelineRequest request, ActionListener<WritePipelineResponse> listener, Header... headers) { | ||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, | ||
WritePipelineResponse::fromXContent, listener, emptySet(), headers); | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.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,83 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.action.ingest.DeletePipelineRequest; | ||
import org.elasticsearch.action.ingest.GetPipelineRequest; | ||
import org.elasticsearch.action.ingest.GetPipelineResponse; | ||
import org.elasticsearch.action.ingest.PutPipelineRequest; | ||
import org.elasticsearch.action.ingest.WritePipelineResponse; | ||
import org.elasticsearch.common.bytes.BytesReference; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.ingest.PipelineConfiguration; | ||
|
||
import java.io.IOException; | ||
|
||
public class IngestClientIT extends ESRestHighLevelClientTestCase { | ||
|
||
public void testPutPipeline() throws IOException { | ||
String id = "some_pipeline_id"; | ||
XContentBuilder pipelineBuilder = buildRandomXContentPipeline(); | ||
PutPipelineRequest request = new PutPipelineRequest( | ||
id, | ||
BytesReference.bytes(pipelineBuilder), | ||
pipelineBuilder.contentType()); | ||
|
||
WritePipelineResponse putPipelineResponse = | ||
execute(request, highLevelClient().ingest()::putPipeline, highLevelClient().ingest()::putPipelineAsync); | ||
assertTrue(putPipelineResponse.isAcknowledged()); | ||
} | ||
|
||
public void testGetPipeline() throws IOException { | ||
String id = "some_pipeline_id"; | ||
XContentBuilder pipelineBuilder = buildRandomXContentPipeline(); | ||
{ | ||
PutPipelineRequest request = new PutPipelineRequest( | ||
id, | ||
BytesReference.bytes(pipelineBuilder), | ||
pipelineBuilder.contentType() | ||
); | ||
createPipeline(request); | ||
} | ||
|
||
GetPipelineRequest request = new GetPipelineRequest(id); | ||
|
||
GetPipelineResponse response = | ||
execute(request, highLevelClient().ingest()::getPipeline, highLevelClient().ingest()::getPipelineAsync); | ||
assertTrue(response.isFound()); | ||
assertEquals(response.pipelines().get(0).getId(), id); | ||
PipelineConfiguration expectedConfig = | ||
new PipelineConfiguration(id, BytesReference.bytes(pipelineBuilder), pipelineBuilder.contentType()); | ||
assertEquals(expectedConfig.getConfigAsMap(), response.pipelines().get(0).getConfigAsMap()); | ||
} | ||
|
||
public void testDeletePipeline() throws IOException { | ||
String id = "some_pipeline_id"; | ||
{ | ||
createPipeline(id); | ||
} | ||
|
||
DeletePipelineRequest request = new DeletePipelineRequest(id); | ||
|
||
WritePipelineResponse response = | ||
execute(request, highLevelClient().ingest()::deletePipeline, highLevelClient().ingest()::deletePipelineAsync); | ||
assertTrue(response.isAcknowledged()); | ||
} | ||
} |
Oops, something went wrong.