Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate /_cat/snapshots in favor of /_cat/snapshots/{repository} #16960

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,28 @@
/^ snap1\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
snap2\s+ SUCCESS\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ 2\s+ 2\s+ 0\s+ 2\s*\n
$/

---
"Test deprecated _cat/snapshots endpoint":
- skip:
version: " - 2.18.99"
reason: "Deprecation added in 2.19"
features: [ "warnings" ]

- do:
snapshot.create_repository:
repository: dep_test_repo
body:
type: fs
settings:
location: "dep_test_repo_loc"

- do:
warnings:
- "[/_cat/snapshots] is a deprecated endpoint. Please use [/_cat/snapshots/{repository}] instead."
cat.snapshots:
q: "repository:dep_test_repo"

- match:
$body: |
/^$/
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
import java.time.Instant;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.Collections.singletonList;
import static org.opensearch.rest.RestRequest.Method.GET;

/**
Expand All @@ -63,9 +63,20 @@ public class RestSnapshotAction extends AbstractCatAction {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSnapshotAction.class);

private static final String DEPRECATED_MESSAGE_CAT_SNAPSHOTS = String.format(
Locale.ROOT,
"[%s] is a deprecated endpoint. Please use [/_cat/snapshots/{repository}] instead.",
"/_cat/snapshots"
);

@Override
public List<Route> routes() {
return unmodifiableList(asList(new Route(GET, "/_cat/snapshots"), new Route(GET, "/_cat/snapshots/{repository}")));
return singletonList(new Route(GET, "/_cat/snapshots/{repository}"));
}

@Override
public List<DeprecatedRoute> deprecatedRoutes() {
return singletonList(new DeprecatedRoute(GET, "/_cat/snapshots", DEPRECATED_MESSAGE_CAT_SNAPSHOTS));
}

@Override
Expand All @@ -77,7 +88,6 @@ public String getName() {
public RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest().repository(request.param("repository"))
.snapshots(new String[] { GetSnapshotsRequest.ALL_SNAPSHOTS });

getSnapshotsRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", getSnapshotsRequest.ignoreUnavailable()));

getSnapshotsRequest.clusterManagerNodeTimeout(
Expand Down
Loading