本文整理汇总了Python中st2common.persistence.trigger.TriggerType.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python TriggerType.get_by_name方法的具体用法?Python TriggerType.get_by_name怎么用?Python TriggerType.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.trigger.TriggerType
的用法示例。
在下文中一共展示了TriggerType.get_by_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_sample_triggers
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_name [as 别名]
def _setup_sample_triggers(
self, names=["st2.test.trigger1", "st2.test.trigger2", "st2.test.trigger3", "st2.test.trigger4"]
):
trigger_dbs = []
for name in names:
trigtype = None
try:
trigtype = TriggerTypeDB()
trigtype.pack = "dummy_pack_1"
trigtype.name = name
trigtype.description = ""
trigtype.payload_schema = {}
trigtype.parameters_schema = {}
try:
trigtype = TriggerType.get_by_name(name)
except:
trigtype = TriggerType.add_or_update(trigtype)
except NotUniqueError:
pass
created = TriggerDB()
created.name = name
created.pack = "dummy_pack_1"
created.description = ""
created.type = trigtype.get_reference().ref
if name in ["st2.test.trigger4"]:
created.parameters = {"url": "sample"}
else:
created.parameters = {}
created = Trigger.add_or_update(created)
trigger_dbs.append(created)
return trigger_dbs
示例2: _setup_sample_triggers
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_name [as 别名]
def _setup_sample_triggers(self, names=['st2.test.trigger1', 'st2.test.trigger2',
'st2.test.trigger3', 'st2.test.trigger4']):
trigger_dbs = []
for name in names:
trigtype = None
try:
trigtype = TriggerTypeDB(pack='dummy_pack_1', name=name, description='',
payload_schema={}, parameters_schema={})
try:
trigtype = TriggerType.get_by_name(name)
except:
trigtype = TriggerType.add_or_update(trigtype)
except NotUniqueError:
pass
created = TriggerDB(pack='dummy_pack_1', name=name, description='',
type=trigtype.get_reference().ref)
if name in ['st2.test.trigger4']:
created.parameters = {'url': 'sample'}
else:
created.parameters = {}
created = Trigger.add_or_update(created)
trigger_dbs.append(created)
return trigger_dbs