Skip to content

Commit 021ef2d

Browse files
committed
[ILM] change remove-policy-from-index http method from DELETE to POST (#35268)
The remove-ilm-from-index API was using the DELETE http method to signify that something is being removed. Although, metadata about ILM for the index is being deleted, no entity/resource is being deleted during this operation. POST is more in line with what this API is actually doing, it is modifying the metadata for an index. As part of this change, `remove` is also appended to the path to be more explicit about its actions.
1 parent b6efa2c commit 021ef2d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleRequestConverters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ static Request deleteLifecyclePolicy(DeleteLifecyclePolicyRequest deleteLifecycl
7878
static Request removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest removePolicyRequest) {
7979
String[] indices = removePolicyRequest.indices() == null ?
8080
Strings.EMPTY_ARRAY : removePolicyRequest.indices().toArray(new String[] {});
81-
Request request = new Request(HttpDelete.METHOD_NAME,
81+
Request request = new Request(HttpPost.METHOD_NAME,
8282
new RequestConverters.EndpointBuilder()
8383
.addCommaSeparatedPathParts(indices)
84-
.addPathPartAsIs("_ilm")
84+
.addPathPartAsIs("_ilm", "remove")
8585
.build());
8686
RequestConverters.Params params = new RequestConverters.Params(request);
8787
params.withIndicesOptions(removePolicyRequest.indicesOptions());

client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleRequestConvertersTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public void testRemoveIndexLifecyclePolicy() {
9999
setRandomMasterTimeout(req::setMasterTimeout, TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT, expectedParams);
100100

101101
Request request = IndexLifecycleRequestConverters.removeIndexLifecyclePolicy(req);
102-
assertThat(request.getMethod(), equalTo(HttpDelete.METHOD_NAME));
102+
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
103103
String idxString = Strings.arrayToCommaDelimitedString(indices);
104-
assertThat(request.getEndpoint(), equalTo("/" + (idxString.isEmpty() ? "" : (idxString + "/")) + "_ilm"));
104+
assertThat(request.getEndpoint(), equalTo("/" + (idxString.isEmpty() ? "" : (idxString + "/")) + "_ilm/remove"));
105105
assertThat(request.getParameters(), equalTo(expectedParams));
106106
}
107107

docs/reference/ilm/apis/remove-policy.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Unassigns a policy from a specified index pattern
1010

1111
==== Request
1212

13-
`DELETE <index>/_ilm`
13+
`POST <index>/_ilm/remove`
1414

1515
==== Description
1616

@@ -80,7 +80,7 @@ PUT my_index
8080

8181
[source,js]
8282
--------------------------------------------------
83-
DELETE my_index/_ilm
83+
POST my_index/_ilm/remove
8484
--------------------------------------------------
8585
// CONSOLE
8686
// TEST[continued]

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRemoveIndexLifecyclePolicyAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class RestRemoveIndexLifecyclePolicyAction extends BaseRestHandler {
2222

2323
public RestRemoveIndexLifecyclePolicyAction(Settings settings, RestController controller) {
2424
super(settings);
25-
controller.registerHandler(RestRequest.Method.DELETE, "/{index}/_ilm", this);
25+
controller.registerHandler(RestRequest.Method.POST, "/{index}/_ilm/remove", this);
2626
}
2727

2828
@Override
@@ -40,4 +40,4 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient
4040
return channel ->
4141
client.execute(RemoveIndexLifecyclePolicyAction.INSTANCE, changePolicyRequest, new RestToXContentListener<>(channel));
4242
}
43-
}
43+
}

x-pack/plugin/src/test/resources/rest-api-spec/api/ilm.remove_policy.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"ilm.remove_policy": {
33
"documentation": "http://www.elastic.co/guide/en/index_lifecycle/current/index_lifecycle.html",
4-
"methods": [ "DELETE" ],
4+
"methods": [ "POST" ],
55
"url": {
6-
"path": "/{index}/_ilm",
7-
"paths": ["/{index}/_ilm", "/_ilm"],
6+
"path": "/{index}/_ilm/remove",
7+
"paths": ["/{index}/_ilm/remove", "/_ilm/remove"],
88
"parts": {
99
"index": {
1010
"type" : "string",

0 commit comments

Comments
 (0)