Skip to content

Commit 4b130d6

Browse files
committed
add offset/limit parameters to operation/list handler (#16161)
1 parent c9f4f5a commit 4b130d6

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

ydb/core/viewer/json_local_rpc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ class TJsonLocalRpc : public TViewerPipeClient {
130130
return false;
131131
}
132132
}
133-
const auto& params(Event->Get()->Request.GetParams());
134-
Params2Proto(params, request);
133+
Params2Proto(Params, request);
135134
if (!ValidateRequest(request)) {
136135
return false;
137136
}

ydb/core/viewer/operation_list.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ class TOperationList : public TOperationListRpc {
2323
AllowedMethods = {HTTP_METHOD_GET};
2424
}
2525

26+
bool ValidateRequest(Ydb::Operations::ListOperationsRequest& request) override {
27+
if (!TBase::ValidateRequest(request)) {
28+
return false;
29+
}
30+
ui64 offset = FromStringWithDefault<ui64>(Params.Get("offset"), 0);
31+
ui64 limit = FromStringWithDefault<ui64>(Params.Get("limit"), 0);
32+
if (offset >= 0 && limit > 0) {
33+
if (offset % limit != 0) {
34+
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "offset must be a multiple of limit"));
35+
return false;
36+
}
37+
if (limit > 100) {
38+
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "limit must be less than or equal to 100"));
39+
return false;
40+
}
41+
request.set_page_size(limit);
42+
request.set_page_token(std::to_string(offset / limit + 1));
43+
}
44+
return true;
45+
}
46+
2647
static YAML::Node GetSwagger() {
2748
YAML::Node node = YAML::Load(R"___(
2849
get:
@@ -42,7 +63,8 @@ class TOperationList : public TOperationListRpc {
4263
kind:
4364
* `ss/backgrounds`
4465
* `export`
45-
* `import`
66+
* `import/S3`
67+
* `import/YT`
4668
* `buildindex`
4769
* `scriptexec`
4870
required: true
@@ -57,6 +79,16 @@ class TOperationList : public TOperationListRpc {
5779
description: page token
5880
required: false
5981
type: string
82+
- name: offset
83+
in: query
84+
description: offset. must be a multiple of limit
85+
required: false
86+
type: integer
87+
- name: limit
88+
in: query
89+
description: limit. must be less than or equal to 100
90+
required: false
91+
type: integer
6092
responses:
6193
200:
6294
description: OK

0 commit comments

Comments
 (0)