Skip to content

Commit 300ddfa

Browse files
authored
SLM Start/Stop HLRC and docs (#47966)
This commit adds HLRC support and documentation for the SLM Start and Stop APIs, as well as updating existing documentation where appropriate. This commit also ensures that the SLM APIs are properly included in the HLRC documentation.
1 parent 8814bf0 commit 300ddfa

11 files changed

+704
-31
lines changed

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

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsRequest;
4444
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsResponse;
4545
import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
46+
import org.elasticsearch.client.slm.SnapshotLifecycleManagementStatusRequest;
47+
import org.elasticsearch.client.slm.StartSLMRequest;
48+
import org.elasticsearch.client.slm.StopSLMRequest;
4649

4750
import java.io.IOException;
4851

@@ -540,4 +543,102 @@ public Cancellable getSnapshotLifecycleStatsAsync(GetSnapshotLifecycleStatsReque
540543
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
541544
options, GetSnapshotLifecycleStatsResponse::fromXContent, listener, emptySet());
542545
}
546+
547+
/**
548+
* Start the Snapshot Lifecycle Management feature.
549+
* See <pre>
550+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
551+
* java-rest-high-ilm-slm-start-slm.html
552+
* </pre> for more.
553+
* @param request the request
554+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
555+
* @return the response
556+
* @throws IOException in case there is a problem sending the request or parsing back the response
557+
*/
558+
public AcknowledgedResponse startSLM(StartSLMRequest request, RequestOptions options) throws IOException {
559+
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::startSLM, options,
560+
AcknowledgedResponse::fromXContent, emptySet());
561+
}
562+
563+
/**
564+
* Asynchronously start the Snapshot Lifecycle Management feature.
565+
* See <pre>
566+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
567+
* java-rest-high-ilm-slm-start-slm.html
568+
* </pre> for more.
569+
* @param request the request
570+
* @param listener the listener to be notified upon request completion
571+
* @return cancellable that may be used to cancel the request
572+
*/
573+
public Cancellable startSLMAsync(StartSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
574+
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::startSLM, options,
575+
AcknowledgedResponse::fromXContent, listener, emptySet());
576+
}
577+
578+
/**
579+
* Stop the Snapshot Lifecycle Management feature.
580+
* See <pre>
581+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
582+
* java-rest-high-ilm-slm-stop-slm.html
583+
* </pre> for more.
584+
* @param request the request
585+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
586+
* @return the response
587+
* @throws IOException in case there is a problem sending the request or parsing back the response
588+
*/
589+
public AcknowledgedResponse stopSLM(StopSLMRequest request, RequestOptions options) throws IOException {
590+
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::stopSLM, options,
591+
AcknowledgedResponse::fromXContent, emptySet());
592+
}
593+
594+
/**
595+
* Asynchronously stop the Snapshot Lifecycle Management feature.
596+
* See <pre>
597+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
598+
* java-rest-high-ilm-slm-stop-slm.html
599+
* </pre> for more.
600+
* @param request the request
601+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
602+
* @param listener the listener to be notified upon request completion
603+
* @return cancellable that may be used to cancel the request
604+
*/
605+
public Cancellable stopSLMAsync(StopSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
606+
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::stopSLM, options,
607+
AcknowledgedResponse::fromXContent, listener, emptySet());
608+
}
609+
610+
/**
611+
* Get the status of Snapshot Lifecycle Management.
612+
* See <pre>
613+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
614+
* java-rest-high-ilm-slm-status.html
615+
* </pre> for more.
616+
* @param request the request
617+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
618+
* @return the response
619+
* @throws IOException in case there is a problem sending the request or parsing back the response
620+
*/
621+
public LifecycleManagementStatusResponse getSLMStatus(SnapshotLifecycleManagementStatusRequest request,
622+
RequestOptions options) throws IOException {
623+
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
624+
options, LifecycleManagementStatusResponse::fromXContent, emptySet());
625+
}
626+
627+
/**
628+
* Asynchronously get the status of Snapshot Lifecycle Management.
629+
* See <pre>
630+
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
631+
* java-rest-high-ilm-slm-status.html
632+
* </pre> for more.
633+
* @param request the request
634+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
635+
* @param listener the listener to be notified upon request completion
636+
* @return cancellable that may be used to cancel the request
637+
*/
638+
public Cancellable getSLMStatusAsync(SnapshotLifecycleManagementStatusRequest request, RequestOptions options,
639+
ActionListener<LifecycleManagementStatusResponse> listener) {
640+
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
641+
IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus, options, LifecycleManagementStatusResponse::fromXContent,
642+
listener, emptySet());
643+
}
543644
}

client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleRequestConverters.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyRequest;
3939
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsRequest;
4040
import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
41+
import org.elasticsearch.client.slm.SnapshotLifecycleManagementStatusRequest;
42+
import org.elasticsearch.client.slm.StartSLMRequest;
43+
import org.elasticsearch.client.slm.StopSLMRequest;
4144
import org.elasticsearch.common.Strings;
4245

4346
import java.io.IOException;
@@ -239,4 +242,43 @@ static Request getSnapshotLifecycleStats(GetSnapshotLifecycleStatsRequest getSna
239242
request.addParameters(params.asMap());
240243
return request;
241244
}
245+
246+
static Request snapshotLifecycleManagementStatus(SnapshotLifecycleManagementStatusRequest snapshotLifecycleManagementStatusRequest){
247+
Request request = new Request(HttpGet.METHOD_NAME,
248+
new RequestConverters.EndpointBuilder()
249+
.addPathPartAsIs("_slm")
250+
.addPathPartAsIs("status")
251+
.build());
252+
RequestConverters.Params params = new RequestConverters.Params();
253+
params.withMasterTimeout(snapshotLifecycleManagementStatusRequest.masterNodeTimeout());
254+
params.withTimeout(snapshotLifecycleManagementStatusRequest.timeout());
255+
request.addParameters(params.asMap());
256+
return request;
257+
}
258+
259+
static Request startSLM(StartSLMRequest startSLMRequest) {
260+
Request request = new Request(HttpPost.METHOD_NAME,
261+
new RequestConverters.EndpointBuilder()
262+
.addPathPartAsIs("_slm")
263+
.addPathPartAsIs("start")
264+
.build());
265+
RequestConverters.Params params = new RequestConverters.Params();
266+
params.withMasterTimeout(startSLMRequest.masterNodeTimeout());
267+
params.withTimeout(startSLMRequest.timeout());
268+
request.addParameters(params.asMap());
269+
return request;
270+
}
271+
272+
static Request stopSLM(StopSLMRequest stopSLMRequest) {
273+
Request request = new Request(HttpPost.METHOD_NAME,
274+
new RequestConverters.EndpointBuilder()
275+
.addPathPartAsIs("_slm")
276+
.addPathPartAsIs("stop")
277+
.build());
278+
RequestConverters.Params params = new RequestConverters.Params();
279+
params.withMasterTimeout(stopSLMRequest.masterNodeTimeout());
280+
params.withTimeout(stopSLMRequest.timeout());
281+
request.addParameters(params.asMap());
282+
return request;
283+
}
242284
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.slm;
21+
22+
import org.elasticsearch.client.TimedRequest;
23+
24+
public class SnapshotLifecycleManagementStatusRequest extends TimedRequest {
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.slm;
21+
22+
import org.elasticsearch.client.TimedRequest;
23+
24+
public class StartSLMRequest extends TimedRequest {
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.slm;
21+
22+
import org.elasticsearch.client.TimedRequest;
23+
24+
public class StopSLMRequest extends TimedRequest {
25+
}

0 commit comments

Comments
 (0)