3737from st2common .models .api .action import LiveActionAPI
3838from st2common .models .api .action import LiveActionCreateAPI
3939from st2common .models .api .base import jsexpose
40+ from st2common .models .api .base import cast_argument_value
4041from st2common .models .api .execution import ActionExecutionAPI
4142from st2common .persistence .liveaction import LiveAction
4243from st2common .persistence .execution import ActionExecution
@@ -276,22 +277,25 @@ def validate(self):
276277 return self
277278
278279 @jsexpose (body_cls = ExecutionSpecificationAPI , status_code = http_client .CREATED )
279- def post (self , spec , execution_id ):
280+ def post (self , spec_api , execution_id , no_merge = False ):
280281 """
281282 Re-run the provided action execution optionally specifying override parameters.
282283
283284 Handles requests:
284285
285286 POST /executions/<id>/re_run
286287 """
288+ no_merge = cast_argument_value (value_type = bool , value = no_merge )
287289 existing_execution = self ._get_one (id = execution_id , exclude_fields = self .exclude_fields )
288290
289- if spec .tasks and existing_execution .runner ['name' ] != 'mistral-v2' :
291+ if spec_api .tasks and existing_execution .runner ['name' ] != 'mistral-v2' :
290292 raise ValueError ('Task option is only supported for Mistral workflows.' )
291293
292294 # Merge in any parameters provided by the user
293- new_parameters = copy .deepcopy (getattr (existing_execution , 'parameters' , {}))
294- new_parameters .update (spec .parameters )
295+ new_parameters = {}
296+ if not no_merge :
297+ new_parameters .update (getattr (existing_execution , 'parameters' , {}))
298+ new_parameters .update (spec_api .parameters )
295299
296300 # Create object for the new execution
297301 action_ref = existing_execution .action ['ref' ]
@@ -303,11 +307,11 @@ def post(self, spec, execution_id):
303307 }
304308 }
305309
306- if spec .tasks :
307- context ['re-run' ]['tasks' ] = spec .tasks
310+ if spec_api .tasks :
311+ context ['re-run' ]['tasks' ] = spec_api .tasks
308312
309- if spec .reset :
310- context ['re-run' ]['reset' ] = spec .reset
313+ if spec_api .reset :
314+ context ['re-run' ]['reset' ] = spec_api .reset
311315
312316 # Add trace to the new execution
313317 trace = trace_service .get_trace_db_by_action_execution (
@@ -319,7 +323,7 @@ def post(self, spec, execution_id):
319323 new_liveaction_api = LiveActionCreateAPI (action = action_ref ,
320324 context = context ,
321325 parameters = new_parameters ,
322- user = spec .user )
326+ user = spec_api .user )
323327
324328 return self ._handle_schedule_execution (liveaction_api = new_liveaction_api )
325329
0 commit comments