MCPcopy Create free account
hub / github.com/StackStorm/st2 / create_shadow_trigger

Function create_shadow_trigger

st2common/st2common/services/triggers.py:399–428  ·  view source on GitHub ↗

Create a shadow trigger for TriggerType with no parameters. :param log_not_unique_error_as_debug: True to lot NotUnique errors under debug instead of error log level. This is to be used in scenarios where f

(trigger_type_db, log_not_unique_error_as_debug=False)

Source from the content-addressed store, hash-verified

397
398
399def create_shadow_trigger(trigger_type_db, log_not_unique_error_as_debug=False):
400 """
401 Create a shadow trigger for TriggerType with no parameters.
402
403 :param log_not_unique_error_as_debug: True to lot NotUnique errors under debug instead of
404 error log level. This is to be used in scenarios where
405 failure is non-fatal (e.g. when services register
406 internal trigger types which is an idempotent
407 operation).
408 :type log_not_unique_error_as_debug: ``bool``
409
410 """
411 trigger_type_ref = trigger_type_db.get_reference().ref
412
413 if trigger_type_db.parameters_schema:
414 LOG.debug(
415 "Skip shadow trigger for TriggerType with parameters %s.", trigger_type_ref
416 )
417 return None
418
419 trigger = {
420 "name": trigger_type_db.name,
421 "pack": trigger_type_db.pack,
422 "type": trigger_type_ref,
423 "parameters": {},
424 }
425
426 return create_or_update_trigger_db(
427 trigger, log_not_unique_error_as_debug=log_not_unique_error_as_debug
428 )
429
430
431def create_or_update_trigger_type_db(trigger_type, log_not_unique_error_as_debug=False):

Callers 1

Calls 2

get_referenceMethod · 0.45

Tested by

no test coverage detected