Skip to content

Commit 33844f4

Browse files
committed
Add pagination and sort parameters
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 6cd6f34 commit 33844f4

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ In this release, we have made some changes to the API to improve the user experi
1818
* Documentation about authentication and encryption was added.
1919
* Enhanced `payload` documentation.
2020
* Add YEARLY frequency to the recurrence definition.
21+
* Add parameters for pagination and sorting.
2122

2223
## Bug Fixes
2324

proto/frequenz/api/dispatch/v1/dispatch.proto

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import "google/protobuf/struct.proto";
1818
import "google/protobuf/timestamp.proto";
1919

2020
import "frequenz/api/common/v1/microgrid/components/components.proto";
21+
import "frequenz/api/common/v1/pagination/pagination_info.proto";
22+
import "frequenz/api/common/v1/pagination/pagination_params.proto";
2123

2224
// Service providing operations related to dispatching microgrid components.
2325
//
@@ -307,13 +309,64 @@ message RecurrenceRule {
307309
repeated uint32 bymonths = 8;
308310
}
309311

310-
// Message for listing dispatches for a given microgrid, and an optional filter
312+
// Enum for the fields to by sorted by.
313+
enum SortField {
314+
// UNSPECIFIED: Default, unspecified sort field.
315+
SORT_FIELD_UNSPECIFIED = 0;
316+
317+
// START_TIME: Sort by start time of the dispatch.
318+
SORT_FIELD_START_TIME = 1;
319+
320+
// CREATE_TIME: Sort by creation time of the dispatch.
321+
SORT_FIELD_CREATE_TIME = 2;
322+
323+
// UPDATE_TIME: Sort by last update time of the dispatch.
324+
SORT_FIELD_LAST_UPDATE_TIME = 3;
325+
}
326+
327+
// Enum for sort order.
328+
enum SortOrder {
329+
// UNSPECIFIED: Default, unspecified sort order.
330+
SORT_ORDER_UNSPECIFIED = 0;
331+
332+
// ASCENDING: Results are returned in ascending order.
333+
SORT_ORDER_ASCENDING = 1;
334+
335+
// DESCENDING: Results are returned in descending order.
336+
SORT_ORDER_DESCENDING = 2;
337+
}
338+
339+
// Message defining parameters for sorting list requests.
340+
//
341+
// Example Usage:
342+
// To retrieve dispatches sorted by creation time in descending order:
343+
// sort_options: { field: CREATE_TIME, order: DESCENDING }
344+
//
345+
message SortOptions {
346+
// Optional field by which to sort the results.
347+
SortField sort_field = 1;
348+
349+
// Optional Order in which to sort the results.
350+
SortOrder sort_order = 2;
351+
}
352+
353+
// Message for listing dispatches for a given microgrid.
354+
//
355+
// Allows retrieval of dispatches for a specified microgrid with optional filtering and sorting.
356+
// Sorting can be specified by setting 'sort_field' and 'sort_order'. If no sorting is specified,
357+
// the results will be returned by their create time in a descending order.
311358
message ListMicrogridDispatchesRequest {
312359
// The microgrid ID
313360
uint64 microgrid_id = 1;
314361

315-
// Additional filter parameters
362+
// Optional filters to apply
316363
DispatchFilter filter = 2;
364+
365+
// Sorting options for the result
366+
SortOptions sort_options = 3;
367+
368+
// Pagination parameters
369+
frequenz.api.common.v1.pagination.PaginationParams pagination_params = 4;
317370
}
318371

319372
// Parameters for filtering the dispatch list
@@ -339,6 +392,9 @@ message DispatchFilter {
339392
message ListMicrogridDispatchesResponse {
340393
// The dispatches
341394
repeated DispatchDetail dispatches = 1;
395+
396+
// Pagination parameters
397+
frequenz.api.common.v1.pagination.PaginationParams pagination_params = 4;
342398
}
343399

344400
// Message to create a new dispatch with the given attributes

0 commit comments

Comments
 (0)