Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for POST requests to SLM Execute API #47061

Merged
merged 2 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static Request deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyReques
}

static Request executeSnapshotLifecyclePolicy(ExecuteSnapshotLifecyclePolicyRequest executeSnapshotLifecyclePolicyRequest) {
Request request = new Request(HttpPut.METHOD_NAME,
Request request = new Request(HttpPost.METHOD_NAME,
new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_slm/policy")
.addPathPartAsIs(executeSnapshotLifecyclePolicyRequest.getPolicyId())
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/ilm/apis/slm-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ To take an immediate snapshot using a policy, use the following

[source,console]
--------------------------------------------------
PUT /_slm/policy/daily-snapshots/_execute
POST /_slm/policy/daily-snapshots/_execute
--------------------------------------------------
// TEST[skip:we can't easily handle snapshots from docs tests]

Expand Down Expand Up @@ -279,7 +279,7 @@ Another snapshot can immediately be executed to ensure the new policy works:

[source,console]
--------------------------------------------------
PUT /_slm/policy/daily-snapshots/_execute
POST /_slm/policy/daily-snapshots/_execute
--------------------------------------------------
// TEST[skip:we can't handle snapshots in docs tests]

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ilm/getting-started-slm.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ as using the configuration from our policy right now instead of waiting for

[source,console]
--------------------------------------------------
PUT /_slm/policy/nightly-snapshots/_execute
POST /_slm/policy/nightly-snapshots/_execute
--------------------------------------------------
// TEST[skip:we can't easily handle snapshots from docs tests]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testPolicyManualExecution() throws Exception {
createSnapshotPolicy(policyName, "snap", "1 2 3 4 5 ?", repoId, indexName, true);

ResponseException badResp = expectThrows(ResponseException.class,
() -> client().performRequest(new Request("PUT", "/_slm/policy/" + policyName + "-bad/_execute")));
() -> client().performRequest(new Request("POST", "/_slm/policy/" + policyName + "-bad/_execute")));
assertThat(EntityUtils.toString(badResp.getResponse().getEntity()),
containsString("no such snapshot lifecycle policy [" + policyName + "-bad]"));

Expand Down Expand Up @@ -338,7 +338,7 @@ public void testBasicTimeBasedRetenion() throws Exception {
*/
private String executePolicy(String policyId) {
try {
Response executeRepsonse = client().performRequest(new Request("PUT", "/_slm/policy/" + policyId + "/_execute"));
Response executeRepsonse = client().performRequest(new Request("POST", "/_slm/policy/" + policyId + "/_execute"));
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, EntityUtils.toByteArray(executeRepsonse.getEntity()))) {
return parser.mapStrings().get("snapshot_name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class RestExecuteSnapshotLifecycleAction extends BaseRestHandler {

public RestExecuteSnapshotLifecycleAction(RestController controller) {
controller.registerHandler(RestRequest.Method.PUT, "/_slm/policy/{name}/_execute", this);
controller.registerHandler(RestRequest.Method.POST, "/_slm/policy/{name}/_execute", this);
}

@Override
Expand Down