diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichClient.java
index b70b7edb05d31..d7e7199f7cc71 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichClient.java
@@ -20,6 +20,7 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.core.AcknowledgedResponse;
+import org.elasticsearch.client.enrich.DeletePolicyRequest;
import org.elasticsearch.client.enrich.PutPolicyRequest;
import java.io.IOException;
@@ -43,7 +44,7 @@ public final class EnrichClient {
/**
* Executes the put policy api, which stores an enrich policy.
*
- * See
+ * See
* the docs for more.
*
* @param request the {@link PutPolicyRequest}
@@ -64,7 +65,7 @@ public AcknowledgedResponse putPolicy(PutPolicyRequest request, RequestOptions o
/**
* Asynchronously executes the put policy api, which stores an enrich policy.
*
- * See
+ * See
* the docs for more.
*
* @param request the {@link PutPolicyRequest}
@@ -83,4 +84,48 @@ public void putPolicyAsync(PutPolicyRequest request,
Collections.emptySet()
);
}
+
+ /**
+ * Executes the delete policy api, which deletes an enrich policy.
+ *
+ * See
+ * the docs for more.
+ *
+ * @param request the {@link DeletePolicyRequest}
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the response
+ * @throws IOException in case there is a problem sending the request or parsing back the response
+ */
+ public AcknowledgedResponse deletePolicy(DeletePolicyRequest request, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(
+ request,
+ EnrichRequestConverters::deletePolicy,
+ options,
+ AcknowledgedResponse::fromXContent,
+ Collections.emptySet()
+ );
+ }
+
+ /**
+ * Asynchronously executes the delete policy api, which deletes an enrich policy.
+ *
+ * See
+ * the docs for more.
+ *
+ * @param request the {@link DeletePolicyRequest}
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @param listener the listener to be notified upon request completion
+ */
+ public void deletePolicyAsync(DeletePolicyRequest request,
+ RequestOptions options,
+ ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(
+ request,
+ EnrichRequestConverters::deletePolicy,
+ options,
+ AcknowledgedResponse::fromXContent,
+ listener,
+ Collections.emptySet()
+ );
+ }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichRequestConverters.java
index c1e9c57078ef5..6cce24cde784f 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/EnrichRequestConverters.java
@@ -18,7 +18,9 @@
*/
package org.elasticsearch.client;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPut;
+import org.elasticsearch.client.enrich.DeletePolicyRequest;
import org.elasticsearch.client.enrich.PutPolicyRequest;
import java.io.IOException;
@@ -38,4 +40,12 @@ static Request putPolicy(PutPolicyRequest putPolicyRequest) throws IOException {
return request;
}
+ static Request deletePolicy(DeletePolicyRequest deletePolicyRequest) {
+ String endpoint = new RequestConverters.EndpointBuilder()
+ .addPathPartAsIs("_enrich", "policy")
+ .addPathPart(deletePolicyRequest.getName())
+ .build();
+ return new Request(HttpDelete.METHOD_NAME, endpoint);
+ }
+
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/enrich/DeletePolicyRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/enrich/DeletePolicyRequest.java
new file mode 100644
index 0000000000000..c6214d3f130e1
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/enrich/DeletePolicyRequest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.enrich;
+
+import org.elasticsearch.client.Validatable;
+import org.elasticsearch.common.Strings;
+
+public class DeletePolicyRequest implements Validatable {
+
+ private final String name;
+
+ public DeletePolicyRequest(String name) {
+ if (Strings.hasLength(name) == false) {
+ throw new IllegalArgumentException("name must be a non-null and non-empty string");
+ }
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/EnrichIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/EnrichIT.java
index 8911893e94735..1134bdef76889 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/EnrichIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/EnrichIT.java
@@ -20,6 +20,7 @@
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.core.AcknowledgedResponse;
+import org.elasticsearch.client.enrich.DeletePolicyRequest;
import org.elasticsearch.client.enrich.PutPolicyRequest;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.json.JsonXContent;
@@ -46,15 +47,26 @@ public void testCRUD() throws Exception {
Response getPolicyResponse = highLevelClient().getLowLevelClient().performRequest(getPolicyRequest);
assertThat(getPolicyResponse.getHttpResponse().getStatusLine().getStatusCode(), equalTo(200));
Map responseBody = toMap(getPolicyResponse);
- @SuppressWarnings("unchecked")
- List