Skip to content

Commit

Permalink
Client: ScheduleEventSubscription should accept more than one schedul…
Browse files Browse the repository at this point in the history
…e id (#12691)

GitOrigin-RevId: 659d1310c4ca5890b2d71d6911995c90ccaf8436
  • Loading branch information
stephencpope authored and Descartes Labs Build committed Oct 4, 2024
1 parent 3dc6b8c commit 938ec51
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions descarteslabs/core/catalog/event_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,23 @@ class ScheduledEventSubscription(EventSubscription):

_derived_type = "scheduled_event_subscription"

def __init__(self, event_schedule_id: str, **kwargs):
def __init__(self, *event_schedule_ids, **kwargs):
"""Create an EventSubscription for a scheduled event.
Parameters
----------
event_schedule_ids : str
The ids of one or more scheduled event to subscribe to (as separate positional arguments).
Plus any additional keyword arguments to pass to the EventSubscription constructor.
"""
if not event_schedule_ids:
raise TypeError(
"At least one EventSchedule id must be provided as a positional argument"
)
if any(not isinstance(id, str) for id in event_schedule_ids):
raise TypeError("All EventSchedule ids must be strings")

kwargs["event_source"] = ["scheduler"]
kwargs["event_type"] = ["scheduled"]
kwargs["event_namespace"] = [event_schedule_id]
kwargs["event_namespace"] = event_schedule_ids
super().__init__(**kwargs)

0 comments on commit 938ec51

Please sign in to comment.