Hi,
Can someone tell me how to write this lifecycle policy test with the new Java API client? It is completely unclear to me. By the way, is there more extensive documentation on how to use the Java API client?
The code below uses the high level rest client.
public void testLifecyclePolicy() throws Exception {
Map<String, Phase> phases = new HashMap<>();
Map<String, LifecycleAction> hotActions = new HashMap<>();
hotActions.put(RolloverAction.NAME, new RolloverAction(null, null, null, 1L));
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(10, TimeUnit.SECONDS), deleteActions));
AcknowledgedResponse createLifecyclePolicyResponse = hlRestClient.indexLifecycle().putLifecyclePolicy(
new PutLifecyclePolicyRequest(new LifecyclePolicy("test-policy", phases)),
RequestOptions.DEFAULT);
Preconditions.checkState(createLifecyclePolicyResponse.isAcknowledged(), "Failed to create lifecycle test-policy");
}
Thanks!