rename CRUD api REST path prefix _ilm to _ilm/policy (#35056)
This PR renames the CRUD APIS for ILM GET _ilm/<policy>, _ilm -> _ilm/policy/<policy>, _ilm/policy PUT _ilm/<policy> -> _ilm/policy/<policy> DELETE _ilm/<policy> -> _ilm/policy/<policy> closes #34929.
This commit is contained in:
parent
f5323cd86e
commit
5141084048
|
@ -41,7 +41,7 @@ final class IndexLifecycleRequestConverters {
|
|||
private IndexLifecycleRequestConverters() {}
|
||||
|
||||
static Request getLifecyclePolicy(GetLifecyclePolicyRequest getLifecyclePolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm/policy")
|
||||
.addCommaSeparatedPathParts(getLifecyclePolicyRequest.getPolicyNames()).build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params(request);
|
||||
|
@ -52,7 +52,7 @@ final class IndexLifecycleRequestConverters {
|
|||
|
||||
static Request putLifecyclePolicy(PutLifecyclePolicyRequest putLifecycleRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("_ilm/policy")
|
||||
.addPathPartAsIs(putLifecycleRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -66,7 +66,7 @@ final class IndexLifecycleRequestConverters {
|
|||
static Request deleteLifecyclePolicy(DeleteLifecyclePolicyRequest deleteLifecyclePolicyRequest) {
|
||||
Request request = new Request(HttpDelete.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("_ilm/policy")
|
||||
.addPathPartAsIs(deleteLifecyclePolicyRequest.getLifecyclePolicy())
|
||||
.build());
|
||||
RequestConverters.Params params = new RequestConverters.Params(request);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class IndexLifecycleRequestConvertersTests extends ESTestCase {
|
|||
Request request = IndexLifecycleRequestConverters.getLifecyclePolicy(req);
|
||||
assertEquals(request.getMethod(), HttpGet.METHOD_NAME);
|
||||
String policiesStr = Strings.arrayToCommaDelimitedString(policies);
|
||||
assertEquals(request.getEndpoint(), "/_ilm" + (policiesStr.isEmpty() ? "" : ("/" + policiesStr)));
|
||||
assertEquals(request.getEndpoint(), "/_ilm/policy" + (policiesStr.isEmpty() ? "" : ("/" + policiesStr)));
|
||||
assertEquals(request.getParameters(), expectedParams);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class IndexLifecycleRequestConvertersTests extends ESTestCase {
|
|||
|
||||
Request request = IndexLifecycleRequestConverters.putLifecyclePolicy(req);
|
||||
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
||||
assertEquals("/_ilm/" + name, request.getEndpoint());
|
||||
assertEquals("/_ilm/policy/" + name, request.getEndpoint());
|
||||
assertEquals(expectedParams, request.getParameters());
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class IndexLifecycleRequestConvertersTests extends ESTestCase {
|
|||
|
||||
Request request = IndexLifecycleRequestConverters.deleteLifecyclePolicy(req);
|
||||
assertEquals(request.getMethod(), HttpDelete.METHOD_NAME);
|
||||
assertEquals(request.getEndpoint(), "/_ilm/" + lifecycleName);
|
||||
assertEquals(request.getEndpoint(), "/_ilm/policy/" + lifecycleName);
|
||||
assertEquals(request.getParameters(), expectedParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Deletes an existing lifecycle policy
|
|||
|
||||
==== Request
|
||||
|
||||
`DELETE _ilm/<policy>`
|
||||
`DELETE _ilm/policy/<policy>`
|
||||
|
||||
==== Description
|
||||
|
||||
|
@ -43,7 +43,7 @@ The following example deletes an existing policy named `my_policy`:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -72,7 +72,7 @@ PUT _ilm/my_policy
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
DELETE _ilm/my_policy
|
||||
DELETE _ilm/policy/my_policy
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
|
|
@ -47,7 +47,7 @@ The following example retrieves the lifecycle state for the index `my_index`:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -10,8 +10,8 @@ Retrieves an existing policy
|
|||
|
||||
==== Request
|
||||
|
||||
`GET _ilm`
|
||||
`GET _ilm/<policy>`
|
||||
`GET _ilm/policy`
|
||||
`GET _ilm/policy/<policy>`
|
||||
|
||||
==== Description
|
||||
|
||||
|
@ -46,7 +46,7 @@ The following example retrieves the policy named `my_policy`:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -75,7 +75,7 @@ PUT _ilm/my_policy
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
GET _ilm
|
||||
GET _ilm/policy
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
|
|
@ -50,7 +50,7 @@ forcemerge step:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -10,7 +10,7 @@ Creates or updates an ILM Policy
|
|||
|
||||
==== Request
|
||||
|
||||
`PUT _ilm/<policy>`
|
||||
`PUT _ilm/policy/<policy>`
|
||||
|
||||
==== Description
|
||||
|
||||
|
@ -46,7 +46,7 @@ The following example creates a new policy named `my_policy`:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -44,7 +44,7 @@ The following example removes a policy `my_policy` from an index `my_index`.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -40,7 +40,7 @@ The following example starts the ILM plugin.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -42,7 +42,7 @@ The following example stops the ILM plugin.
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -10,7 +10,7 @@ our indexes.
|
|||
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -17,7 +17,7 @@ to see the current state of ILM.
|
|||
////
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -21,7 +21,7 @@ To show this, let's create a policy `my_policy`.
|
|||
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -53,7 +53,7 @@ Updating the Delete phase's minimum age can be done in an update request.
|
|||
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -81,7 +81,7 @@ PUT _ilm/my_policy
|
|||
//////////
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
GET _ilm
|
||||
GET _ilm/policy
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
@ -136,7 +136,7 @@ Let's say we have an index `my_index` managed by the below `my_executing_policy`
|
|||
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_executing_policy
|
||||
PUT _ilm/policy/my_executing_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -226,7 +226,7 @@ Updating `my_executing_policy` to have no rollover action and, instead, go direc
|
|||
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_executing_policy
|
||||
PUT _ilm/policy/my_executing_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -371,7 +371,7 @@ it will move on to the next phase in `my_other_policy`. So if it was on the
|
|||
////
|
||||
[source,js]
|
||||
------------------------
|
||||
PUT _ilm/my_policy
|
||||
PUT _ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
@ -392,7 +392,7 @@ PUT _ilm/my_policy
|
|||
}
|
||||
}
|
||||
|
||||
PUT _ilm/my_other_policy
|
||||
PUT _ilm/policy/my_other_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -48,7 +48,7 @@ this example, that means the index will be deleted 30 days after rollover, not
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT /_ilm/my_policy
|
||||
PUT /_ilm/policy/my_policy
|
||||
{
|
||||
"policy": {
|
||||
"phases": {
|
||||
|
|
|
@ -526,10 +526,10 @@ public abstract class ESRestTestCase extends ESTestCase {
|
|||
Map<String, Object> policies;
|
||||
|
||||
try {
|
||||
Response response = adminClient().performRequest(new Request("GET", "/_ilm"));
|
||||
Response response = adminClient().performRequest(new Request("GET", "/_ilm/policy"));
|
||||
policies = entityAsMap(response);
|
||||
} catch (ResponseException e) {
|
||||
if (RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) {
|
||||
if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode()) {
|
||||
// If bad request returned, ILM is not enabled.
|
||||
return;
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ public abstract class ESRestTestCase extends ESTestCase {
|
|||
}
|
||||
|
||||
for (String policyName : policies.keySet()) {
|
||||
adminClient().performRequest(new Request("DELETE", "/_ilm/" + policyName));
|
||||
adminClient().performRequest(new Request("DELETE", "/_ilm/policy/" + policyName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
lifecyclePolicy.toXContent(builder, null);
|
||||
final StringEntity entity = new StringEntity(
|
||||
"{ \"policy\":" + Strings.toString(builder) + "}", ContentType.APPLICATION_JSON);
|
||||
Request request = new Request("PUT", "_ilm/" + policy);
|
||||
Request request = new Request("PUT", "_ilm/policy/" + policy);
|
||||
request.setEntity(entity);
|
||||
assertOK(client().performRequest(request));
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
lifecyclePolicy.toXContent(builder, null);
|
||||
final StringEntity entity = new StringEntity(
|
||||
"{ \"policy\":" + Strings.toString(builder) + "}", ContentType.APPLICATION_JSON);
|
||||
Request request = new Request("PUT", "_ilm/" + policy);
|
||||
Request request = new Request("PUT", "_ilm/policy/" + policy);
|
||||
request.setEntity(entity);
|
||||
client().performRequest(request);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class PermissionsIT extends ESRestTestCase {
|
|||
lifecyclePolicy.toXContent(builder, null);
|
||||
final StringEntity entity = new StringEntity(
|
||||
"{ \"policy\":" + Strings.toString(builder) + "}", ContentType.APPLICATION_JSON);
|
||||
Request request = new Request("PUT", "_ilm/" + policy);
|
||||
Request request = new Request("PUT", "_ilm/policy/" + policy);
|
||||
request.setEntity(entity);
|
||||
client().performRequest(request);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class RestDeleteLifecycleAction extends BaseRestHandler {
|
|||
|
||||
public RestDeleteLifecycleAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, "/_ilm/{name}", this);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, "/_ilm/policy/{name}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,4 +37,4 @@ public class RestDeleteLifecycleAction extends BaseRestHandler {
|
|||
|
||||
return channel -> client.execute(DeleteLifecycleAction.INSTANCE, deleteLifecycleRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ public class RestGetLifecycleAction extends BaseRestHandler {
|
|||
|
||||
public RestGetLifecycleAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_ilm", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_ilm/{name}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_ilm/policy", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, "/_ilm/policy/{name}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,4 +39,4 @@ public class RestGetLifecycleAction extends BaseRestHandler {
|
|||
|
||||
return channel -> client.execute(GetLifecycleAction.INSTANCE, getLifecycleRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class RestPutLifecycleAction extends BaseRestHandler {
|
|||
|
||||
public RestPutLifecycleAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.PUT, "/_ilm/{name}", this);
|
||||
controller.registerHandler(RestRequest.Method.PUT, "/_ilm/policy/{name}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,4 +39,4 @@ public class RestPutLifecycleAction extends BaseRestHandler {
|
|||
|
||||
return channel -> client.execute(PutLifecycleAction.INSTANCE, putLifecycleRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ChangePolicyforIndexIT extends ESRestTestCase {
|
|||
* existing definition when the policy is changed for that index, and that
|
||||
* after completing the current phase the new policy will be used for
|
||||
* subsequent phases.
|
||||
*
|
||||
*
|
||||
* The test creates two policies, one with a hot phase requiring 1 document
|
||||
* to rollover and a warm phase with an impossible allocation action. The
|
||||
* second policy has a rollover action requiring 1000 document and a warm
|
||||
|
@ -69,13 +69,13 @@ public class ChangePolicyforIndexIT extends ESRestTestCase {
|
|||
XContentBuilder builder1 = jsonBuilder();
|
||||
lifecyclePolicy1.toXContent(builder1, null);
|
||||
final StringEntity entity1 = new StringEntity("{ \"policy\":" + Strings.toString(builder1) + "}", ContentType.APPLICATION_JSON);
|
||||
Request request1 = new Request("PUT", "_ilm/" + "policy_1");
|
||||
Request request1 = new Request("PUT", "_ilm/policy/" + "policy_1");
|
||||
request1.setEntity(entity1);
|
||||
assertOK(client().performRequest(request1));
|
||||
XContentBuilder builder2 = jsonBuilder();
|
||||
lifecyclePolicy2.toXContent(builder2, null);
|
||||
final StringEntity entity2 = new StringEntity("{ \"policy\":" + Strings.toString(builder2) + "}", ContentType.APPLICATION_JSON);
|
||||
Request request2 = new Request("PUT", "_ilm/" + "policy_2");
|
||||
Request request2 = new Request("PUT", "_ilm/policy/" + "policy_2");
|
||||
request2.setEntity(entity2);
|
||||
assertOK(client().performRequest(request2));
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "http://www.elastic.co/guide/en/index_lifecycle/current/index_lifecycle.html",
|
||||
"methods": [ "DELETE" ],
|
||||
"url": {
|
||||
"path": "/_ilm/{policy}",
|
||||
"paths": ["/_ilm/{policy}"],
|
||||
"path": "/_ilm/policy/{policy}",
|
||||
"paths": ["/_ilm/policy/{policy}"],
|
||||
"parts": {
|
||||
"policy": {
|
||||
"type" : "string",
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "http://www.elastic.co/guide/en/index_lifecycle/current/index_lifecycle.html",
|
||||
"methods": [ "GET" ],
|
||||
"url": {
|
||||
"path": "/_ilm/{policy}",
|
||||
"paths": ["/_ilm/{policy}", "/_ilm"],
|
||||
"path": "/_ilm/policy/{policy}",
|
||||
"paths": ["/_ilm/policy/{policy}", "/_ilm/policy"],
|
||||
"parts": {
|
||||
"policy": {
|
||||
"type" : "string",
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "http://www.elastic.co/guide/en/index_lifecycle/current/index_lifecycle.html",
|
||||
"methods": [ "PUT" ],
|
||||
"url": {
|
||||
"path": "/_ilm/{policy}",
|
||||
"paths": ["/_ilm/{policy}"],
|
||||
"path": "/_ilm/policy/{policy}",
|
||||
"paths": ["/_ilm/policy/{policy}"],
|
||||
"parts": {
|
||||
"policy": {
|
||||
"type" : "string",
|
||||
|
|
Loading…
Reference in New Issue