Przeglądaj źródła

Remove IndexLifecycleClient from High Level Rest Client (#83476)

It was used in the SLM permissions tests to check permissions for policy and retention CRUD. This
commit replaces it with the LLRC equivalent.

Relates to #83423
Lee Hinman 3 lat temu
rodzic
commit
cf410fcd3c

+ 0 - 913
client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java

@@ -1,913 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.client;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.client.core.AcknowledgedResponse;
-import org.elasticsearch.client.ilm.DeleteLifecyclePolicyRequest;
-import org.elasticsearch.client.ilm.ExplainLifecycleRequest;
-import org.elasticsearch.client.ilm.ExplainLifecycleResponse;
-import org.elasticsearch.client.ilm.GetLifecyclePolicyRequest;
-import org.elasticsearch.client.ilm.GetLifecyclePolicyResponse;
-import org.elasticsearch.client.ilm.LifecycleManagementStatusRequest;
-import org.elasticsearch.client.ilm.LifecycleManagementStatusResponse;
-import org.elasticsearch.client.ilm.PutLifecyclePolicyRequest;
-import org.elasticsearch.client.ilm.RemoveIndexLifecyclePolicyRequest;
-import org.elasticsearch.client.ilm.RemoveIndexLifecyclePolicyResponse;
-import org.elasticsearch.client.ilm.RetryLifecyclePolicyRequest;
-import org.elasticsearch.client.ilm.StartILMRequest;
-import org.elasticsearch.client.ilm.StopILMRequest;
-import org.elasticsearch.client.slm.DeleteSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyResponse;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecycleRetentionRequest;
-import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyResponse;
-import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsRequest;
-import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsResponse;
-import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.SnapshotLifecycleManagementStatusRequest;
-import org.elasticsearch.client.slm.StartSLMRequest;
-import org.elasticsearch.client.slm.StopSLMRequest;
-
-import java.io.IOException;
-
-import static java.util.Collections.emptySet;
-
-/**
- * @deprecated The High Level Rest Client is deprecated in favor of the
- * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html">
- * Elasticsearch Java API Client</a>
- */
-@Deprecated(since = "7.16.0", forRemoval = true)
-@SuppressWarnings("removal")
-public class IndexLifecycleClient {
-    private final RestHighLevelClient restHighLevelClient;
-
-    IndexLifecycleClient(RestHighLevelClient restHighLevelClient) {
-        this.restHighLevelClient = restHighLevelClient;
-    }
-
-    /**
-     * Retrieve one or more lifecycle policy definition. See
-     * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-ilm-ilm-get-lifecycle-policy.html">
-     * the docs</a> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public GetLifecyclePolicyResponse getLifecyclePolicy(GetLifecyclePolicyRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getLifecyclePolicy,
-            options,
-            GetLifecyclePolicyResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously retrieve one or more lifecycle policy definition. See
-     * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-ilm-ilm-get-lifecycle-policy.html">
-     * the docs</a> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable getLifecyclePolicyAsync(
-        GetLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<GetLifecyclePolicyResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getLifecyclePolicy,
-            options,
-            GetLifecyclePolicyResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Create or modify a lifecycle definition. See <a href=
-     * "https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-ilm-ilm-put-lifecycle-policy.html">
-     * the docs</a> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse putLifecyclePolicy(PutLifecyclePolicyRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::putLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously create or modify a lifecycle definition. See <a href=
-     * "https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-ilm-ilm-put-lifecycle-policy.html">
-     * the docs</a> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable putLifecyclePolicyAsync(
-        PutLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::putLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Delete a lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-delete-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse deleteLifecyclePolicy(DeleteLifecyclePolicyRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::deleteLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously delete a lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-delete-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable deleteLifecyclePolicyAsync(
-        DeleteLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::deleteLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Remove the index lifecycle policy for an index
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-remove-lifecycle-policy-from-index.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public RemoveIndexLifecyclePolicyResponse removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::removeIndexLifecyclePolicy,
-            options,
-            RemoveIndexLifecyclePolicyResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously remove the index lifecycle policy for an index
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-remove-lifecycle-policy-from-index.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable removeIndexLifecyclePolicyAsync(
-        RemoveIndexLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<RemoveIndexLifecyclePolicyResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::removeIndexLifecyclePolicy,
-            options,
-            RemoveIndexLifecyclePolicyResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Start the Index Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-start-ilm.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse startILM(StartILMRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::startILM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously start the Index Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-start-ilm.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable startILMAsync(StartILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::startILM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Stop the Index Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-stop-ilm.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse stopILM(StopILMRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::stopILM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously stop the Index Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-stop-ilm.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::stopILM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Get the status of index lifecycle management
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-status.html
-     * </pre>
-     * for more.
-     *
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     */
-    public LifecycleManagementStatusResponse lifecycleManagementStatus(LifecycleManagementStatusRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::lifecycleManagementStatus,
-            options,
-            LifecycleManagementStatusResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously get the status of index lifecycle management
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-status.html
-     * </pre>
-     * for more.
-     * @param request  the request
-     * @param options  the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable lifecycleManagementStatusAsync(
-        LifecycleManagementStatusRequest request,
-        RequestOptions options,
-        ActionListener<LifecycleManagementStatusResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::lifecycleManagementStatus,
-            options,
-            LifecycleManagementStatusResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Explain the lifecycle state for an index
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-explain-lifecycle.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public ExplainLifecycleResponse explainLifecycle(ExplainLifecycleRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::explainLifecycle,
-            options,
-            ExplainLifecycleResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously explain the lifecycle state for an index
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-explain-lifecycle.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable explainLifecycleAsync(
-        ExplainLifecycleRequest request,
-        RequestOptions options,
-        ActionListener<ExplainLifecycleResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::explainLifecycle,
-            options,
-            ExplainLifecycleResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Retry lifecycle step for given indices
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-retry-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse retryLifecyclePolicy(RetryLifecyclePolicyRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::retryLifecycle,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously retry the lifecycle step for given indices
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-ilm-retry-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable retryLifecyclePolicyAsync(
-        RetryLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::retryLifecycle,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Retrieve one or more snapshot lifecycle policy definitions.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-get-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public GetSnapshotLifecyclePolicyResponse getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
-            options,
-            GetSnapshotLifecyclePolicyResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously retrieve one or more snapshot lifecycle policy definition.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-get-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable getSnapshotLifecyclePolicyAsync(
-        GetSnapshotLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<GetSnapshotLifecyclePolicyResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
-            options,
-            GetSnapshotLifecyclePolicyResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Create or modify a snapshot lifecycle definition.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-put-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously create or modify a snapshot lifecycle definition.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-put-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable putSnapshotLifecyclePolicyAsync(
-        PutSnapshotLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Delete a snapshot lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-delete-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously delete a snapshot lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-delete-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable deleteSnapshotLifecyclePolicyAsync(
-        DeleteSnapshotLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Execute a snapshot lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-execute-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public ExecuteSnapshotLifecyclePolicyResponse executeSnapshotLifecyclePolicy(
-        ExecuteSnapshotLifecyclePolicyRequest request,
-        RequestOptions options
-    ) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
-            options,
-            ExecuteSnapshotLifecyclePolicyResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously execute a snapshot lifecycle definition
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-execute-snapshot-lifecycle-policy.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable executeSnapshotLifecyclePolicyAsync(
-        ExecuteSnapshotLifecyclePolicyRequest request,
-        RequestOptions options,
-        ActionListener<ExecuteSnapshotLifecyclePolicyResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
-            options,
-            ExecuteSnapshotLifecyclePolicyResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Execute snapshot lifecycle retention
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-execute-snapshot-lifecycle-retention.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse executeSnapshotLifecycleRetention(ExecuteSnapshotLifecycleRetentionRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously execute snapshot lifecycle retention
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-execute-snapshot-lifecycle-retention.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable executeSnapshotLifecycleRetentionAsync(
-        ExecuteSnapshotLifecycleRetentionRequest request,
-        RequestOptions options,
-        ActionListener<AcknowledgedResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Retrieve snapshot lifecycle statistics.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-get-snapshot-lifecycle-stats.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public GetSnapshotLifecycleStatsResponse getSnapshotLifecycleStats(GetSnapshotLifecycleStatsRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
-            options,
-            GetSnapshotLifecycleStatsResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously retrieve snapshot lifecycle statistics.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-get-snapshot-lifecycle-stats.html
-     * </pre>
-     * for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable getSnapshotLifecycleStatsAsync(
-        GetSnapshotLifecycleStatsRequest request,
-        RequestOptions options,
-        ActionListener<GetSnapshotLifecycleStatsResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
-            options,
-            GetSnapshotLifecycleStatsResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Start the Snapshot Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-start-slm.html
-     * </pre> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse startSLM(StartSLMRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::startSLM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously start the Snapshot Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-start-slm.html
-     * </pre> for more.
-     * @param request the request
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable startSLMAsync(StartSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::startSLM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Stop the Snapshot Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-stop-slm.html
-     * </pre> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public AcknowledgedResponse stopSLM(StopSLMRequest request, RequestOptions options) throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::stopSLM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously stop the Snapshot Lifecycle Management feature.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-stop-slm.html
-     * </pre> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable stopSLMAsync(StopSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::stopSLM,
-            options,
-            AcknowledgedResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Get the status of Snapshot Lifecycle Management.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-status.html
-     * </pre> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @return the response
-     * @throws IOException in case there is a problem sending the request or parsing back the response
-     */
-    public LifecycleManagementStatusResponse getSLMStatus(SnapshotLifecycleManagementStatusRequest request, RequestOptions options)
-        throws IOException {
-        return restHighLevelClient.performRequestAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
-            options,
-            LifecycleManagementStatusResponse::fromXContent,
-            emptySet()
-        );
-    }
-
-    /**
-     * Asynchronously get the status of Snapshot Lifecycle Management.
-     * See <pre>
-     *  https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
-     *  java-rest-high-ilm-slm-status.html
-     * </pre> for more.
-     * @param request the request
-     * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
-     * @param listener the listener to be notified upon request completion
-     * @return cancellable that may be used to cancel the request
-     */
-    public Cancellable getSLMStatusAsync(
-        SnapshotLifecycleManagementStatusRequest request,
-        RequestOptions options,
-        ActionListener<LifecycleManagementStatusResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
-            options,
-            LifecycleManagementStatusResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-}

+ 0 - 12
client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

@@ -284,7 +284,6 @@ public class RestHighLevelClient implements Closeable {
     private final MigrationClient migrationClient = new MigrationClient(this);
     private final MachineLearningClient machineLearningClient = new MachineLearningClient(this);
     private final SecurityClient securityClient = new SecurityClient(this);
-    private final IndexLifecycleClient ilmClient = new IndexLifecycleClient(this);
     private final TransformClient transformClient = new TransformClient(this);
     private final EqlClient eqlClient = new EqlClient(this);
     private final SearchableSnapshotsClient searchableSnapshotsClient = new SearchableSnapshotsClient(this);
@@ -418,17 +417,6 @@ public class RestHighLevelClient implements Closeable {
         return xPackClient;
     }
 
-    /**
-     * A wrapper for the {@link RestHighLevelClient} that provides methods for
-     * accessing the Elastic Index Lifecycle APIs.
-     * <p>
-     * See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management-api.html"> X-Pack APIs
-     * on elastic.co</a> for more information.
-     */
-    public IndexLifecycleClient indexLifecycle() {
-        return ilmClient;
-    }
-
     /**
      * A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Searchable Snapshots APIs.
      * <p>

+ 7 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

@@ -104,6 +104,7 @@ import static java.util.Collections.sort;
 import static java.util.Collections.unmodifiableList;
 import static org.hamcrest.Matchers.anEmptyMap;
 import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.everyItem;
 import static org.hamcrest.Matchers.in;
@@ -1400,6 +1401,12 @@ public abstract class ESRestTestCase extends ESTestCase {
         assertThat(response.getStatusLine().getStatusCode(), anyOf(equalTo(200), equalTo(201)));
     }
 
+    public static void assertAcknowledged(Response response) throws IOException {
+        assertOK(response);
+        String jsonBody = EntityUtils.toString(response.getEntity());
+        assertThat(jsonBody, containsString("\"acknowledged\":true"));
+    }
+
     /**
      * Permits subclasses to increase the default timeout when waiting for green health
      */

+ 56 - 88
x-pack/plugin/ilm/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java

@@ -9,11 +9,8 @@ package org.elasticsearch.xpack.security;
 
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.ElasticsearchStatusException;
+import org.apache.http.util.EntityUtils;
 import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
-import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
-import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
 import org.elasticsearch.client.Node;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.RequestOptions;
@@ -21,14 +18,6 @@ import org.elasticsearch.client.Response;
 import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
-import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.client.core.AcknowledgedResponse;
-import org.elasticsearch.client.slm.DeleteSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyResponse;
-import org.elasticsearch.client.slm.ExecuteSnapshotLifecycleRetentionRequest;
-import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyRequest;
-import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
 import org.elasticsearch.client.slm.SnapshotLifecyclePolicy;
 import org.elasticsearch.client.slm.SnapshotRetentionConfiguration;
 import org.elasticsearch.common.Strings;
@@ -37,11 +26,11 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.util.concurrent.ThreadContext;
 import org.elasticsearch.common.xcontent.XContentHelper;
 import org.elasticsearch.common.xcontent.support.XContentMapValues;
+import org.elasticsearch.core.Nullable;
 import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.repositories.fs.FsRepository;
 import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
-import org.elasticsearch.snapshots.SnapshotState;
 import org.elasticsearch.test.rest.ESRestTestCase;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentType;
@@ -63,7 +52,6 @@ import java.util.concurrent.TimeUnit;
 
 import static java.util.Collections.singletonMap;
 import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
-import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 
@@ -190,30 +178,12 @@ public class PermissionsIT extends ESRestTestCase {
         createUser("slm_admin", "slm-admin-password", "slm-manage");
         createUser("slm_user", "slm-user-password", "slm-read");
 
-        final HighLevelClient hlAdminClient = new HighLevelClient(adminClient());
-
-        // Build two high level clients, each using a different user
-        final RestClientBuilder adminBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
-        final String adminToken = basicAuthHeaderValue("slm_admin", new SecureString("slm-admin-password".toCharArray()));
-        configureClient(adminBuilder, Settings.builder().put(ThreadContext.PREFIX + ".Authorization", adminToken).build());
-        adminBuilder.setStrictDeprecationMode(true);
-        final RestHighLevelClient adminHLRC = new RestHighLevelClient(adminBuilder);
-
-        final RestClientBuilder userBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
-        final String userToken = basicAuthHeaderValue("slm_user", new SecureString("slm-user-password".toCharArray()));
-        configureClient(userBuilder, Settings.builder().put(ThreadContext.PREFIX + ".Authorization", userToken).build());
-        userBuilder.setStrictDeprecationMode(true);
-        final RestHighLevelClient readHlrc = new RestHighLevelClient(userBuilder);
-
         PutRepositoryRequest repoRequest = new PutRepositoryRequest();
-
         Settings.Builder settingsBuilder = Settings.builder().put("location", ".");
         repoRequest.settings(settingsBuilder);
         repoRequest.name(repo);
         repoRequest.type(FsRepository.TYPE);
-        org.elasticsearch.action.support.master.AcknowledgedResponse response = hlAdminClient.snapshot()
-            .createRepository(repoRequest, RequestOptions.DEFAULT);
-        assertTrue(response.isAcknowledged());
+        assertAcknowledged(performWithOptions(RequestOptions.DEFAULT, "PUT", "/_snapshot/" + repo, Strings.toString(repoRequest)));
 
         Map<String, Object> config = new HashMap<>();
         config.put("indices", Collections.singletonList("index"));
@@ -225,75 +195,65 @@ public class PermissionsIT extends ESRestTestCase {
             config,
             new SnapshotRetentionConfiguration(TimeValue.ZERO, null, null)
         );
-        PutSnapshotLifecyclePolicyRequest request = new PutSnapshotLifecyclePolicyRequest(policy);
+        final String policyStr = Strings.toString(policy);
 
-        expectThrows(
-            ElasticsearchStatusException.class,
-            () -> readHlrc.indexLifecycle().putSnapshotLifecyclePolicy(request, RequestOptions.DEFAULT)
-        );
+        // Build two client options, each using a different user
+        final RequestOptions adminOptions = RequestOptions.DEFAULT.toBuilder()
+            .addHeader("Authorization", basicAuthHeaderValue("slm_admin", new SecureString("slm-admin-password".toCharArray())))
+            .build();
 
-        adminHLRC.indexLifecycle().putSnapshotLifecyclePolicy(request, RequestOptions.DEFAULT);
+        final RequestOptions userOptions = RequestOptions.DEFAULT.toBuilder()
+            .addHeader("Authorization", basicAuthHeaderValue("slm_user", new SecureString("slm-user-password".toCharArray())))
+            .build();
 
-        GetSnapshotLifecyclePolicyRequest getRequest = new GetSnapshotLifecyclePolicyRequest("policy_id");
-        readHlrc.indexLifecycle().getSnapshotLifecyclePolicy(getRequest, RequestOptions.DEFAULT);
-        adminHLRC.indexLifecycle().getSnapshotLifecyclePolicy(getRequest, RequestOptions.DEFAULT);
+        expectThrows(ResponseException.class, () -> performWithOptions(userOptions, "PUT", "/_slm/policy/policy_id", policyStr));
 
-        ExecuteSnapshotLifecyclePolicyRequest executeRequest = new ExecuteSnapshotLifecyclePolicyRequest("policy_id");
-        expectThrows(
-            ElasticsearchStatusException.class,
-            () -> readHlrc.indexLifecycle().executeSnapshotLifecyclePolicy(executeRequest, RequestOptions.DEFAULT)
-        );
+        performWithOptions(adminOptions, "PUT", "/_slm/policy/policy_id", policyStr);
+
+        performWithOptions(userOptions, "GET", "/_slm/policy/policy_id", null);
+        performWithOptions(adminOptions, "GET", "/_slm/policy/policy_id", null);
 
-        ExecuteSnapshotLifecyclePolicyResponse executeResp = adminHLRC.indexLifecycle()
-            .executeSnapshotLifecyclePolicy(executeRequest, RequestOptions.DEFAULT);
-        final String snapName = executeResp.getSnapshotName();
+        expectThrows(ResponseException.class, () -> performWithOptions(userOptions, "PUT", "/_slm/policy/policy_id/_execute", null));
+
+        Response executeResponse = performWithOptions(adminOptions, "PUT", "/_slm/policy/policy_id/_execute", null);
+        String body = EntityUtils.toString(executeResponse.getEntity());
+        final String snapName = body.replace("{\"snapshot_name\":\"", "").replace("\"}", "");
 
         assertBusy(() -> {
             try {
-                logger.info("--> checking for snapshot to be created");
-                GetSnapshotsRequest getSnaps = new GetSnapshotsRequest(repo);
-                getSnaps.snapshots(new String[] { snapName });
-                GetSnapshotsResponse getResp = adminHLRC.snapshot().get(getSnaps, RequestOptions.DEFAULT);
-                assertThat(getResp.getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
-            } catch (ElasticsearchException e) {
-                fail("expected snapshot to exist but it does not: " + e.getDetailedMessage());
+                logger.info("--> checking for snapshot [{}] to be created", snapName);
+                Request req = new Request("GET", "/_snapshot/" + repo + "/" + snapName);
+                Response resp = adminClient().performRequest(req);
+                String respStr = EntityUtils.toString(resp.getEntity());
+                if (respStr.contains("SUCCESS") == false) {
+                    fail("expected successful snapshot but got: " + respStr);
+                }
+            } catch (ResponseException e) {
+                fail("expected snapshot to exist but it does not: " + e);
             }
         });
 
-        ExecuteSnapshotLifecycleRetentionRequest executeRetention = new ExecuteSnapshotLifecycleRetentionRequest();
-        expectThrows(
-            ElasticsearchStatusException.class,
-            () -> readHlrc.indexLifecycle().executeSnapshotLifecycleRetention(executeRetention, RequestOptions.DEFAULT)
-        );
+        expectThrows(ResponseException.class, () -> performWithOptions(userOptions, "POST", "/_slm/_execute_retention"));
 
-        AcknowledgedResponse retentionResp = adminHLRC.indexLifecycle()
-            .executeSnapshotLifecycleRetention(executeRetention, RequestOptions.DEFAULT);
-        assertTrue(retentionResp.isAcknowledged());
+        assertAcknowledged(performWithOptions(adminOptions, "POST", "/_slm/_execute_retention"));
 
         assertBusy(() -> {
             try {
                 logger.info("--> checking for snapshot to be deleted");
-                GetSnapshotsRequest getSnaps = new GetSnapshotsRequest(repo);
-                getSnaps.snapshots(new String[] { snapName });
-                GetSnapshotsResponse getResp = adminHLRC.snapshot().get(getSnaps, RequestOptions.DEFAULT);
-                assertThat(getResp.getSnapshots().size(), equalTo(0));
-            } catch (ElasticsearchException e) {
-                // great, we want it to not exist
-                assertThat(e.getDetailedMessage(), containsString("snapshot_missing_exception"));
+                performWithOptions(adminOptions, "GET", "/_snapshot/" + repo + "/" + snapName);
+                fail("expected 404 because snapshot should be deleted, but it still exists");
+            } catch (ResponseException e) {
+                assertThat(
+                    "expected 404 for missing snapshot after it has been deleted",
+                    e.getResponse().getStatusLine().getStatusCode(),
+                    equalTo(404)
+                );
             }
         });
 
-        DeleteSnapshotLifecyclePolicyRequest deleteRequest = new DeleteSnapshotLifecyclePolicyRequest("policy_id");
-        expectThrows(
-            ElasticsearchStatusException.class,
-            () -> readHlrc.indexLifecycle().deleteSnapshotLifecyclePolicy(deleteRequest, RequestOptions.DEFAULT)
-        );
-
-        adminHLRC.indexLifecycle().deleteSnapshotLifecyclePolicy(deleteRequest, RequestOptions.DEFAULT);
+        expectThrows(ResponseException.class, () -> performWithOptions(userOptions, "DELETE", "/_slm/policy/policy_id"));
 
-        hlAdminClient.close();
-        readHlrc.close();
-        adminHLRC.close();
+        performWithOptions(adminOptions, "DELETE", "/_slm/policy/policy_id");
     }
 
     public void testCanViewExplainOnUnmanagedIndex() throws Exception {
@@ -348,6 +308,20 @@ public class PermissionsIT extends ESRestTestCase {
         });
     }
 
+    private Response performWithOptions(RequestOptions options, String verb, String endpoint) throws IOException {
+        return performWithOptions(options, verb, endpoint, null);
+    }
+
+    private Response performWithOptions(RequestOptions options, String verb, String endpoint, @Nullable String jsonBody)
+        throws IOException {
+        Request req = new Request(verb, endpoint);
+        if (jsonBody != null) {
+            req.setJsonEntity(jsonBody);
+        }
+        req.setOptions(options);
+        return adminClient().performRequest(req);
+    }
+
     private void createNewSingletonPolicy(RestClient client, String policy, String phaseName, LifecycleAction action) throws IOException {
         Phase phase = new Phase(phaseName, TimeValue.ZERO, singletonMap(action.getWriteableName(), action));
         LifecyclePolicy lifecyclePolicy = new LifecyclePolicy(policy, singletonMap(phase.getName(), phase));
@@ -424,10 +398,4 @@ public class PermissionsIT extends ESRestTestCase {
         assertOK(adminClient().performRequest(request));
     }
 
-    private static class HighLevelClient extends RestHighLevelClient {
-        private HighLevelClient(RestClient restClient) {
-            super(restClient, (client) -> {}, Collections.emptyList());
-        }
-    }
-
 }