Skip to content

Commit 736198c

Browse files
Refactor pagination.proto
This commit refactors `pagination.proto` to move the `PaginationParams` and `PaginationInfo` messages to their own files, in a new directory `pagination`. This sets package name of this proto file to its parent directory name, which seems to be a standard practice. Signed-off-by: Tiyash Basu <[email protected]>
1 parent c4b12f9 commit 736198c

File tree

5 files changed

+60
-16
lines changed

5 files changed

+60
-16
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959

6060
- Updated the package name of `location.proto` to `frequenz.api.common.v1`.
6161

62+
- Added messages to support pagination in APIs.
63+
6264
## New Features
6365

6466
<!-- Here goes the main new features and examples or instructions on how to use them -->

proto/frequenz/api/common/v1/pagination.proto renamed to proto/frequenz/api/common/v1/pagination/pagination_info.proto

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@ syntax = "proto3";
99

1010
package frequenz.api.common.v1.pagination;
1111

12-
// A message defining parameters for paginating list requests.
13-
// It can be appended to a request message to specify the desired page of
14-
// results and the maximum number of results per page. For initial requests
15-
// (requesting the first page), the page_token should not be provided. For
16-
// subsequent requests (requesting any page after the first), the
17-
// next_page_token from the previous responses PaginationInfo must be supplied.
18-
// The page_size should only be specified in the initial request and will be
19-
// disregarded in subsequent requests.
20-
message PaginationParams {
21-
// The maximum number of results to be returned per request.
22-
optional uint32 page_size = 1;
23-
24-
// The token identifying a specific page of the list results.
25-
optional string page_token = 2;
26-
}
27-
2812
// A message providing metadata about paginated list results.
2913
// The PaginationInfo message delivers metadata concerning the paginated list
3014
// results and should be appended to the response message of a list request. The
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Parameters for pagination.
2+
//
3+
// Copyright 2023 Frequenz Energy-as-a-Service GmbH
4+
//
5+
// Licensed under the MIT License (the "License");
6+
// you may not use this file except in compliance with the License.
7+
8+
syntax = "proto3";
9+
10+
package frequenz.api.common.v1.pagination;
11+
12+
// A message defining parameters for paginating list requests.
13+
// It can be appended to a request message to specify the desired page of
14+
// results and the maximum number of results per page. For initial requests
15+
// (requesting the first page), the page_token should not be provided. For
16+
// subsequent requests (requesting any page after the first), the
17+
// next_page_token from the previous responses PaginationInfo must be supplied.
18+
// The page_size should only be specified in the initial request and will be
19+
// disregarded in subsequent requests.
20+
message PaginationParams {
21+
// The maximum number of results to be returned per request.
22+
optional uint32 page_size = 1;
23+
24+
// The token identifying a specific page of the list results.
25+
optional string page_token = 2;
26+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Frequenz common gRPC API and bindings."""

pytests/test_common.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,31 @@ def test_module_import_location() -> None:
179179
from frequenz.api.common.v1 import location_pb2_grpc
180180

181181
assert location_pb2_grpc is not None
182+
183+
184+
def test_module_import_pagination() -> None:
185+
"""Test that the modules can be imported."""
186+
# pylint: disable=import-outside-toplevel
187+
from frequenz.api.common.v1 import pagination
188+
189+
assert pagination is not None
190+
191+
# pylint: disable=import-outside-toplevel
192+
from frequenz.api.common.v1.pagination import pagination_info_pb2
193+
194+
assert pagination_info_pb2 is not None
195+
196+
# pylint: disable=import-outside-toplevel
197+
from frequenz.api.common.v1.pagination import pagination_info_pb2_grpc
198+
199+
assert pagination_info_pb2_grpc is not None
200+
201+
# pylint: disable=import-outside-toplevel
202+
from frequenz.api.common.v1.pagination import pagination_params_pb2
203+
204+
assert pagination_params_pb2 is not None
205+
206+
# pylint: disable=import-outside-toplevel
207+
from frequenz.api.common.v1.pagination import pagination_params_pb2_grpc
208+
209+
assert pagination_params_pb2_grpc is not None

0 commit comments

Comments
 (0)