@@ -53,63 +53,60 @@ import "frequenz/api/common/v1/microgrid/components/components.proto";
5353// This API is designed for application developers in the energy sector who focus on the tasks of optimizing microgrid
5454// electricity flows. Its design aims to be as developer-friendly as possible, requiring no prior knowledge in
5555// electrical engineering and systems.
56+ //
57+ // #### Security
58+ //
59+ // ALL requests to this service must be signed. The key and signature
60+ // should be added to the request metadata (HTTP headers). The signature
61+ // should be computed using the HMAC-SHA256 algorithm and the user's secret key.
62+ //
63+ // ALL requests to this service must be made over HTTPS.
5664service MicrogridDispatchService {
5765 // Returns a list of all dispatches
58- rpc ListMicrogridDispatches (DispatchListRequest ) returns (DispatchList );
66+ rpc ListMicrogridDispatches (ListMicrogridDispatchesRequest ) returns (ListMicrogridDispatchesResponse );
5967
6068 // Create a new dispatch
61- rpc CreateMicrogridDispatch (DispatchCreateRequest ) returns (google . protobuf . Empty );
69+ rpc CreateMicrogridDispatch (CreateMicrogridDispatchRequest ) returns (CreateMicrogridDispatchResponse );
6270
6371 // Update a dispatch
64- rpc UpdateMicrogridDispatch (DispatchUpdateRequest ) returns (google . protobuf . Empty );
72+ rpc UpdateMicrogridDispatch (UpdateMicrogridDispatchRequest ) returns (UpdateMicrogridDispatchResponse );
6573
6674 // Get a single dispatch
67- rpc GetMicrogridDispatch (DispatchGetRequest ) returns (Dispatch );
75+ rpc GetMicrogridDispatch (GetMicrogridDispatchRequest ) returns (GetMicrogridDispatchResponse );
6876
6977 // Delete a given dispatch
70- rpc DeleteMicrogridDispatch (DispatchDeleteRequest ) returns (google . protobuf . Empty );
78+ rpc DeleteMicrogridDispatch (DeleteMicrogridDispatchRequest ) returns (DeleteMicrogridDispatchResponse );
7179}
7280
73- // Message representing one dispatch.
81+ // Represents a dispatches data, including its type, start time, duration, component selector,
7482//
7583// Timezone Note: Timestamps are in UTC. It is the responsibility of each microgrid to translate UTC
7684// to its local timezone.
7785message Dispatch {
78- // The dispatch identifier
79- uint64 id = 1 ;
80-
81- // The microgrid identifier
82- uint64 microgrid_id = 2 ;
83-
8486 // The dispatch type.
8587 // Contains user-defined information about what "type" of dispatch this is.
8688 // Downstream applications that consume the dispatch API are responsible for
8789 // understanding and processing this field.
88- string type = 3 ;
89-
90- // The creation time in UTC
91- // This is set when a dispatch is created via the create request message
92- google.protobuf.Timestamp create_time = 4 ;
93-
94- // The update time in UTC
95- // This is set when a dispatch is modified via the update request message
96- google.protobuf.Timestamp update_time = 5 ;
90+ string type = 1 ;
9791
98- // The start time in UTC
99- google.protobuf.Timestamp start_time = 6 ;
92+ // The dispatch start time in UTC.
93+ // For reoccuring dispatches this is when the first time execution occurs. When
94+ // creating a dispatch, ensure that the starting timestamp is set to the current
95+ // time or any future time. Timestamps earlier than the current time are not allowed.
96+ google.protobuf.Timestamp start_time = 2 ;
10097
10198 // Duration in seconds
102- uint32 duration = 7 ;
99+ optional uint32 duration = 3 ;
103100
104- // The component selector
105- ComponentSelector selector = 8 ;
101+ // Dispatch microgrid component selector
102+ ComponentSelector selector = 4 ;
106103
107104 // The "active" status
108105 // An active dispatch is eligible for processing, either immediately or at a scheduled
109106 // time in the future, including recurring dispatches. If a dispatch is set to
110107 // inactive, it won't be processed even if it matches all other conditions, allowing
111108 // for temporary disabling of dispatches without deletion.
112- bool is_active = 9 ;
109+ bool is_active = 5 ;
113110
114111 // The "dry run" status
115112 // A dry run dispatch is executed for logging and monitoring purposes
@@ -118,13 +115,28 @@ message Dispatch {
118115 // actually affecting any component states.
119116 // Notably, a dispatch can be both "dry run" and "active," allowing for
120117 // the system to generate logs and observe behavior without making actual changes.
121- bool is_dry_run = 10 ;
118+ bool is_dry_run = 6 ;
122119
123120 // The dispatch payload
124- google.protobuf.Struct payload = 11 ;
121+ google.protobuf.Struct payload = 7 ;
125122
126123 // The recurrence rule
127- RecurrenceRule recurrence = 12 ;
124+ RecurrenceRule recurrence = 8 ;
125+ }
126+
127+ // Represents a dispatch, including its metadata
128+ message DispatchDetail {
129+ // Unique identifier of the microgrid dispatch.
130+ uint64 dispatch_id = 1 ;
131+
132+ // The dispatch data
133+ Dispatch dispatch = 2 ;
134+
135+ // UTC Timestamp when the order was created.
136+ google.protobuf.Timestamp create_time = 3 ;
137+
138+ // UTC Timestamp of the last update to the order.
139+ google.protobuf.Timestamp modification_time = 4 ;
128140}
129141
130142// Filter parameter for specifying multiple time intervals
@@ -287,7 +299,7 @@ message RecurrenceRule {
287299}
288300
289301// Message for listing dispatches for a given microgrid, and an optional filter
290- message DispatchListRequest {
302+ message ListMicrogridDispatchesRequest {
291303 // The microgrid ID
292304 uint64 microgrid_id = 1 ;
293305
@@ -315,46 +327,28 @@ message DispatchFilter {
315327}
316328
317329// A list of dispatches
318- message DispatchList {
330+ message ListMicrogridDispatchesResponse {
319331 // The dispatches
320- repeated Dispatch dispatches = 1 ;
332+ repeated DispatchDetail dispatches = 1 ;
321333}
322334
323335// Message to create a new dispatch with the given attributes
324- message DispatchCreateRequest {
336+ message CreateMicrogridDispatchRequest {
325337 // The microgrid identifier
326338 uint64 microgrid_id = 1 ;
327339
328- // The type of dispatch
329- string type = 2 ;
330-
331- // The start time
332- // When creating a dispatch, ensure that the starting timestamp is set to
333- // the current time or any future time.
334- // Timestamps earlier than the current time are not allowed.
335- google.protobuf.Timestamp start_time = 3 ;
336-
337- // Duration in seconds
338- uint32 duration = 4 ;
339-
340- // The component selector
341- ComponentSelector selector = 5 ;
342-
343- // The "active" status
344- bool is_active = 6 ;
345-
346- // The "dry run" status
347- bool is_dry_run = 7 ;
348-
349- // The dispatch payload
350- google.protobuf.Struct payload = 8 ;
340+ // Content of the dispatch to be created
341+ Dispatch dispatch = 2 ;
342+ }
351343
352- // The recurrence rule
353- RecurrenceRule recurrence = 9 ;
344+ // Response message for creating a new dispatch
345+ message CreateMicrogridDispatchResponse {
346+ // The created dispatch
347+ DispatchDetail dispatch = 1 ;
354348}
355349
356350// Message to update the dispatch with the given ID, with the given attributes
357- message DispatchUpdateRequest {
351+ message UpdateMicrogridDispatchRequest {
358352 // Message containing the updated dispatch attributes
359353 message DispatchUpdate {
360354 // Message containing the updated recurrence rule attributes
@@ -384,52 +378,79 @@ message DispatchUpdateRequest {
384378 repeated uint32 bymonths = 8 ;
385379 }
386380
387- // The type of dispatch
388- optional string type = 1 ;
389-
390381 // The start time
391382 // When updating a dispatch, ensure that the starting timestamp is set to
392383 // the current time or any future time.
393384 // Timestamps earlier than the current time are not allowed.
394- google.protobuf.Timestamp start_time = 2 ;
385+ google.protobuf.Timestamp start_time = 1 ;
395386
396387 // Duration in seconds
397- optional uint32 duration = 3 ;
388+ optional uint32 duration = 2 ;
398389
399390 // The component selector
400- ComponentSelector selector = 4 ;
391+ ComponentSelector selector = 3 ;
401392
402393 // The "active" status
403- optional bool is_active = 5 ;
404-
405- // The "dry run" status
406- optional bool is_dry_run = 6 ;
394+ optional bool is_active = 4 ;
407395
408396 // The dispatch payload
409- google.protobuf.Struct payload = 7 ;
397+ google.protobuf.Struct payload = 5 ;
410398
411399 // The recurrence rule
412- RecurrenceRuleUpdate recurrence = 8 ;
400+ RecurrenceRuleUpdate recurrence = 6 ;
413401 }
414402
403+ // ID of the microgrid
404+ uint64 microgrid_id = 1 ;
405+
415406 // The dispatch identifier
416- uint64 id = 1 ;
407+ uint64 dispatch_id = 2 ;
417408
418409 // Field mask specifying which fields should be updated
419- google.protobuf.FieldMask update_mask = 2 ;
410+ google.protobuf.FieldMask update_mask = 3 ;
420411
421412 // The updated dispatch attributes
422- DispatchUpdate update = 3 ;
413+ DispatchUpdate update = 4 ;
414+ }
415+
416+ // Response message for updating a dispatch
417+ message UpdateMicrogridDispatchResponse {
418+ // The updated dispatch
419+ DispatchDetail dispatch = 1 ;
423420}
424421
425422// Message to get a single dispatch by its ID
426- message DispatchGetRequest {
423+ message GetMicrogridDispatchRequest {
424+ // The microgrid ID that the dispatch belongs to
425+ uint64 microgrid_id = 1 ;
426+
427427 // The dispatch identifier
428- uint64 id = 1 ;
428+ uint64 dispatch_id = 2 ;
429+ }
430+
431+ // Response message for getting a single dispatch
432+ message GetMicrogridDispatchResponse {
433+ // The microgrid ID that the dispatch belongs to
434+ uint64 microgrid_id = 1 ;
435+
436+ // The dispatch
437+ DispatchDetail dispatch = 2 ;
429438}
430439
431440// Message to delete a single dispatch by its ID
432- message DispatchDeleteRequest {
441+ message DeleteMicrogridDispatchRequest {
442+ // The microgrid ID that the dispatch belongs to
443+ uint64 microgrid_id = 1 ;
444+
433445 // The dispatch identifier
434- uint64 id = 1 ;
446+ uint64 dispatch_id = 2 ;
447+ }
448+
449+ // Response message for deleting a single dispatch
450+ message DeleteMicrogridDispatchResponse {
451+ // The microgrid ID that the dispatch belonged to
452+ uint64 microgrid_id = 1 ;
453+
454+ // The dispatch ID that was deleted
455+ uint64 dispatch_id = 2 ;
435456}
0 commit comments