File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -246,3 +246,40 @@ async def take_action(
246
246
)
247
247
248
248
return result
249
+
250
+
251
+ class AbortRequestModel (OPModel ):
252
+ message : str = Field ("Action aborted" , title = "Message" )
253
+
254
+
255
+ @router .post ("/abort/{token}" )
256
+ async def abort_action (
257
+ request : AbortRequestModel ,
258
+ token : str = Path (
259
+ ...,
260
+ title = "Action Token" ,
261
+ pattern = r"[a-f0-9]{64}" ,
262
+ ),
263
+ ) -> None :
264
+ """called by launcher
265
+
266
+ This is called by the launcher to abort an action.
267
+ """
268
+
269
+ res = await Postgres .fetch (
270
+ """
271
+ UPDATE events SET status = 'aborted', description = $2
272
+ WHERE
273
+ hash = $1
274
+ AND topic = 'action.launcher'
275
+ AND status IN ('pending', 'in_progress')
276
+ RETURNING *
277
+ """ ,
278
+ token ,
279
+ request .message ,
280
+ )
281
+
282
+ if not res :
283
+ raise NotFoundException ("Invalid token" )
284
+
285
+ return None
You can’t perform that action at this time.
0 commit comments