1313import org .elasticsearch .action .admin .cluster .snapshots .get .SnapshotSortKey ;
1414import org .elasticsearch .client .internal .node .NodeClient ;
1515import org .elasticsearch .common .Strings ;
16+ import org .elasticsearch .common .util .set .Sets ;
17+ import org .elasticsearch .core .Assertions ;
1618import org .elasticsearch .features .NodeFeature ;
1719import org .elasticsearch .rest .BaseRestHandler ;
1820import org .elasticsearch .rest .RestRequest ;
21+ import org .elasticsearch .rest .RestUtils ;
1922import org .elasticsearch .rest .Scope ;
2023import org .elasticsearch .rest .ServerlessScope ;
2124import org .elasticsearch .rest .action .RestCancellableNodeClient ;
4245@ ServerlessScope (Scope .INTERNAL )
4346public class RestGetSnapshotsAction extends BaseRestHandler {
4447
48+ private static final Set <String > SUPPORTED_RESPONSE_PARAMETERS = Set .of (
49+ INCLUDE_REPOSITORY_XCONTENT_PARAM ,
50+ INDEX_DETAILS_XCONTENT_PARAM ,
51+ INDEX_NAMES_XCONTENT_PARAM
52+ );
53+
54+ private static final Set <String > SUPPORTED_QUERY_PARAMETERS = Set .of (
55+ RestUtils .REST_MASTER_TIMEOUT_PARAM ,
56+ "after" ,
57+ "from_sort_value" ,
58+ "ignore_unavailable" ,
59+ "offset" ,
60+ "order" ,
61+ "size" ,
62+ "slm_policy_filter" ,
63+ "sort" ,
64+ "state" ,
65+ "verbose"
66+ );
67+
68+ private static final Set <String > ALL_SUPPORTED_PARAMETERS = Set .copyOf (
69+ Sets .union (SUPPORTED_QUERY_PARAMETERS , SUPPORTED_RESPONSE_PARAMETERS , Set .of ("repository" , "snapshot" ))
70+ );
71+
4572 private final Predicate <NodeFeature > clusterSupportsFeature ;
4673
4774 public RestGetSnapshotsAction (Predicate <NodeFeature > clusterSupportsFeature ) {
@@ -60,7 +87,17 @@ public String getName() {
6087
6188 @ Override
6289 protected Set <String > responseParams () {
63- return Set .of (INDEX_DETAILS_XCONTENT_PARAM , INCLUDE_REPOSITORY_XCONTENT_PARAM , INDEX_NAMES_XCONTENT_PARAM );
90+ return SUPPORTED_RESPONSE_PARAMETERS ;
91+ }
92+
93+ @ Override
94+ public Set <String > supportedQueryParameters () {
95+ return SUPPORTED_QUERY_PARAMETERS ;
96+ }
97+
98+ @ Override
99+ public Set <String > allSupportedParameters () {
100+ return ALL_SUPPORTED_PARAMETERS ;
64101 }
65102
66103 @ Override
@@ -101,6 +138,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
101138 throw new IllegalStateException ("[state] parameter is not supported on all nodes in the cluster" );
102139 }
103140
141+ // Consume these response parameters used in SnapshotInfo now, to avoid assertion errors in BaseRestHandler for requests where they
142+ // may not get used.
143+ if (Assertions .ENABLED ) {
144+ for (final var responseParameter : SUPPORTED_RESPONSE_PARAMETERS ) {
145+ request .param (responseParameter );
146+ }
147+ }
148+
104149 return channel -> new RestCancellableNodeClient (client , request .getHttpChannel ()).admin ()
105150 .cluster ()
106151 .getSnapshots (getSnapshotsRequest , new RestRefCountedChunkedToXContentListener <>(channel ));
0 commit comments