Skip to content

Commit 3ad73be

Browse files
Refactor protobuf messages and files to establish a standard packaging scheme (#131)
This change introduces the following packaging norm to the remaining protobuf files: the package for every protobuf file is it's path inside the protobuf directory. E.g., the package name for the message `PaginationInfo` is `frequenz.api.common.v1.pagination`, and the message lives in the file `frequenz/api/common/v1/paginaation/pagination_info.proto`.
2 parents 4050b0e + 0208871 commit 3ad73be

File tree

12 files changed

+116
-44
lines changed

12 files changed

+116
-44
lines changed

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757

5858
- Added a message `Microgrid` to represent a microgrid.
5959

60+
- Updated the package name of `location.proto` to `frequenz.api.common.v1`.
61+
62+
- Added messages to support pagination in APIs.
63+
6064
## New Features
6165

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

proto/frequenz/api/common/v1/location.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
syntax = "proto3";
99

10-
package frequenz.api.common.v1.location;
10+
package frequenz.api.common.v1;
1111

1212
// A pair of geographical co-ordinates, representing the location of a place.
1313
message Location {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Definitions for bounds.
2+
//
3+
// Copyright:
4+
// Copyright 2023 Frequenz Energy-as-a-Service GmbH
5+
//
6+
// License:
7+
// MIT
8+
9+
syntax = "proto3";
10+
11+
package frequenz.api.common.v1.metrics;
12+
13+
// A set of lower and upper bounds for any metric.
14+
// The units of the bounds are always the same as the related metric.
15+
message Bounds {
16+
// The lower bound.
17+
// If absent, there is no lower bound.
18+
optional float lower = 1;
19+
20+
// The upper bound.
21+
// If absent, there is no upper bound.
22+
optional float upper = 2;
23+
}

proto/frequenz/api/common/v1/metrics/electrical.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ syntax = "proto3";
1010

1111
package frequenz.api.common.v1.metrics.electrical;
1212

13-
import "frequenz/api/common/v1/metrics.proto";
13+
import "frequenz/api/common/v1/metrics/metric_sample.proto";
1414

1515
// Metrics of a DC electrical connection.
1616
message DC {

proto/frequenz/api/common/v1/metrics.proto renamed to proto/frequenz/api/common/v1/metrics/metric_sample.proto

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Metrics & bounds definitions.
1+
// Metrics definitions.
22
//
33
// Copyright:
44
// Copyright 2023 Frequenz Energy-as-a-Service GmbH
@@ -10,19 +10,9 @@ syntax = "proto3";
1010

1111
package frequenz.api.common.v1.metrics;
1212

13-
import "google/protobuf/timestamp.proto";
14-
15-
// A set of lower and upper bounds for any metric.
16-
// The units of the bounds are always the same as the related metric.
17-
message Bounds {
18-
// The lower bound.
19-
// If absent, there is no lower bound.
20-
optional float lower = 1;
13+
import "frequenz/api/common/v1/metrics/bounds.proto";
2114

22-
// The upper bound.
23-
// If absent, there is no upper bound.
24-
optional float upper = 2;
25-
}
15+
import "google/protobuf/timestamp.proto";
2616

2717
// Represents a single sample of a specific metric, the value of which is either
2818
// measured or derived at a particular time.

proto/frequenz/api/common/v1/microgrid/components/components.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ syntax = "proto3";
1010

1111
package frequenz.api.common.v1.microgrid.components;
1212

13-
import "frequenz/api/common/v1/metrics.proto";
13+
import "frequenz/api/common/v1/metrics/metric_sample.proto";
1414
import "frequenz/api/common/v1/microgrid/components/battery.proto";
1515
import "frequenz/api/common/v1/microgrid/components/ev_charger.proto";
1616
import "frequenz/api/common/v1/microgrid/components/fuse.proto";

proto/frequenz/api/common/v1/microgrid/microgrid.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ message Microgrid {
5454
frequenz.api.common.v1.grid.DeliveryArea delivery_area = 4;
5555

5656
// Physical location of the microgrid, in geographical co-ordinates.
57-
frequenz.api.common.v1.location.Location location = 5;
57+
frequenz.api.common.v1.Location location = 5;
5858

5959
// The current status of the microgrid.
6060
MicrogridStatus status = 6;

proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ syntax = "proto3";
1010

1111
package frequenz.api.common.v1.microgrid.sensors;
1212

13-
import "frequenz/api/common/v1/metrics.proto";
13+
import "frequenz/api/common/v1/metrics/metric_sample.proto";
1414
import "frequenz/api/common/v1/microgrid/lifetime.proto";
1515

1616
import "google/protobuf/timestamp.proto";

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+
}

0 commit comments

Comments
 (0)