Skip to content

Commit 2d6d300

Browse files
authored
Use oneof in recurrence filter (#188)
- **Use `oneof` for recurrence filter** - **Fix release notes formatting & phrasing** fixes #161
2 parents 7c8f726 + 9e1985e commit 2d6d300

File tree

2 files changed

+77
-33
lines changed

2 files changed

+77
-33
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ In this release, we have made some changes to the API to improve the user experi
2222
* Add YEARLY frequency to the recurrence definition.
2323
* Add parameters for pagination and sorting.
2424
* Documentation of valid values for `count` and `interval` fields was added.
25-
* Extended filter parameters for recurrence and end time.
26-
* Add new field end\_time to the DispatchDetail.
25+
* Extended `DispatchFilter` to support filtering by `recurrence` and `end_time`.
26+
* Add new field `end_time` to the `DispatchDetail`.
2727

2828
## Bug Fixes
2929

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

Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,44 @@ message TimeIntervalFilter {
201201

202202
// Parameters for filtering the dispatch list
203203
message DispatchFilter {
204+
// Recurrence filters
205+
//
206+
// The fields are left commented out for now as the exact definition and requirements
207+
// for recurrence filtering are still being finalized.
204208
message RecurrenceFilter {
205-
// Filter by recurring status
206-
// True: Only recurring dispatches will be returned.
207-
// False: Only non-recurring dispatches will be returned.
208-
// Unset: Both recurring and non-recurring dispatches will be returned,
209-
// recurring dispatches will be filtered based on the recurrence
210-
// filter, while non-recurring dispatches will be returned regardless.
211-
// Examples:
212-
// - To retrieve only recurring dispatches:
213-
// filter { recurrence_filter { is_recurring: true } }
214-
// - To retrieve only non-recurring dispatches:
215-
// filter { recurrence_filter { is_recurring: false } }
216-
// - To retrieve all dispatches:
217-
// filter { recurrence_filter {} }
218-
// - To retrieve only recurring dispatches with a specific frequency:
219-
// filter { recurrence_filter { is_recurring: true, freq: [FREQUENCY_DAILY] } }
220-
// - To retrieve only recurring dispatches with a specific frequency but
221-
// also include non-recurring dispatches:
222-
// filter { recurrence_filter { freq: [FREQUENCY_DAILY] } }
223-
224-
// - only_recurring = true: Only recurring dispatches will be returned.
225-
optional bool is_recurring = 1;
226-
227-
// Filter by frequency
228-
// If not specified, all frequencies will be returned.
229-
repeated RecurrenceRule.Frequency freqs = 2;
209+
// The frequency specifier of this recurring dispatch
210+
//optional RecurrenceRule.Frequency freq = 1;
211+
212+
//// How often this dispatch should recur, based on the frequency
213+
//// Example:
214+
//// - Every 2 hours:
215+
//// freq = FREQUENCY_HOURLY
216+
//// interval = 2
217+
//// Valid values typically range between 1 and 10_000, depending on the implementation.
218+
//optional uint32 interval = 2;
219+
220+
//// When this dispatch should end.
221+
//// A dispatch can either recur a fixed number of times, or until a given timestamp.
222+
//// If this field is not set, the dispatch will recur indefinitely.
223+
//optional EndCriteria end_criteria = 3;
224+
225+
//// On which minute(s) of the hour does the event occur
226+
//repeated uint32 byminutes = 4;
227+
228+
//// On which hour(s) of the day does the event occur
229+
//repeated uint32 byhours = 5;
230+
231+
//// On which day(s) of the week does the event occur
232+
//repeated RecurrenceRule.Weekday byweekdays = 6;
233+
234+
//// On which day(s) of the month does the event occur. Valid values are 1 to 31 or -31 to -1.
235+
////
236+
//// For example, -10 represents the tenth to the last day of the month.
237+
//// The bymonthdays rule part MUST NOT be specified when the FREQ rule part is set to WEEKLY.
238+
//repeated int32 bymonthdays = 7;
239+
240+
//// On which month(s) of the year does the event occur
241+
//repeated uint32 bymonths = 8;
230242
}
231243

232244
// Optional filter by component ID or category.
@@ -240,20 +252,52 @@ message DispatchFilter {
240252
// If this field is not set, dispatches of any dry run status will be included.
241253
optional bool is_dry_run = 3;
242254

243-
// Optional recurrence filter
244-
// If not specified both types will be returned.
245-
RecurrenceFilter recurrence_filter = 4;
255+
// Optional filter by recurrence fields.
256+
oneof recurrence {
257+
// Filter by recurring status
258+
// True: Only recurring dispatches will be returned.
259+
// False: Only non-recurring dispatches will be returned.
260+
// Examples:
261+
// - To retrieve only recurring dispatches:
262+
// filter { recurrence { is_recurring: true } }
263+
// - To retrieve only non-recurring dispatches:
264+
// filter { recurrence { is_recurring: false } }
265+
// - To retrieve all dispatches:
266+
// filter { recurrence {} }
267+
// For advanced recurrence filtering, use the `filter` field.
268+
bool is_recurring = 4;
269+
270+
// Filter by recurrence details
271+
// Examples:
272+
// - To retrieve only recurring dispatches with a specific frequency:
273+
// filter { recurrence { filter { freq: FREQUENCY_DAILY } } }
274+
// - To retrieve recurring dispatches with a specific frequency and interval:
275+
// filter { recurrence { filter { freq: FREQUENCY_HOURLY, interval: 2 } } }
276+
// - To retrieve recurring dispatches that end after a specific criteria:
277+
// filter { recurrence { filter { end_criteria: { count: 10 } } } }
278+
// - To retrieve recurring dispatches at specific minutes of the hour:
279+
// filter { recurrence { filter { byminutes: [0, 15, 30, 45] } } }
280+
// - To retrieve recurring dispatches at specific hours of the day:
281+
// filter { recurrence { filter { byhours: [8, 12, 16] } } }
282+
// - To retrieve recurring dispatches on specific days of the week:
283+
// filter { recurrence { filter { byweekdays: [WEEKDAY_MONDAY, WEEKDAY_WEDNESDAY] } } }
284+
// - To retrieve recurring dispatches on specific days of the month:
285+
// filter { recurrence { filter { bymonthdays: [1, 15, 30, -1] } } }
286+
// - To retrieve recurring dispatches in specific months of the year:
287+
// filter { recurrence { filter { bymonths: [1, 6, 12] } } }
288+
RecurrenceFilter filter = 5;
289+
}
246290

247291
// Optional filter by start time.
248292
// If no interval is provided, all dispatches will be returned.
249-
TimeIntervalFilter start_time_interval = 5;
293+
TimeIntervalFilter start_time_interval = 6;
250294

251295
// Optional filter by end time
252296
// Filter dispatches based on their explicit end time.
253-
TimeIntervalFilter end_time_interval = 6;
297+
TimeIntervalFilter end_time_interval = 7;
254298

255299
// Optional filter by update time
256-
TimeIntervalFilter update_time_interval = 7;
300+
TimeIntervalFilter update_time_interval = 8;
257301
}
258302

259303
// Parameter for controlling which components a dispatch applies to

0 commit comments

Comments
 (0)