Skip to content

Commit 5e9e56d

Browse files
Change settings to payload and use google protobuf Struct (#19)
2 parents 67e2fac + e1f255d commit 5e9e56d

File tree

5 files changed

+55
-125
lines changed

5 files changed

+55
-125
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Release notes
22

3-
- Added python module & test case for submodule `fcr`.
3+
- The `FcrPrequalificationSettings` message has been removed, and settings
4+
fields have been modified/reverted to use protobuf Structs, in order to
5+
represent arbitrary JSON objects.

proto/frequenz/api/dispatch/dispatch.proto

Lines changed: 52 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ package frequenz.api.dispatch;
1414

1515
import "google/api/annotations.proto";
1616
import "google/protobuf/empty.proto";
17+
import "google/protobuf/struct.proto";
1718
import "google/protobuf/timestamp.proto";
1819

1920
import "frequenz/api/common/components.proto";
2021

21-
import "frequenz/api/dispatch/fcr/prequalification.proto";
22-
2322
service DispatchService {
2423
// Returns a list of all dispatches
2524
rpc ListDispatches(DispatchFilter) returns (DispatchList) {
@@ -43,47 +42,40 @@ service DispatchService {
4342
}
4443
}
4544

46-
// Possible dispatch types
47-
enum DispatchType {
48-
// Unspecified dispatch type, used mainly for error handling
49-
DISPATCH_TYPE_UNSPECIFIED = 0;
50-
51-
// Shutdown dispatch event
52-
DISPATCH_TYPE_SHUTDOWN = 1;
53-
54-
// Charge battery dispatch event
55-
DISPATCH_TYPE_BATTERY_CHARGE = 2;
45+
// Message representing one dispatch
46+
message Dispatch {
47+
// The dispatch identifier
48+
uint64 id = 1;
5649

57-
// Discharge battery dispatch event
58-
DISPATCH_TYPE_BATTERY_DISCHARGE = 3;
50+
// The microgrid identifier
51+
uint64 microgrid_id = 2;
5952

60-
// Frequency containment reserve dispatch event
61-
DISPATCH_TYPE_FCR = 4;
53+
// The dispatch type.
54+
// Contains user-defined information about what "type" of dispatch this is.
55+
// Downstream applications that consume the dispatch API are responsible for
56+
// understanding and processing this field.
57+
string type = 3;
6258

63-
// FCR prequalification, charge test
64-
DISPATCH_TYPE_FCR_PREQUALIFICATION_CHARGE = 5;
59+
// The start time
60+
google.protobuf.Timestamp start_time = 4;
6561

66-
// FCR prequalification, discharge test
67-
DISPATCH_TYPE_FCR_PREQUALIFICATION_DISCHARGE = 6;
62+
// The end time
63+
google.protobuf.Timestamp end_time = 5;
6864

69-
// FCR prequalification, cancellation of a charge and discharge test
70-
// for a given battery
71-
DISPATCH_TYPE_FCR_PREQUALIFICATION_CANCEL = 7;
72-
}
65+
// The component selector
66+
DispatchComponentSelector selector = 6;
7367

74-
// Possible dispatch statuses
75-
enum DispatchStatus {
76-
// Unspecified dispatch status, used mainly for error handling
77-
DISPATCH_STATUS_UNSPECIFIED = 0;
68+
// The creation time
69+
google.protobuf.Timestamp create_time = 7;
7870

79-
// Active dispatch status
80-
DISPATCH_STATUS_ACTIVE = 1;
71+
// The "active" status
72+
bool is_active = 8;
8173

82-
// Inactive dispatch status
83-
DISPATCH_STATUS_INACTIVE = 2;
74+
// The "dry run" status
75+
bool is_dry_run = 9;
8476

85-
// Simulated dispatch status
86-
DISPATCH_STATUS_SIMULATE = 3;
77+
// The dispatch payload
78+
google.protobuf.Struct payload = 10;
8779
}
8880

8981
// Filter parameter for specifying multiple time intervals
@@ -128,51 +120,22 @@ message DispatchFilter {
128120
repeated uint64 microgrid_ids = 2;
129121

130122
// Filter by dispatch type
131-
repeated DispatchType types = 3;
123+
repeated string types = 3;
132124

133125
// Filter by component ID or category
134126
repeated DispatchComponentSelector selectors = 4;
135127

136128
// Filter by time interval
137129
TimeIntervalFilter time_interval = 5;
138-
}
139130

140-
message DispatchSettings {
141-
oneof settings {
142-
fcr.prequalification.FcrPrequalificationSettings fcr_prequalification = 1;
143-
}
144-
}
145-
146-
// Message representing one dispatch
147-
message Dispatch {
148-
// The dispatch identifier
149-
uint64 id = 1;
131+
// Filter by "active" status
132+
optional bool is_active = 6;
150133

151-
// The microgrid identifier
152-
uint64 microgrid_id = 2;
153-
154-
// The type of dispatch
155-
DispatchType type = 3;
156-
157-
// The start time
158-
google.protobuf.Timestamp start_time = 4;
159-
160-
// The end time
161-
google.protobuf.Timestamp end_time = 5;
162-
163-
// The component selector
164-
DispatchComponentSelector selector = 6;
165-
166-
// The creation time
167-
google.protobuf.Timestamp create_time = 7;
168-
169-
// The dispatch status
170-
DispatchStatus status = 8;
171-
172-
// The dispatch settings
173-
DispatchSettings settings = 9;
134+
// Filter by "dry run" status
135+
optional bool is_dry_run = 7;
174136
}
175137

138+
176139
// A list of dispatches
177140
message DispatchList {
178141
// The dispatches
@@ -185,7 +148,7 @@ message DispatchCreateRequest {
185148
uint64 microgrid_id = 1;
186149

187150
// The type of dispatch
188-
DispatchType type = 2;
151+
string type = 2;
189152

190153
// The start time
191154
google.protobuf.Timestamp start_time = 3;
@@ -196,11 +159,14 @@ message DispatchCreateRequest {
196159
// The component selector
197160
DispatchComponentSelector selector = 5;
198161

199-
// The dispatch status
200-
DispatchStatus status = 6;
162+
// The "active" status
163+
bool is_active = 6;
201164

202-
// The dispatch settings
203-
DispatchSettings settings = 7;
165+
// The "dry run" status
166+
bool is_dry_run = 7;
167+
168+
// The dispatch payload
169+
google.protobuf.Struct payload = 8;
204170
}
205171

206172
// Message to update the dispatch with the given ID, with the given attributes
@@ -212,23 +178,26 @@ message DispatchUpdateRequest {
212178
optional uint64 microgrid_id = 2;
213179

214180
// The type of dispatch
215-
optional DispatchType type = 3;
181+
optional string type = 3;
216182

217183
// The start time
218-
optional google.protobuf.Timestamp start_time = 4;
184+
google.protobuf.Timestamp start_time = 4;
219185

220186
// The end time
221-
optional google.protobuf.Timestamp end_time = 5;
187+
google.protobuf.Timestamp end_time = 5;
222188

223189
// The component selector
224-
optional DispatchComponentSelector selector = 6;
190+
DispatchComponentSelector selector = 6;
225191

226192
// The creation time
227-
optional google.protobuf.Timestamp create_time = 7;
193+
google.protobuf.Timestamp create_time = 7;
194+
195+
// The "active" status
196+
optional bool is_active = 8;
228197

229-
// The dispatch status
230-
optional DispatchStatus status = 8;
198+
// The "dry run" status
199+
optional bool is_dry_run = 9;
231200

232-
// The dispatch settings
233-
optional DispatchSettings settings = 9;
201+
// The dispatch payload
202+
google.protobuf.Struct payload = 10;
234203
}

proto/frequenz/api/dispatch/fcr/prequalification.proto

Lines changed: 0 additions & 25 deletions
This file was deleted.

py/frequenz/api/dispatch/fcr/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

pytests/test_dispatch.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,3 @@ def test_module_import() -> None:
2323
from frequenz.api.dispatch import dispatch_pb2_grpc
2424

2525
assert dispatch_pb2_grpc is not None
26-
27-
28-
def test_fcr_pq_import() -> None:
29-
"""Test that the FCR prequalification sub module can be imported."""
30-
# pylint: disable=import-outside-toplevel
31-
from frequenz.api.dispatch.fcr import prequalification_pb2
32-
33-
assert prequalification_pb2 is not None
34-
35-
# pylint: disable=import-outside-toplevel
36-
from frequenz.api.dispatch.fcr import prequalification_pb2_grpc
37-
38-
assert prequalification_pb2_grpc is not None

0 commit comments

Comments
 (0)