@@ -80,7 +80,8 @@ def create_schedules(
80
80
scheduled_at = None ,
81
81
data = {},
82
82
actor = None ,
83
- tenant = None ):
83
+ tenant = None ,
84
+ ending_at = None ):
84
85
"""
85
86
Creates schedules for recipients.
86
87
@@ -96,11 +97,14 @@ def create_schedules(
96
97
97
98
data (dict): Any data to be passed to the scheduled trigger call.
98
99
99
- scheduled_at (datetime): Date when the schedule must start
100
+ scheduled_at (datetime): Date when the schedule must start.
100
101
101
102
tenant (str | dict[str, Any]): An optional reference for the tenant that the notifications belong to. This can be A) a tenant
102
103
id, B) an object reference without the collection, or C) a dictionary with data to identify a tenant.
103
104
105
+ ending_at (datetime, optional): The date when the schedule should end. For recurring schedules,
106
+ no further executions will occur after this time.
107
+
104
108
Returns:
105
109
list[dict]: list of created schedules
106
110
"""
@@ -112,10 +116,15 @@ def create_schedules(
112
116
'repeats' : repeats ,
113
117
'actor' : actor ,
114
118
'data' : data ,
115
- 'tenant' : tenant ,
116
- 'scheduled_at' : scheduled_at .isoformat ()
119
+ 'tenant' : tenant
117
120
}
118
121
122
+ if scheduled_at :
123
+ params ['scheduled_at' ] = scheduled_at .isoformat ()
124
+
125
+ if ending_at :
126
+ params ['ending_at' ] = ending_at .isoformat ()
127
+
119
128
return self .client .request ("post" , endpoint , payload = params )
120
129
121
130
def update_schedules (
@@ -128,13 +137,22 @@ def update_schedules(
128
137
Args:
129
138
schedule_ids (list[str]): the ids of the schedules to be updated (max 100)
130
139
131
- schedule_attrs (dict): Schedule attributes to be updated, these can be: repeats, actor, data and tenant.
140
+ schedule_attrs (dict): Schedule attributes to be updated. These can include:
141
+ - repeats: Schedule repeat configuration
142
+ - actor: Who/what performed the action
143
+ - data: Any data to be passed to the scheduled trigger
144
+ - tenant: The tenant that the notifications belong to
145
+ - ending_at (datetime): The date when the schedule should end
132
146
133
147
Returns:
134
148
list[dict]: list of updated schedules
135
149
"""
136
150
endpoint = '/schedules'
137
151
152
+ # Convert ending_at to ISO format if present
153
+ if 'ending_at' in schedule_attrs and schedule_attrs ['ending_at' ]:
154
+ schedule_attrs ['ending_at' ] = schedule_attrs ['ending_at' ].isoformat ()
155
+
138
156
schedule_attrs ['schedule_ids' ] = schedule_ids
139
157
140
158
return self .client .request ("put" , endpoint , payload = schedule_attrs )
0 commit comments