-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Introduce Next Field in Paginated GetSnapshots Response #74236
Changes from 7 commits
0092197
6f41fa6
622b25b
0f9aad3
e178f43
d3b362b
332cbfb
60264aa
8a829d1
59ac817
70b957f
27cf07e
4da55ff
72f29fe
025116d
497333c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ PUT /_snapshot/my_repository | |
|
||
PUT /_snapshot/my_repository/my_snapshot?wait_for_completion=true | ||
|
||
PUT /_snapshot/my_repository/snapshot_1?wait_for_completion=true | ||
PUT /_snapshot/my_repository/snapshot_2?wait_for_completion=true | ||
PUT /_snapshot/my_repository/snapshot_3?wait_for_completion=true | ||
---- | ||
// TESTSETUP | ||
//// | ||
|
@@ -128,7 +130,11 @@ Allows setting a sort order for the result. Defaults to `start_time`, i.e. sorti | |
(Optional, string) | ||
Sort order. Valid values are `asc` for ascending and `desc` for descending order. Defaults to `asc`, meaning ascending order. | ||
|
||
NOTE: The pagination parameters `size`, `order`, and `sort` are not supported when using `verbose=false` and the sort order for | ||
`after`:: | ||
(Optional, string) | ||
Offset identifier to start pagination from as returned by the `next` field in the response body. | ||
|
||
NOTE: The pagination parameters `size`, `order`, `after` and `sort` are not supported when using `verbose=false` and the sort order for | ||
requests with `verbose=false` is undefined. | ||
|
||
[role="child_attributes"] | ||
|
@@ -268,6 +274,10 @@ The snapshot `state` can be one of the following values: | |
that were not processed correctly. | ||
==== | ||
-- | ||
`next`:: | ||
(string) | ||
If the request contained a size limit and there might be more results, a `next` field will be added to the response and can be used as the | ||
`after` query parameter to fetch additional results. | ||
|
||
[[get-snapshot-api-example]] | ||
==== {api-examples-title} | ||
|
@@ -319,3 +329,130 @@ The API returns the following response: | |
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.129Z"/"end_time": $body.snapshots.0.end_time/] | ||
// TESTRESPONSE[s/"end_time_in_millis": 1593094752018/"end_time_in_millis": $body.snapshots.0.end_time_in_millis/] | ||
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/] | ||
|
||
The following request returns information for all snapshots with prefix `snapshot` in the `my_repository` repository, | ||
limiting the response size to 2 and sorting by snapshot name. | ||
|
||
[source,console] | ||
---- | ||
GET /_snapshot/my_repository/snapshot*?size=2&sort=name | ||
---- | ||
|
||
The API returns the following response: | ||
|
||
[source,console-result] | ||
---- | ||
{ | ||
"snapshots": [ | ||
{ | ||
"snapshot": "snapshot_1", | ||
"uuid": "dKb54xw67gvdRctLCxSket", | ||
"repository": "my_repository", | ||
"version_id": <version_id>, | ||
"version": <version>, | ||
"indices": [], | ||
"data_streams": [], | ||
"feature_states": [], | ||
"include_global_state": true, | ||
"state": "SUCCESS", | ||
"start_time": "2020-07-06T21:55:18.129Z", | ||
"start_time_in_millis": 1593093628850, | ||
"end_time": "2020-07-06T21:55:18.129Z", | ||
"end_time_in_millis": 1593094752018, | ||
"duration_in_millis": 0, | ||
"failures": [], | ||
"shards": { | ||
"total": 0, | ||
"failed": 0, | ||
"successful": 0 | ||
} | ||
}, | ||
{ | ||
"snapshot": "snapshot_2", | ||
"uuid": "vdRctLCxSketdKb54xw67g", | ||
"repository": "my_repository", | ||
"version_id": <version_id>, | ||
"version": <version>, | ||
"indices": [], | ||
"data_streams": [], | ||
"feature_states": [], | ||
"include_global_state": true, | ||
"state": "SUCCESS", | ||
"start_time": "2020-07-06T21:55:18.130Z", | ||
"start_time_in_millis": 1593093628851, | ||
"end_time": "2020-07-06T21:55:18.130Z", | ||
"end_time_in_millis": 1593094752019, | ||
"duration_in_millis": 1, | ||
"failures": [], | ||
"shards": { | ||
"total": 0, | ||
"failed": 0, | ||
"successful": 0 | ||
} | ||
} | ||
], | ||
"next": "snapshot_2,snapshot_2" | ||
} | ||
---- | ||
// TESTRESPONSE[s/"uuid": "dKb54xw67gvdRctLCxSket"/"uuid": $body.snapshots.0.uuid/] | ||
// TESTRESPONSE[s/"uuid": "vdRctLCxSketdKb54xw67g"/"uuid": $body.snapshots.1.uuid/] | ||
// TESTRESPONSE[s/"version_id": <version_id>/"version_id": $body.snapshots.0.version_id/] | ||
// TESTRESPONSE[s/"version": <version>/"version": $body.snapshots.0.version/] | ||
// TESTRESPONSE[s/"start_time": "2020-07-06T21:55:18.129Z"/"start_time": $body.snapshots.0.start_time/] | ||
// TESTRESPONSE[s/"start_time": "2020-07-06T21:55:18.130Z"/"start_time": $body.snapshots.1.start_time/] | ||
// TESTRESPONSE[s/"start_time_in_millis": 1593093628850/"start_time_in_millis": $body.snapshots.0.start_time_in_millis/] | ||
// TESTRESPONSE[s/"start_time_in_millis": 1593093628851/"start_time_in_millis": $body.snapshots.1.start_time_in_millis/] | ||
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.129Z"/"end_time": $body.snapshots.0.end_time/] | ||
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.130Z"/"end_time": $body.snapshots.1.end_time/] | ||
// TESTRESPONSE[s/"end_time_in_millis": 1593094752018/"end_time_in_millis": $body.snapshots.0.end_time_in_millis/] | ||
// TESTRESPONSE[s/"end_time_in_millis": 1593094752019/"end_time_in_millis": $body.snapshots.1.end_time_in_millis/] | ||
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/] | ||
// TESTRESPONSE[s/"duration_in_millis": 1/"duration_in_millis": $body.snapshots.1.duration_in_millis/] | ||
|
||
A subsequent request for the remaining snapshots can then be made using the `next` value from the previous response as `after` parameter. | ||
|
||
[source,console] | ||
---- | ||
GET /_snapshot/my_repository/snapshot*?size=2&sort=name&after=snapshot_2,snapshot_2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worry we will have users running into encoding problems with this API, since we permit characters like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ will do :) |
||
---- | ||
|
||
The API returns the following response: | ||
|
||
[source,console-result] | ||
---- | ||
{ | ||
"snapshots": [ | ||
{ | ||
"snapshot": "snapshot_3", | ||
"uuid": "dRctdKb54xw67gvLCxSket", | ||
"repository": "my_repository", | ||
"version_id": <version_id>, | ||
"version": <version>, | ||
"indices": [], | ||
"data_streams": [], | ||
"feature_states": [], | ||
"include_global_state": true, | ||
"state": "SUCCESS", | ||
"start_time": "2020-07-06T21:55:18.129Z", | ||
"start_time_in_millis": 1593093628850, | ||
"end_time": "2020-07-06T21:55:18.129Z", | ||
"end_time_in_millis": 1593094752018, | ||
"duration_in_millis": 0, | ||
"failures": [], | ||
"shards": { | ||
"total": 0, | ||
"failed": 0, | ||
"successful": 0 | ||
} | ||
} | ||
] | ||
} | ||
---- | ||
// TESTRESPONSE[s/"uuid": "dRctdKb54xw67gvLCxSket"/"uuid": $body.snapshots.0.uuid/] | ||
// TESTRESPONSE[s/"version_id": <version_id>/"version_id": $body.snapshots.0.version_id/] | ||
// TESTRESPONSE[s/"version": <version>/"version": $body.snapshots.0.version/] | ||
// TESTRESPONSE[s/"start_time": "2020-07-06T21:55:18.129Z"/"start_time": $body.snapshots.0.start_time/] | ||
// TESTRESPONSE[s/"start_time_in_millis": 1593093628850/"start_time_in_millis": $body.snapshots.0.start_time_in_millis/] | ||
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.129Z"/"end_time": $body.snapshots.0.end_time/] | ||
// TESTRESPONSE[s/"end_time_in_millis": 1593094752018/"end_time_in_millis": $body.snapshots.0.end_time_in_millis/] | ||
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth spending a few lines explaining that the underlying list can change and how pagination works in case of deletes and additions during pagination (i.e., you are sure to not miss any that were in the list originally and have not been deleted during pagination and you may see snapshots added during pagination).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ added a few lines on this