diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
index 8c5c908945412..3ba9937e44e12 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
@@ -30,8 +30,6 @@
import org.elasticsearch.client.indexlifecycle.LifecycleManagementStatusResponse;
import org.elasticsearch.client.indexlifecycle.PutLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyResponse;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
import org.elasticsearch.client.indexlifecycle.StopILMRequest;
@@ -133,35 +131,6 @@ public void deleteLifecyclePolicyAsync(DeleteLifecyclePolicyRequest request, Req
AcknowledgedResponse::fromXContent, listener, emptySet());
}
- /**
- * Remove the index lifecycle policy for an index
- * See
- * the docs for more.
- * @param request the request
- * @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 RemoveIndexLifecyclePolicyResponse removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest request,
- RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::removeIndexLifecyclePolicy, options,
- RemoveIndexLifecyclePolicyResponse::fromXContent, emptySet());
- }
-
- /**
- * Asynchronously remove the index lifecycle policy for an index
- * See
- * the docs for more.
- * @param request the request
- * @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 removeIndexLifecyclePolicyAsync(RemoveIndexLifecyclePolicyRequest request, RequestOptions options,
- ActionListener listener) {
- restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::removeIndexLifecyclePolicy, options,
- RemoveIndexLifecyclePolicyResponse::fromXContent, listener, emptySet());
- }
-
/**
* Start the Index Lifecycle Management feature.
* See
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
index 2cc5efb9a4ccc..2a5c16c0243d8 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
@@ -56,7 +56,6 @@
import org.elasticsearch.client.indexlifecycle.LifecycleManagementStatusRequest;
import org.elasticsearch.client.indexlifecycle.PutLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
import org.elasticsearch.client.indexlifecycle.StopILMRequest;
import org.elasticsearch.client.security.RefreshPolicy;
@@ -640,20 +639,6 @@ static Request deleteLifecyclePolicy(DeleteLifecyclePolicyRequest deleteLifecycl
return request;
}
- static Request removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest removePolicyRequest) {
- String[] indices = removePolicyRequest.indices() == null ?
- Strings.EMPTY_ARRAY : removePolicyRequest.indices().toArray(new String[] {});
- Request request = new Request(HttpDelete.METHOD_NAME,
- new EndpointBuilder()
- .addCommaSeparatedPathParts(indices)
- .addPathPartAsIs("_ilm")
- .build());
- Params params = new Params(request);
- params.withIndicesOptions(removePolicyRequest.indicesOptions());
- params.withMasterTimeout(removePolicyRequest.masterNodeTimeout());
- return request;
- }
-
static Request startILM(StartILMRequest startILMRequest) {
Request request = new Request(HttpPost.METHOD_NAME,
new EndpointBuilder()
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequest.java
deleted file mode 100644
index 88bdf4dd6868d..0000000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.indexlifecycle;
-
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.client.TimedRequest;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-public class RemoveIndexLifecyclePolicyRequest extends TimedRequest {
-
- private final List indices;
- private final IndicesOptions indicesOptions;
-
- public RemoveIndexLifecyclePolicyRequest(List indices) {
- this(indices, IndicesOptions.strictExpandOpen());
- }
-
- public RemoveIndexLifecyclePolicyRequest(List indices, IndicesOptions indicesOptions) {
- this.indices = Collections.unmodifiableList(Objects.requireNonNull(indices));
- this.indicesOptions = Objects.requireNonNull(indicesOptions);
- }
-
- public List indices() {
- return indices;
- }
-
- public IndicesOptions indicesOptions() {
- return indicesOptions;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(indices, indicesOptions);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RemoveIndexLifecyclePolicyRequest other = (RemoveIndexLifecyclePolicyRequest) obj;
- return Objects.deepEquals(indices, other.indices) &&
- Objects.equals(indicesOptions, other.indicesOptions);
- }
-}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponse.java
deleted file mode 100644
index 3aae1537faa29..0000000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponse.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.indexlifecycle;
-
-import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.xcontent.ConstructingObjectParser;
-import org.elasticsearch.common.xcontent.XContentParser;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-public class RemoveIndexLifecyclePolicyResponse {
-
- public static final ParseField HAS_FAILURES_FIELD = new ParseField("has_failures");
- public static final ParseField FAILED_INDEXES_FIELD = new ParseField("failed_indexes");
- @SuppressWarnings("unchecked")
- public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(
- "change_policy_for_index_response", true, args -> new RemoveIndexLifecyclePolicyResponse((List)args[0]));
- static {
- PARSER.declareStringArray(ConstructingObjectParser.constructorArg(), FAILED_INDEXES_FIELD);
- // Needs to be declared but not used in constructing the response object
- PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), HAS_FAILURES_FIELD);
- }
-
- private final List failedIndexes;
-
- public RemoveIndexLifecyclePolicyResponse(List failedIndexes) {
- if (failedIndexes == null) {
- throw new IllegalArgumentException(FAILED_INDEXES_FIELD.getPreferredName() + " cannot be null");
- }
- this.failedIndexes = Collections.unmodifiableList(failedIndexes);
- }
-
- public List getFailedIndexes() {
- return failedIndexes;
- }
-
- public boolean hasFailures() {
- return failedIndexes.isEmpty() == false;
- }
-
- public static RemoveIndexLifecyclePolicyResponse fromXContent(XContentParser parser) {
- return PARSER.apply(parser, null);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(failedIndexes);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RemoveIndexLifecyclePolicyResponse other = (RemoveIndexLifecyclePolicyResponse) obj;
- return Objects.equals(failedIndexes, other.failedIndexes);
- }
-}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
index f2040bc88da34..cb8ed65746958 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
@@ -20,8 +20,6 @@
package org.elasticsearch.client;
import org.elasticsearch.ElasticsearchStatusException;
-import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
-import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.indexlifecycle.AllocateAction;
import org.elasticsearch.client.indexlifecycle.DeleteAction;
@@ -42,8 +40,6 @@
import org.elasticsearch.client.indexlifecycle.PhaseExecutionInfo;
import org.elasticsearch.client.indexlifecycle.PutLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyResponse;
import org.elasticsearch.client.indexlifecycle.RolloverAction;
import org.elasticsearch.client.indexlifecycle.ShrinkAction;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
@@ -53,7 +49,6 @@
import org.hamcrest.Matchers;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -69,39 +64,6 @@
public class IndexLifecycleIT extends ESRestHighLevelClientTestCase {
- public void testRemoveIndexLifecyclePolicy() throws Exception {
- String policyName = randomAlphaOfLength(10);
- LifecyclePolicy policy = createRandomPolicy(policyName);
- PutLifecyclePolicyRequest putRequest = new PutLifecyclePolicyRequest(policy);
- assertAcked(execute(putRequest, highLevelClient().indexLifecycle()::putLifecyclePolicy,
- highLevelClient().indexLifecycle()::putLifecyclePolicyAsync));
-
- createIndex("foo", Settings.builder().put("index.lifecycle.name", policyName).build());
- createIndex("baz", Settings.builder().put("index.lifecycle.name", policyName).build());
- createIndex("rbh", Settings.builder().put("index.lifecycle.name", policyName).build());
-
- GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices("foo", "baz", "rbh");
- GetSettingsResponse settingsResponse = highLevelClient().indices().getSettings(getSettingsRequest, RequestOptions.DEFAULT);
- assertThat(settingsResponse.getSetting("foo", "index.lifecycle.name"), equalTo(policyName));
- assertThat(settingsResponse.getSetting("baz", "index.lifecycle.name"), equalTo(policyName));
- assertThat(settingsResponse.getSetting("rbh", "index.lifecycle.name"), equalTo(policyName));
-
- List indices = new ArrayList<>();
- indices.add("foo");
- indices.add("rbh");
- RemoveIndexLifecyclePolicyRequest removeReq = new RemoveIndexLifecyclePolicyRequest(indices);
- RemoveIndexLifecyclePolicyResponse removeResp = execute(removeReq, highLevelClient().indexLifecycle()::removeIndexLifecyclePolicy,
- highLevelClient().indexLifecycle()::removeIndexLifecyclePolicyAsync);
- assertThat(removeResp.hasFailures(), is(false));
- assertThat(removeResp.getFailedIndexes().isEmpty(), is(true));
-
- getSettingsRequest = new GetSettingsRequest().indices("foo", "baz", "rbh");
- settingsResponse = highLevelClient().indices().getSettings(getSettingsRequest, RequestOptions.DEFAULT);
- assertNull(settingsResponse.getSetting("foo", "index.lifecycle.name"));
- assertThat(settingsResponse.getSetting("baz", "index.lifecycle.name"), equalTo(policyName));
- assertNull(settingsResponse.getSetting("rbh", "index.lifecycle.name"));
- }
-
public void testStartStopILM() throws Exception {
String policyName = randomAlphaOfLength(10);
LifecyclePolicy policy = createRandomPolicy(policyName);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
index 113380bd08d9e..efa90112d8c5e 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
@@ -62,7 +62,6 @@
import org.elasticsearch.client.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.client.indexlifecycle.PutLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
-import org.elasticsearch.client.indexlifecycle.RemoveIndexLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
import org.elasticsearch.client.indexlifecycle.StopILMRequest;
import org.elasticsearch.common.CheckedBiConsumer;
@@ -1509,20 +1508,6 @@ public void testDeleteLifecycle() {
assertEquals(request.getParameters(), expectedParams);
}
- public void testRemoveIndexLifecyclePolicy() {
- Map expectedParams = new HashMap<>();
- String[] indices = randomIndicesNames(0, 10);
- IndicesOptions indicesOptions = setRandomIndicesOptions(IndicesOptions.strictExpandOpen(), expectedParams);
- RemoveIndexLifecyclePolicyRequest req = new RemoveIndexLifecyclePolicyRequest(Arrays.asList(indices), indicesOptions);
- setRandomMasterTimeout(req::setMasterTimeout, TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT, expectedParams);
-
- Request request = RequestConverters.removeIndexLifecyclePolicy(req);
- assertThat(request.getMethod(), equalTo(HttpDelete.METHOD_NAME));
- String idxString = Strings.arrayToCommaDelimitedString(indices);
- assertThat(request.getEndpoint(), equalTo("/" + (idxString.isEmpty() ? "" : (idxString + "/")) + "_ilm"));
- assertThat(request.getParameters(), equalTo(expectedParams));
- }
-
public void testStartILM() throws Exception {
StartILMRequest req = new StartILMRequest();
Map expectedParams = new HashMap<>();
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequestTests.java
deleted file mode 100644
index 532688c475115..0000000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyRequestTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.indexlifecycle;
-
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.EqualsHashCodeTestUtils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class RemoveIndexLifecyclePolicyRequestTests extends ESTestCase {
-
- public void testNullIndices() {
- expectThrows(NullPointerException.class, () -> new RemoveIndexLifecyclePolicyRequest(null));
- }
-
- public void testNullIndicesOptions() {
- expectThrows(NullPointerException.class, () -> new RemoveIndexLifecyclePolicyRequest(Collections.emptyList(), null));
- }
-
- public void testValidate() {
- RemoveIndexLifecyclePolicyRequest request = new RemoveIndexLifecyclePolicyRequest(Collections.emptyList());
- assertFalse(request.validate().isPresent());
- }
-
- protected RemoveIndexLifecyclePolicyRequest createInstance() {
- if (randomBoolean()) {
- return new RemoveIndexLifecyclePolicyRequest(Arrays.asList(generateRandomStringArray(20, 20, false)),
- IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(),
- randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
- } else {
- return new RemoveIndexLifecyclePolicyRequest(Arrays.asList(generateRandomStringArray(20, 20, false)));
- }
- }
-
- private RemoveIndexLifecyclePolicyRequest copyInstance(RemoveIndexLifecyclePolicyRequest req) {
- return new RemoveIndexLifecyclePolicyRequest(new ArrayList<>(req.indices()), IndicesOptions.fromOptions(
- req.indicesOptions().ignoreUnavailable(), req.indicesOptions().allowNoIndices(),
- req.indicesOptions().expandWildcardsOpen(), req.indicesOptions().expandWildcardsClosed(),
- req.indicesOptions().allowAliasesToMultipleIndices(), req.indicesOptions().forbidClosedIndices(),
- req.indicesOptions().ignoreAliases()));
- }
-
- private RemoveIndexLifecyclePolicyRequest mutateInstance(RemoveIndexLifecyclePolicyRequest req) {
- if (randomBoolean()) {
- return new RemoveIndexLifecyclePolicyRequest(req.indices(),
- randomValueOtherThan(req.indicesOptions(), () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(),
- randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean())));
- } else {
- return new RemoveIndexLifecyclePolicyRequest(
- randomValueOtherThan(req.indices(), () -> Arrays.asList(generateRandomStringArray(20, 20, false))),
- req.indicesOptions());
- }
- }
-
- public void testEqualsAndHashCode() {
- for (int count = 0; count < 100; ++count) {
- EqualsHashCodeTestUtils.checkEqualsAndHashCode(createInstance(), this::copyInstance, this::mutateInstance);
- }
- }
-}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponseTests.java
deleted file mode 100644
index 1f99a2dfdfac4..0000000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/RemoveIndexLifecyclePolicyResponseTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.indexlifecycle;
-
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.EqualsHashCodeTestUtils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
-
-public class RemoveIndexLifecyclePolicyResponseTests extends ESTestCase {
-
- private void toXContent(RemoveIndexLifecyclePolicyResponse response, XContentBuilder builder) throws IOException {
- builder.startObject();
- builder.field(RemoveIndexLifecyclePolicyResponse.HAS_FAILURES_FIELD.getPreferredName(), response.hasFailures());
- builder.field(RemoveIndexLifecyclePolicyResponse.FAILED_INDEXES_FIELD.getPreferredName(), response.getFailedIndexes());
- builder.endObject();
- }
-
- private RemoveIndexLifecyclePolicyResponse createInstance() {
- List failedIndexes = Arrays.asList(generateRandomStringArray(20, 20, false));
- return new RemoveIndexLifecyclePolicyResponse(failedIndexes);
- }
-
- private RemoveIndexLifecyclePolicyResponse copyInstance(RemoveIndexLifecyclePolicyResponse req) {
- return new RemoveIndexLifecyclePolicyResponse(new ArrayList<>(req.getFailedIndexes()));
- }
-
- private RemoveIndexLifecyclePolicyResponse mutateInstance(RemoveIndexLifecyclePolicyResponse req) {
- return new RemoveIndexLifecyclePolicyResponse(randomValueOtherThan(req.getFailedIndexes(),
- () -> Arrays.asList(generateRandomStringArray(20, 20, false))));
- }
-
- public void testFromXContent() throws IOException {
- xContentTester(
- this::createParser,
- this::createInstance,
- this::toXContent,
- RemoveIndexLifecyclePolicyResponse::fromXContent)
- .supportsUnknownFields(true)
- .test();
- }
-
- public void testNullFailedIndices() {
- IllegalArgumentException exception =
- expectThrows(IllegalArgumentException.class, () -> new RemoveIndexLifecyclePolicyResponse(null));
- assertEquals("failed_indexes cannot be null", exception.getMessage());
- }
-
- public void testHasFailures() {
- RemoveIndexLifecyclePolicyResponse response = new RemoveIndexLifecyclePolicyResponse(new ArrayList<>());
- assertFalse(response.hasFailures());
- assertEquals(Collections.emptyList(), response.getFailedIndexes());
-
- int size = randomIntBetween(1, 10);
- List failedIndexes = new ArrayList<>(size);
- for (int i = 0; i < size; i++) {
- failedIndexes.add(randomAlphaOfLength(20));
- }
- response = new RemoveIndexLifecyclePolicyResponse(failedIndexes);
- assertTrue(response.hasFailures());
- assertEquals(failedIndexes, response.getFailedIndexes());
- }
-
- public void testEqualsAndHashCode() {
- for (int count = 0; count < 100; ++count) {
- EqualsHashCodeTestUtils.checkEqualsAndHashCode(createInstance(), this::copyInstance, this::mutateInstance);
- }
- }
-}
diff --git a/x-pack/docs/en/ilm/apis/ilm-api.asciidoc b/x-pack/docs/en/ilm/apis/ilm-api.asciidoc
index 1139990edf62c..b04c5583dd6cd 100644
--- a/x-pack/docs/en/ilm/apis/ilm-api.asciidoc
+++ b/x-pack/docs/en/ilm/apis/ilm-api.asciidoc
@@ -16,7 +16,6 @@ You can use the following APIs to manage policies on indices.
=== Index Management APIs
* <>
-* <>
* <>
[float]
@@ -34,8 +33,6 @@ include::get-lifecycle.asciidoc[]
include::delete-lifecycle.asciidoc[]
include::move-to-step.asciidoc[]
-include::set-policy.asciidoc[]
-include::remove-policy.asciidoc[]
include::retry-policy.asciidoc[]
include::get-status.asciidoc[]
diff --git a/x-pack/docs/en/ilm/apis/remove-policy.asciidoc b/x-pack/docs/en/ilm/apis/remove-policy.asciidoc
deleted file mode 100644
index 3e13f852af866..0000000000000
--- a/x-pack/docs/en/ilm/apis/remove-policy.asciidoc
+++ /dev/null
@@ -1,98 +0,0 @@
-[role="xpack"]
-[testenv="basic"]
-[[ilm-remove-policy]]
-=== Remove Policy On Index API
-++++
-Remove Policy From Index
-++++
-
-Unassigns a policy from a specified index pattern
-
-==== Request
-
-`DELETE /_ilm`
-
-==== Description
-
-This action removes a policy from managing an index. It is effectively the same as setting an index's
-`index.lifecycle.name` setting to null.
-
-==== Path Parameters
-
-`index` (required)::
- (string) Identifier for the index.
-
-==== Request Parameters
-
-`timeout`::
- (time units) Specifies the period of time to wait for the completion of the
- operation. When this period of time elapses, the API fails and returns
- an error. The default value is `30s`. For more information about time units,
- see <>.
-
-`master_timeout`::
- (time units) Specifies the period of time to wait for the connection with master.
- When this period of time elapses, the API fails and returns an error.
- The default value is `30s`. For more information about time units, see <>.
-
-
-==== Examples
-
-The following example removes a policy `my_policy` from an index `my_index`.
-
-//////////////////////////
-
-[source,js]
---------------------------------------------------
-PUT _ilm/my_policy
-{
- "policy": {
- "phases": {
- "warm": {
- "minimum_age": "10d",
- "actions": {
- "forcemerge": {
- "max_num_segments": 1
- }
- }
- },
- "delete": {
- "minimum_age": "30d",
- "actions": {
- "delete": {}
- }
- }
- }
- }
-}
-
-PUT my_index
-{
- "settings": {
- "index.lifecycle.name": "my_policy"
- }
-}
---------------------------------------------------
-// CONSOLE
-// TEST
-
-//////////////////////////
-
-[source,js]
---------------------------------------------------
-DELETE my_index/_ilm
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-
-If the request does not encounter errors, you receive the following result:
-
-[source,js]
---------------------------------------------------
-{
- "has_failures" : false,
- "failed_indexes" : []
-}
---------------------------------------------------
-// CONSOLE
-// TESTRESPONSE
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
index 1d11f3df1721d..7b0aaeef17c77 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
@@ -59,7 +59,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.action.GetLifecycleAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction;
import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage;
import org.elasticsearch.xpack.core.ml.MachineLearningFeatureSetUsage;
@@ -341,7 +340,6 @@ public List> getClientActions() {
GetLifecycleAction.INSTANCE,
PutLifecycleAction.INSTANCE,
ExplainLifecycleAction.INSTANCE,
- RemoveIndexLifecyclePolicyAction.INSTANCE,
MoveToStepAction.INSTANCE,
RetryAction.INSTANCE
);
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyAction.java
deleted file mode 100644
index 239e748e58d8a..0000000000000
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyAction.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-package org.elasticsearch.xpack.core.indexlifecycle.action;
-
-import org.elasticsearch.action.Action;
-import org.elasticsearch.action.ActionRequestValidationException;
-import org.elasticsearch.action.ActionResponse;
-import org.elasticsearch.action.IndicesRequest;
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.action.support.master.AcknowledgedRequest;
-import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.xcontent.ConstructingObjectParser;
-import org.elasticsearch.common.xcontent.ToXContentObject;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-public class RemoveIndexLifecyclePolicyAction extends Action {
- public static final RemoveIndexLifecyclePolicyAction INSTANCE = new RemoveIndexLifecyclePolicyAction();
- public static final String NAME = "indices:admin/ilm/remove_policy";
-
- protected RemoveIndexLifecyclePolicyAction() {
- super(NAME);
- }
-
- @Override
- public RemoveIndexLifecyclePolicyAction.Response newResponse() {
- return new Response();
- }
-
- public static class Response extends ActionResponse implements ToXContentObject {
-
- public static final ParseField HAS_FAILURES_FIELD = new ParseField("has_failures");
- public static final ParseField FAILED_INDEXES_FIELD = new ParseField("failed_indexes");
- @SuppressWarnings("unchecked")
- public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(
- "change_policy_for_index_response", a -> new Response((List) a[0]));
- static {
- PARSER.declareStringArray(ConstructingObjectParser.constructorArg(), FAILED_INDEXES_FIELD);
- // Needs to be declared but not used in constructing the response object
- PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), HAS_FAILURES_FIELD);
- }
-
- private List failedIndexes;
-
- public Response() {
- }
-
- public Response(List failedIndexes) {
- if (failedIndexes == null) {
- throw new IllegalArgumentException(FAILED_INDEXES_FIELD.getPreferredName() + " cannot be null");
- }
- this.failedIndexes = failedIndexes;
- }
-
- public List getFailedIndexes() {
- return failedIndexes;
- }
-
- public boolean hasFailures() {
- return failedIndexes.isEmpty() == false;
- }
-
- @Override
- public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
- builder.startObject();
- builder.field(HAS_FAILURES_FIELD.getPreferredName(), hasFailures());
- builder.field(FAILED_INDEXES_FIELD.getPreferredName(), failedIndexes);
- builder.endObject();
- return builder;
- }
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- failedIndexes = in.readList(StreamInput::readString);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeStringList(failedIndexes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(failedIndexes);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Response other = (Response) obj;
- return Objects.equals(failedIndexes, other.failedIndexes);
- }
-
- }
-
- public static class Request extends AcknowledgedRequest implements IndicesRequest.Replaceable {
-
- private String[] indices;
- private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
-
- public Request() {
- }
-
- public Request(String... indices) {
- if (indices == null) {
- throw new IllegalArgumentException("indices cannot be null");
- }
- this.indices = indices;
- }
-
- @Override
- public Request indices(String... indices) {
- this.indices = indices;
- return this;
- }
-
- @Override
- public String[] indices() {
- return indices;
- }
-
- public void indicesOptions(IndicesOptions indicesOptions) {
- this.indicesOptions = indicesOptions;
- }
-
- public IndicesOptions indicesOptions() {
- return indicesOptions;
- }
-
- @Override
- public ActionRequestValidationException validate() {
- return null;
- }
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- indices = in.readStringArray();
- indicesOptions = IndicesOptions.readIndicesOptions(in);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeStringArray(indices);
- indicesOptions.writeIndicesOptions(out);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(Arrays.hashCode(indices), indicesOptions);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Request other = (Request) obj;
- return Objects.deepEquals(indices, other.indices) &&
- Objects.equals(indicesOptions, other.indicesOptions);
- }
-
- }
-}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/client/ILMClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/client/ILMClient.java
index 5e81d2e2aa7e5..8581171fec3dd 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/client/ILMClient.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/client/ILMClient.java
@@ -19,7 +19,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.action.GetLifecycleAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
@@ -105,22 +104,6 @@ public ActionFuture getStatus(GetStatusAction.Request
return client.execute(GetStatusAction.INSTANCE, request);
}
- /**
- * Removes index lifecycle management from an index
- */
- public void removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyAction.Request request,
- ActionListener listener) {
- client.execute(RemoveIndexLifecyclePolicyAction.INSTANCE, request, listener);
- }
-
- /**
- * Removes index lifecycle management from an index
- */
- public ActionFuture removeIndexLifecyclePolicy(
- RemoveIndexLifecyclePolicyAction.Request request) {
- return client.execute(RemoveIndexLifecyclePolicyAction.INSTANCE, request);
- }
-
/**
* Retries the policy for an index which is currently in ERROR
*/
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyRequestTests.java
deleted file mode 100644
index 3f36820422614..0000000000000
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyRequestTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-package org.elasticsearch.xpack.core.indexlifecycle.action;
-
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.test.AbstractStreamableTestCase;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction.Request;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-public class RemoveIndexLifecyclePolicyRequestTests extends AbstractStreamableTestCase {
-
- @Override
- protected Request createTestInstance() {
- Request request = new Request(generateRandomStringArray(20, 20, false));
- if (randomBoolean()) {
- IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
- randomBoolean(), randomBoolean(), randomBoolean());
- request.indicesOptions(indicesOptions);
- }
- if (randomBoolean()) {
- request.indices(generateRandomStringArray(20, 20, false));
- }
- return request;
- }
-
- @Override
- protected Request createBlankInstance() {
- return new Request();
- }
-
- @Override
- protected Request mutateInstance(Request instance) throws IOException {
- String[] indices = instance.indices();
- IndicesOptions indicesOptions = instance.indicesOptions();
- switch (between(0, 1)) {
- case 0:
- indices = randomValueOtherThanMany(i -> Arrays.equals(i, instance.indices()),
- () -> generateRandomStringArray(20, 20, false));
- break;
- case 1:
- indicesOptions = randomValueOtherThan(indicesOptions, () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(),
- randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
- break;
- default:
- throw new AssertionError("Illegal randomisation branch");
- }
- Request newRequest = new Request(indices);
- newRequest.indicesOptions(indicesOptions);
- return newRequest;
- }
-
- public void testNullIndices() {
- IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
- () -> new Request((String[]) null));
- assertEquals("indices cannot be null", exception.getMessage());
- }
-
- public void testValidate() {
- Request request = createTestInstance();
- assertNull(request.validate());
- }
-}
diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyResponseTests.java
deleted file mode 100644
index a394e593e7307..0000000000000
--- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RemoveIndexLifecyclePolicyResponseTests.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-package org.elasticsearch.xpack.core.indexlifecycle.action;
-
-import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.test.AbstractStreamableXContentTestCase;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction.Response;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class RemoveIndexLifecyclePolicyResponseTests extends AbstractStreamableXContentTestCase {
-
- @Override
- protected Response createBlankInstance() {
- return new Response();
- }
-
- @Override
- protected Response createTestInstance() {
- List failedIndexes = Arrays.asList(generateRandomStringArray(20, 20, false));
- return new Response(failedIndexes);
- }
-
- @Override
- protected Response mutateInstance(Response instance) throws IOException {
- List failedIndices = randomValueOtherThan(instance.getFailedIndexes(),
- () -> Arrays.asList(generateRandomStringArray(20, 20, false)));
- return new Response(failedIndices);
- }
-
- @Override
- protected Response doParseInstance(XContentParser parser) throws IOException {
- return Response.PARSER.apply(parser, null);
- }
-
- @Override
- protected boolean supportsUnknownFields() {
- return false;
- }
-
- public void testNullFailedIndices() {
- IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> new Response((List) null));
- assertEquals("failed_indexes cannot be null", exception.getMessage());
- }
-
- public void testHasFailures() {
- Response response = new Response(new ArrayList<>());
- assertFalse(response.hasFailures());
- assertEquals(Collections.emptyList(), response.getFailedIndexes());
-
- int size = randomIntBetween(1, 10);
- List failedIndexes = new ArrayList<>(size);
- for (int i = 0; i < size; i++) {
- failedIndexes.add(randomAlphaOfLength(20));
- }
- response = new Response(failedIndexes);
- assertTrue(response.hasFailures());
- assertEquals(failedIndexes, response.getFailedIndexes());
- }
-
-}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
index 6854dbf2afc95..ed0b22132e2be 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
@@ -51,7 +51,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
@@ -61,7 +60,6 @@
import org.elasticsearch.xpack.indexlifecycle.action.RestGetStatusAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestMoveToStepAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestPutLifecycleAction;
-import org.elasticsearch.xpack.indexlifecycle.action.RestRemoveIndexLifecyclePolicyAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestRetryAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestStartILMAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestStopAction;
@@ -71,7 +69,6 @@
import org.elasticsearch.xpack.indexlifecycle.action.TransportGetStatusAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportMoveToStepAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportPutLifecycleAction;
-import org.elasticsearch.xpack.indexlifecycle.action.TransportRemoveIndexLifecyclePolicyAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportRetryAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportStartILMAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportStopILMAction;
@@ -173,7 +170,6 @@ public List getRestHandlers(Settings settings, RestController restC
new RestGetLifecycleAction(settings, restController),
new RestDeleteLifecycleAction(settings, restController),
new RestExplainLifecycleAction(settings, restController),
- new RestRemoveIndexLifecyclePolicyAction(settings, restController),
new RestMoveToStepAction(settings, restController),
new RestRetryAction(settings, restController),
new RestStopAction(settings, restController),
@@ -192,7 +188,6 @@ public List getRestHandlers(Settings settings, RestController restC
new ActionHandler<>(GetLifecycleAction.INSTANCE, TransportGetLifecycleAction.class),
new ActionHandler<>(DeleteLifecycleAction.INSTANCE, TransportDeleteLifecycleAction.class),
new ActionHandler<>(ExplainLifecycleAction.INSTANCE, TransportExplainLifecycleAction.class),
- new ActionHandler<>(RemoveIndexLifecyclePolicyAction.INSTANCE, TransportRemoveIndexLifecyclePolicyAction.class),
new ActionHandler<>(MoveToStepAction.INSTANCE, TransportMoveToStepAction.class),
new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class),
new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class),
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java
index b1f18c674d15d..34646019972ab 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunner.java
@@ -476,46 +476,6 @@ private void setStepInfo(Index index, String policy, StepKey currentStepKey, ToX
clusterService.submitStateUpdateTask("ilm-set-step-info", new SetStepInfoUpdateTask(index, policy, currentStepKey, stepInfo));
}
- public static ClusterState removePolicyForIndexes(final Index[] indices, ClusterState currentState, List failedIndexes) {
- MetaData.Builder newMetadata = MetaData.builder(currentState.getMetaData());
- boolean clusterStateChanged = false;
- for (Index index : indices) {
- IndexMetaData indexMetadata = currentState.getMetaData().index(index);
- if (indexMetadata == null) {
- // Index doesn't exist so fail it
- failedIndexes.add(index.getName());
- } else {
- IndexMetaData.Builder newIdxMetadata = IndexLifecycleRunner.removePolicyForIndex(indexMetadata);
- if (newIdxMetadata != null) {
- newMetadata.put(newIdxMetadata);
- clusterStateChanged = true;
- }
- }
- }
- if (clusterStateChanged) {
- ClusterState.Builder newClusterState = ClusterState.builder(currentState);
- newClusterState.metaData(newMetadata);
- return newClusterState.build();
- } else {
- return currentState;
- }
- }
-
- private static IndexMetaData.Builder removePolicyForIndex(IndexMetaData indexMetadata) {
- Settings idxSettings = indexMetadata.getSettings();
- Settings.Builder newSettings = Settings.builder().put(idxSettings);
- boolean notChanged = true;
-
- notChanged &= Strings.isNullOrEmpty(newSettings.remove(LifecycleSettings.LIFECYCLE_NAME_SETTING.getKey()));
- notChanged &= Strings.isNullOrEmpty(newSettings.remove(LifecycleSettings.LIFECYCLE_SKIP_SETTING.getKey()));
- notChanged &= Strings.isNullOrEmpty(newSettings.remove(RolloverAction.LIFECYCLE_ROLLOVER_ALIAS_SETTING.getKey()));
- long newSettingsVersion = notChanged ? indexMetadata.getSettingsVersion() : 1 + indexMetadata.getSettingsVersion();
-
- IndexMetaData.Builder builder = IndexMetaData.builder(indexMetadata);
- builder.removeCustom(ILM_CUSTOM_METADATA_KEY);
- return builder.settings(newSettings).settingsVersion(newSettingsVersion);
- }
-
private void markPolicyDoesNotExist(String policyName, Index index, LifecycleExecutionState executionState) {
logger.debug("policy [{}] for index [{}] does not exist, recording this in step_info for this index",
policyName, index.getName());
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRemoveIndexLifecyclePolicyAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRemoveIndexLifecyclePolicyAction.java
deleted file mode 100644
index afa328ab8d8fe..0000000000000
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRemoveIndexLifecyclePolicyAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-package org.elasticsearch.xpack.indexlifecycle.action;
-
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.rest.BaseRestHandler;
-import org.elasticsearch.rest.RestController;
-import org.elasticsearch.rest.RestRequest;
-import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction;
-
-import java.io.IOException;
-
-public class RestRemoveIndexLifecyclePolicyAction extends BaseRestHandler {
-
- public RestRemoveIndexLifecyclePolicyAction(Settings settings, RestController controller) {
- super(settings);
- controller.registerHandler(RestRequest.Method.DELETE, "/{index}/_ilm", this);
- }
-
- @Override
- public String getName() {
- return "ilm_remove_policy_for_index_action";
- }
-
- @Override
- protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
- String[] indexes = Strings.splitStringByCommaToArray(restRequest.param("index"));
- RemoveIndexLifecyclePolicyAction.Request changePolicyRequest = new RemoveIndexLifecyclePolicyAction.Request(indexes);
- changePolicyRequest.masterNodeTimeout(restRequest.paramAsTime("master_timeout", changePolicyRequest.masterNodeTimeout()));
- changePolicyRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, changePolicyRequest.indicesOptions()));
-
- return channel ->
- client.execute(RemoveIndexLifecyclePolicyAction.INSTANCE, changePolicyRequest, new RestToXContentListener<>(channel));
- }
-}
\ No newline at end of file
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRemoveIndexLifecyclePolicyAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRemoveIndexLifecyclePolicyAction.java
deleted file mode 100644
index 149921a29a3d1..0000000000000
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRemoveIndexLifecyclePolicyAction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-package org.elasticsearch.xpack.indexlifecycle.action;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.master.TransportMasterNodeAction;
-import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
-import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.block.ClusterBlockException;
-import org.elasticsearch.cluster.block.ClusterBlockLevel;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
-import org.elasticsearch.cluster.service.ClusterService;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction.Request;
-import org.elasticsearch.xpack.core.indexlifecycle.action.RemoveIndexLifecyclePolicyAction.Response;
-import org.elasticsearch.xpack.indexlifecycle.IndexLifecycleRunner;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class TransportRemoveIndexLifecyclePolicyAction extends TransportMasterNodeAction {
-
- @Inject
- public TransportRemoveIndexLifecyclePolicyAction(Settings settings, TransportService transportService, ClusterService clusterService,
- ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
- super(settings, RemoveIndexLifecyclePolicyAction.NAME, transportService, clusterService, threadPool, actionFilters,
- indexNameExpressionResolver, Request::new);
- }
-
- @Override
- protected String executor() {
- return ThreadPool.Names.SAME;
- }
-
- @Override
- protected Response newResponse() {
- return new Response();
- }
-
- @Override
- protected ClusterBlockException checkBlock(Request request, ClusterState state) {
- return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
- }
-
- @Override
- protected void masterOperation(Request request, ClusterState state, ActionListener listener) throws Exception {
- final Index[] indices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), request.indices());
- clusterService.submitStateUpdateTask("remove-lifecycle-for-index",
- new AckedClusterStateUpdateTask(request, listener) {
-
- private final List failedIndexes = new ArrayList<>();
-
- @Override
- public ClusterState execute(ClusterState currentState) throws Exception {
- return IndexLifecycleRunner.removePolicyForIndexes(indices, currentState, failedIndexes);
- }
-
- @Override
- public void onFailure(String source, Exception e) {
- listener.onFailure(e);
- }
-
- @Override
- protected Response newResponse(boolean acknowledged) {
- return new Response(failedIndexes);
- }
- });
- }
-
-}
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
index 0be05bfda3b20..5f69a68bcd74b 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
@@ -1015,97 +1015,6 @@ private static LifecyclePolicy createPolicy(String policyName, StepKey safeStep,
return newTestLifecyclePolicy(policyName, phases);
}
- public void testRemovePolicyForIndex() {
- String indexName = randomAlphaOfLength(10);
- String oldPolicyName = "old_policy";
- StepKey currentStep = new StepKey(randomAlphaOfLength(10), MockAction.NAME, randomAlphaOfLength(10));
- LifecyclePolicy oldPolicy = createPolicy(oldPolicyName, currentStep, null);
- Settings.Builder indexSettingsBuilder = Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, oldPolicyName)
- .put(LifecycleSettings.LIFECYCLE_SKIP, true);
- LifecycleExecutionState.Builder lifecycleState = LifecycleExecutionState.builder();
- lifecycleState.setPhase(currentStep.getPhase());
- lifecycleState.setAction(currentStep.getAction());
- lifecycleState.setStep(currentStep.getName());
- List policyMetadatas = new ArrayList<>();
- policyMetadatas.add(new LifecyclePolicyMetadata(oldPolicy, Collections.emptyMap(),
- randomNonNegativeLong(), randomNonNegativeLong()));
- ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
- Index index = clusterState.metaData().index(indexName).getIndex();
- Index[] indices = new Index[] { index };
- List failedIndexes = new ArrayList<>();
-
- ClusterState newClusterState = IndexLifecycleRunner.removePolicyForIndexes(indices, clusterState, failedIndexes);
-
- assertTrue(failedIndexes.isEmpty());
- assertIndexNotManagedByILM(newClusterState, index);
- }
-
- public void testRemovePolicyForIndexNoCurrentPolicy() {
- String indexName = randomAlphaOfLength(10);
- Settings.Builder indexSettingsBuilder = Settings.builder();
- ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, LifecycleExecutionState.builder().build(),
- Collections.emptyList());
- Index index = clusterState.metaData().index(indexName).getIndex();
- Index[] indices = new Index[] { index };
- List failedIndexes = new ArrayList<>();
-
- ClusterState newClusterState = IndexLifecycleRunner.removePolicyForIndexes(indices, clusterState, failedIndexes);
-
- assertTrue(failedIndexes.isEmpty());
- assertIndexNotManagedByILM(newClusterState, index);
- }
-
- public void testRemovePolicyForIndexIndexDoesntExist() {
- String indexName = randomAlphaOfLength(10);
- String oldPolicyName = "old_policy";
- LifecyclePolicy oldPolicy = newTestLifecyclePolicy(oldPolicyName, Collections.emptyMap());
- StepKey currentStep = AbstractStepTestCase.randomStepKey();
- Settings.Builder indexSettingsBuilder = Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, oldPolicyName)
- .put(LifecycleSettings.LIFECYCLE_SKIP, true);
- LifecycleExecutionState.Builder lifecycleState = LifecycleExecutionState.builder();
- lifecycleState.setPhase(currentStep.getPhase());
- lifecycleState.setAction(currentStep.getAction());
- lifecycleState.setStep(currentStep.getName());
- List policyMetadatas = new ArrayList<>();
- policyMetadatas.add(new LifecyclePolicyMetadata(oldPolicy, Collections.emptyMap(),
- randomNonNegativeLong(), randomNonNegativeLong()));
- ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
- Index index = new Index("doesnt_exist", "im_not_here");
- Index[] indices = new Index[] { index };
- List failedIndexes = new ArrayList<>();
-
- ClusterState newClusterState = IndexLifecycleRunner.removePolicyForIndexes(indices, clusterState, failedIndexes);
-
- assertEquals(1, failedIndexes.size());
- assertEquals("doesnt_exist", failedIndexes.get(0));
- assertSame(clusterState, newClusterState);
- }
-
- public void testRemovePolicyForIndexIndexInUnsafe() {
- String indexName = randomAlphaOfLength(10);
- String oldPolicyName = "old_policy";
- StepKey currentStep = new StepKey(randomAlphaOfLength(10), MockAction.NAME, randomAlphaOfLength(10));
- LifecyclePolicy oldPolicy = createPolicy(oldPolicyName, null, currentStep);
- Settings.Builder indexSettingsBuilder = Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, oldPolicyName)
- .put(LifecycleSettings.LIFECYCLE_SKIP, true);
- LifecycleExecutionState.Builder lifecycleState = LifecycleExecutionState.builder();
- lifecycleState.setPhase(currentStep.getPhase());
- lifecycleState.setAction(currentStep.getAction());
- lifecycleState.setStep(currentStep.getName());
- List policyMetadatas = new ArrayList<>();
- policyMetadatas.add(new LifecyclePolicyMetadata(oldPolicy, Collections.emptyMap(),
- randomNonNegativeLong(), randomNonNegativeLong()));
- ClusterState clusterState = buildClusterState(indexName, indexSettingsBuilder, lifecycleState.build(), policyMetadatas);
- Index index = clusterState.metaData().index(indexName).getIndex();
- Index[] indices = new Index[] { index };
- List failedIndexes = new ArrayList<>();
-
- ClusterState newClusterState = IndexLifecycleRunner.removePolicyForIndexes(indices, clusterState, failedIndexes);
-
- assertTrue(failedIndexes.isEmpty());
- assertIndexNotManagedByILM(newClusterState, index);
- }
-
public void testIsReadyToTransition() {
String policyName = "async_action_policy";
StepKey stepKey = new StepKey("phase", MockAction.NAME, MockAction.NAME);
diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/10_basic.yml
index 81af39839ee11..695b92db77b3d 100644
--- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/10_basic.yml
+++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/10_basic.yml
@@ -217,8 +217,10 @@ setup:
- match: { error.root_cause.0.reason: "Cannot delete policy [my_timeseries_lifecycle]. It is being used by at least one index [my_timeseries_index]" }
- do:
- ilm.remove_policy:
+ indices.put_settings:
index: my_timeseries_index
+ body:
+ lifecycle.name: ""
- do:
acknowledge: true
diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/60_remove_policy_for_index.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/60_remove_policy_for_index.yml
deleted file mode 100644
index 4950b38200c94..0000000000000
--- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ilm/60_remove_policy_for_index.yml
+++ /dev/null
@@ -1,217 +0,0 @@
----
-setup:
- - do:
- cluster.health:
- wait_for_status: yellow
- - do:
- acknowlege: true
- ilm.put_lifecycle:
- policy: "my_moveable_timeseries_lifecycle"
- body: |
- {
- "policy": {
- "phases": {
- "warm": {
- "minimum_age": "1000s",
- "actions": {
- "forcemerge": {
- "max_num_segments": 10000
- }
- }
- },
- "hot": {
- "minimum_age": "1000s",
- "actions": { }
- }
- }
- }
- }
-
- - do:
- acknowledge: true
- ilm.get_lifecycle:
- policy: "my_moveable_timeseries_lifecycle"
-
- - do:
- acknowlege: true
- ilm.put_lifecycle:
- policy: "my_alternative_timeseries_lifecycle"
- body: |
- {
- "policy": {
- "phases": {
- "warm": {
- "minimum_age": "1000s",
- "actions": {
- "forcemerge": {
- "max_num_segments": 10000
- }
- }
- },
- "hot": {
- "minimum_age": "1000s",
- "actions": { }
- }
- }
- }
- }
-
- - do:
- acknowledge: true
- ilm.get_lifecycle:
- policy: "my_alternative_timeseries_lifecycle"
-
- - do:
- indices.create:
- index: my_index
- body:
- settings:
- index.lifecycle.name: "my_moveable_timeseries_lifecycle"
-
- - do:
- indices.create:
- index: my_index2
- body:
- settings:
- index.lifecycle.name: "my_moveable_timeseries_lifecycle"
-
- - do:
- indices.create:
- index: another_index
- body:
- settings:
- index.lifecycle.name: "my_moveable_timeseries_lifecycle"
-
- - do:
- indices.create:
- index: unmanaged_index
- body:
- settings: {}
-
- - do:
- indices.create:
- index: my_index_no_policy
-
----
-teardown:
-
- - do:
- acknowledge: true
- indices.delete:
- index: my_index
- - do:
- acknowledge: true
- indices.delete:
- index: my_index2
- - do:
- acknowledge: true
- indices.delete:
- index: another_index
- - do:
- acknowledge: true
- indices.delete:
- index: unmanaged_index
-
- - do:
- acknowledge: true
- indices.delete:
- index: my_index_no_policy
-
- - do:
- acknowledge: true
- ilm.delete_lifecycle:
- policy: "my_moveable_timeseries_lifecycle"
-
- - do:
- catch: missing
- ilm.get_lifecycle:
- policy: "my_moveable_timeseries_lifecycle"
-
- - do:
- acknowledge: true
- ilm.delete_lifecycle:
- policy: "my_alternative_timeseries_lifecycle"
-
- - do:
- catch: missing
- ilm.get_lifecycle:
- policy: "my_alternative_timeseries_lifecycle"
-
----
-"Test Remove Policy Single Index":
-
- - do:
- indices.get_settings:
- index: "another_index"
-
- - match: { another_index.settings.index.lifecycle.name: my_moveable_timeseries_lifecycle }
-
- - do:
- acknowledge: true
- ilm.remove_policy:
- index: "another_index"
-
- - is_false: has_failures
- - length: { failed_indexes: 0 }
-
- - do:
- indices.get_settings:
- index: "another_index"
-
- - is_false: another_index.settings.index.lifecycle
-
----
-"Test Remove Policy Index Pattern":
-
- - do:
- indices.get_settings:
- index: "my_*"
-
- - match: { my_index.settings.index.lifecycle.name: my_moveable_timeseries_lifecycle }
- - match: { my_index2.settings.index.lifecycle.name: my_moveable_timeseries_lifecycle }
-
- - do:
- acknowledge: true
- ilm.remove_policy:
- index: "my_*"
-
- - is_false: has_failures
- - length: { failed_indexes: 0 }
-
- - do:
- indices.get_settings:
- index: "my_*"
-
- - is_false: my_index.settings.index.lifecycle
- - is_false: my_index2.settings.index.lifecycle
-
----
-"Test Remove Policy Unmanaged Index":
-
- - do:
- indices.get_settings:
- index: "unmanaged_index"
-
- - is_false: unmanaged_index.settings.index.lifecycle.name
-
- - do:
- acknowledge: true
- ilm.remove_policy:
- index: "unmanaged_index"
-
- - is_false: has_failures
- - length: { failed_indexes: 0 }
-
- - do:
- indices.get_settings:
- index: "unmanaged_index"
-
- - is_false: unmanaged_index.settings.index.lifecycle
-
----
-"Test Remove Policy Index Does Not Exist":
-
- - do:
- catch: missing
- ilm.remove_policy:
- index: "doesnt_exist"