Add HLRC docs for Delete Lifecycle Policy (#35664)

Adds documenatation for the Delete Lifecycle Policy API to the HLRC
documentation.
This commit is contained in:
Gordon Brown 2018-11-20 11:32:41 -07:00 committed by GitHub
parent 89cf4a7397
commit 17780ce07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 0 deletions

View File

@ -137,6 +137,80 @@ public class ILMDocumentationIT extends ESRestHighLevelClientTestCase {
}
public void testDeletePolicy() throws IOException, InterruptedException {
RestHighLevelClient client = highLevelClient();
// Set up a policy so we have something to delete
PutLifecyclePolicyRequest putRequest;
{
Map<String, Phase> phases = new HashMap<>();
Map<String, LifecycleAction> hotActions = new HashMap<>();
hotActions.put(RolloverAction.NAME, new RolloverAction(
new ByteSizeValue(50, ByteSizeUnit.GB), null, null));
phases.put("hot", new Phase("hot", TimeValue.ZERO, hotActions));
Map<String, LifecycleAction> deleteActions =
Collections.singletonMap(DeleteAction.NAME,
new DeleteAction());
phases.put("delete",
new Phase("delete",
new TimeValue(90, TimeUnit.DAYS), deleteActions));
LifecyclePolicy myPolicy = new LifecyclePolicy("my_policy", phases);
putRequest = new PutLifecyclePolicyRequest(myPolicy);
AcknowledgedResponse putResponse = client.indexLifecycle().
putLifecyclePolicy(putRequest, RequestOptions.DEFAULT);
assertTrue(putResponse.isAcknowledged());
}
// tag::ilm-delete-lifecycle-policy-request
DeleteLifecyclePolicyRequest request =
new DeleteLifecyclePolicyRequest("my_policy"); // <1>
// end::ilm-delete-lifecycle-policy-request
// tag::ilm-delete-lifecycle-policy-execute
AcknowledgedResponse response = client.indexLifecycle()
.deleteLifecyclePolicy(request, RequestOptions.DEFAULT);
// end::ilm-delete-lifecycle-policy-execute
// tag::ilm-delete-lifecycle-policy-response
boolean acknowledged = response.isAcknowledged(); // <1>
// end::ilm-delete-lifecycle-policy-response
assertTrue(acknowledged);
// Put the policy again so we can delete it again
{
AcknowledgedResponse putResponse = client.indexLifecycle().
putLifecyclePolicy(putRequest, RequestOptions.DEFAULT);
assertTrue(putResponse.isAcknowledged());
}
// tag::ilm-delete-lifecycle-policy-execute-listener
ActionListener<AcknowledgedResponse> listener =
new ActionListener<AcknowledgedResponse>() {
@Override
public void onResponse(AcknowledgedResponse response) {
boolean acknowledged = response.isAcknowledged(); // <1>
}
@Override
public void onFailure(Exception e) {
// <2>
}
};
// end::ilm-delete-lifecycle-policy-execute-listener
// Replace the empty listener by a blocking listener in test
final CountDownLatch latch = new CountDownLatch(1);
listener = new LatchedActionListener<>(listener, latch);
// tag::ilm-delete-lifecycle-policy-execute-async
client.indexLifecycle().deleteLifecyclePolicyAsync(request,
RequestOptions.DEFAULT, listener); // <1>
// end::ilm-delete-lifecycle-policy-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}
public void testGetLifecyclePolicy() throws IOException, InterruptedException {
RestHighLevelClient client = highLevelClient();

View File

@ -0,0 +1,36 @@
--
:api: ilm-delete-lifecycle-policy
:request: DeleteLifecyclePolicyRequest
:response: AcknowledgedResponse
--
[id="{upid}-{api}"]
=== Delete Lifecycle Policy API
[id="{upid}-{api}-request"]
==== Request
The Delete Lifecycle Policy API allows you to delete an Index Lifecycle
Management Policy from the cluster.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> The policy named `my_policy` will be deleted.
[id="{upid}-{api}-response"]
==== Response
The returned +{response}+ indicates if the delete lifecycle policy request was received.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> Whether or not the delete lifecycle policy request was acknowledged.
include::../execution.asciidoc[]

View File

@ -457,6 +457,7 @@ The Java High Level REST Client supports the following Index Lifecycle
Management APIs:
* <<{upid}-ilm-put-lifecycle-policy>>
* <<{upid}-ilm-delete-lifecycle-policy>>
* <<{upid}-ilm-get-lifecycle-policy>>
* <<{upid}-ilm-start-ilm>>
* <<{upid}-ilm-stop-ilm>>
@ -465,6 +466,7 @@ Management APIs:
include::ilm/put_lifecycle_policy.asciidoc[]
include::ilm/delete_lifecycle_policy.asciidoc[]
include::ilm/get_lifecycle_policy.asciidoc[]
include::ilm/start_lifecycle_management.asciidoc[]
include::ilm/stop_lifecycle_management.asciidoc[]