当前位置: 首页>>代码示例>>Python>>正文


Python TriggerInstance.get_by_id方法代码示例

本文整理汇总了Python中st2common.persistence.trigger.TriggerInstance.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python TriggerInstance.get_by_id方法的具体用法?Python TriggerInstance.get_by_id怎么用?Python TriggerInstance.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st2common.persistence.trigger.TriggerInstance的用法示例。


在下文中一共展示了TriggerInstance.get_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_triggerinstance_crud

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
 def test_triggerinstance_crud(self):
     triggertype = ReactorModelTest._create_save_triggertype()
     trigger = ReactorModelTest._create_save_trigger(triggertype)
     saved = ReactorModelTest._create_save_triggerinstance(trigger)
     retrieved = TriggerInstance.get_by_id(saved.id)
     self.assertIsNotNone(retrieved, "No triggerinstance created.")
     ReactorModelTest._delete([retrieved, trigger, triggertype])
     try:
         retrieved = TriggerInstance.get_by_id(saved.id)
     except StackStormDBObjectNotFoundError:
         retrieved = None
     self.assertIsNone(retrieved, "managed to retrieve after failure.")
开发者ID:rlugojr,项目名称:st2,代码行数:14,代码来源:test_db.py

示例2: test_triggerinstance_crud

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
 def test_triggerinstance_crud(self):
     triggertype = ReactorModelTest._create_save_triggertype()
     trigger = ReactorModelTest._create_save_trigger(triggertype)
     saved = ReactorModelTest._create_save_triggerinstance(trigger)
     retrieved = TriggerInstance.get_by_id(saved.id)
     self.assertIsNotNone(retrieved, 'No triggerinstance created.')
     ReactorModelTest._delete([retrieved, trigger, triggertype])
     try:
         retrieved = TriggerInstance.get_by_id(saved.id)
     except ValueError:
         retrieved = None
     self.assertIsNone(retrieved, 'managed to retrieve after failure.')
开发者ID:azamsheriff,项目名称:st2,代码行数:14,代码来源:test_db.py

示例3: create_execution_object

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
def create_execution_object(liveaction, action_db=None, runnertype_db=None, publish=True):
    if not action_db:
        action_db = action_utils.get_action_by_ref(liveaction.action)

    if not runnertype_db:
        runnertype_db = RunnerType.get_by_name(action_db.runner_type['name'])

    attrs = {
        'action': vars(ActionAPI.from_model(action_db)),
        'parameters': liveaction['parameters'],
        'runner': vars(RunnerTypeAPI.from_model(runnertype_db))
    }
    attrs.update(_decompose_liveaction(liveaction))

    if 'rule' in liveaction.context:
        rule = reference.get_model_from_ref(Rule, liveaction.context.get('rule', {}))
        attrs['rule'] = vars(RuleAPI.from_model(rule))

    if 'trigger_instance' in liveaction.context:
        trigger_instance_id = liveaction.context.get('trigger_instance', {})
        trigger_instance_id = trigger_instance_id.get('id', None)
        trigger_instance = TriggerInstance.get_by_id(trigger_instance_id)
        trigger = reference.get_model_by_resource_ref(db_api=Trigger,
                                                      ref=trigger_instance.trigger)
        trigger_type = reference.get_model_by_resource_ref(db_api=TriggerType,
                                                           ref=trigger.type)
        trigger_instance = reference.get_model_from_ref(
            TriggerInstance, liveaction.context.get('trigger_instance', {}))
        attrs['trigger_instance'] = vars(TriggerInstanceAPI.from_model(trigger_instance))
        attrs['trigger'] = vars(TriggerAPI.from_model(trigger))
        attrs['trigger_type'] = vars(TriggerTypeAPI.from_model(trigger_type))

    parent = _get_parent_execution(liveaction)
    if parent:
        attrs['parent'] = str(parent.id)

    attrs['log'] = [_create_execution_log_entry(liveaction['status'])]

    # TODO: This object initialization takes 20-30or so ms
    execution = ActionExecutionDB(**attrs)
    # TODO: Do 100% research this is fully safe and unique in distributed setups
    execution.id = ObjectId()
    execution.web_url = _get_web_url_for_execution(str(execution.id))

    # NOTE: User input data is already validate as part of the API request,
    # other data is set by us. Skipping validation here makes operation 10%-30% faster
    execution = ActionExecution.add_or_update(execution, publish=publish, validate=False)

    if parent and str(execution.id) not in parent.children:
        values = {}
        values['push__children'] = str(execution.id)
        ActionExecution.update(parent, **values)

    return execution
开发者ID:nzlosh,项目名称:st2,代码行数:56,代码来源:executions.py

示例4: create_execution_object

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
def create_execution_object(liveaction, publish=True):
    action_db = action_utils.get_action_by_ref(liveaction.action)
    runner = RunnerType.get_by_name(action_db.runner_type['name'])

    attrs = {
        'action': vars(ActionAPI.from_model(action_db)),
        'parameters': liveaction['parameters'],
        'runner': vars(RunnerTypeAPI.from_model(runner))
    }
    attrs.update(_decompose_liveaction(liveaction))

    if 'rule' in liveaction.context:
        rule = reference.get_model_from_ref(Rule, liveaction.context.get('rule', {}))
        attrs['rule'] = vars(RuleAPI.from_model(rule))

    if 'trigger_instance' in liveaction.context:
        trigger_instance_id = liveaction.context.get('trigger_instance', {})
        trigger_instance_id = trigger_instance_id.get('id', None)
        trigger_instance = TriggerInstance.get_by_id(trigger_instance_id)
        trigger = reference.get_model_by_resource_ref(db_api=Trigger,
                                                      ref=trigger_instance.trigger)
        trigger_type = reference.get_model_by_resource_ref(db_api=TriggerType,
                                                           ref=trigger.type)
        trigger_instance = reference.get_model_from_ref(
            TriggerInstance, liveaction.context.get('trigger_instance', {}))
        attrs['trigger_instance'] = vars(TriggerInstanceAPI.from_model(trigger_instance))
        attrs['trigger'] = vars(TriggerAPI.from_model(trigger))
        attrs['trigger_type'] = vars(TriggerTypeAPI.from_model(trigger_type))

    parent = _get_parent_execution(liveaction)
    if parent:
        attrs['parent'] = str(parent.id)

    attrs['log'] = [_create_execution_log_entry(liveaction['status'])]

    execution = ActionExecutionDB(**attrs)
    execution = ActionExecution.add_or_update(execution, publish=False)

    # Update the web_url field in execution. Unfortunately, we need
    # the execution id for constructing the URL which we only get
    # after the model is written to disk.
    execution.web_url = _get_web_url_for_execution(str(execution.id))
    execution = ActionExecution.add_or_update(execution, publish=publish)

    if parent:
        if str(execution.id) not in parent.children:
            parent.children.append(str(execution.id))
            ActionExecution.add_or_update(parent)

    return execution
开发者ID:lyandut,项目名称:st2,代码行数:52,代码来源:executions.py

示例5: get_one

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
    def get_one(self, id):
        """
            List triggerinstance by id.

            Handle:
                GET /triggerinstances/1
        """
        try:
            trigger_instance_db = TriggerInstance.get_by_id(id)
        except (ValueError, ValidationError):
            LOG.exception('Database lookup for id="%s" resulted in exception.', id)
            abort(http_client.NOT_FOUND)
            return

        trigger_instance_api = TriggerInstanceAPI.from_model(trigger_instance_db)
        return trigger_instance_api
开发者ID:bsyk,项目名称:st2,代码行数:18,代码来源:triggers.py

示例6: create_execution_object

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
def create_execution_object(liveaction, publish=True):
    action_db = action_utils.get_action_by_ref(liveaction.action)
    runner = RunnerType.get_by_name(action_db.runner_type['name'])

    attrs = {
        'action': vars(ActionAPI.from_model(action_db)),
        'parameters': liveaction['parameters'],
        'runner': vars(RunnerTypeAPI.from_model(runner))
    }
    attrs.update(_decompose_liveaction(liveaction))

    if 'rule' in liveaction.context:
        rule = reference.get_model_from_ref(Rule, liveaction.context.get('rule', {}))
        attrs['rule'] = vars(RuleAPI.from_model(rule))

    if 'trigger_instance' in liveaction.context:
        trigger_instance_id = liveaction.context.get('trigger_instance', {})
        trigger_instance_id = trigger_instance_id.get('id', None)
        trigger_instance = TriggerInstance.get_by_id(trigger_instance_id)
        trigger = reference.get_model_by_resource_ref(db_api=Trigger,
                                                      ref=trigger_instance.trigger)
        trigger_type = reference.get_model_by_resource_ref(db_api=TriggerType,
                                                           ref=trigger.type)
        trigger_instance = reference.get_model_from_ref(
            TriggerInstance, liveaction.context.get('trigger_instance', {}))
        attrs['trigger_instance'] = vars(TriggerInstanceAPI.from_model(trigger_instance))
        attrs['trigger'] = vars(TriggerAPI.from_model(trigger))
        attrs['trigger_type'] = vars(TriggerTypeAPI.from_model(trigger_type))

    parent = _get_parent_execution(liveaction)
    if parent:
        attrs['parent'] = str(parent.id)

    execution = ActionExecutionDB(**attrs)
    execution = ActionExecution.add_or_update(execution, publish=publish)

    if parent:
        if str(execution.id) not in parent.children:
            parent.children.append(str(execution.id))
            ActionExecution.add_or_update(parent)

    return execution
开发者ID:azamsheriff,项目名称:st2,代码行数:44,代码来源:executions.py

示例7: _refire_trigger_instance

# 需要导入模块: from st2common.persistence.trigger import TriggerInstance [as 别名]
# 或者: from st2common.persistence.trigger.TriggerInstance import get_by_id [as 别名]
def _refire_trigger_instance(trigger_instance_id, log_):
    trigger_instance = TriggerInstance.get_by_id(trigger_instance_id)
    trigger_dispatcher = TriggerDispatcher(log_)
    trigger_dispatcher.dispatch(trigger=trigger_instance.trigger,
                                payload=trigger_instance.payload)
开发者ID:lyandut,项目名称:st2,代码行数:7,代码来源:trigger_re_fire.py


注:本文中的st2common.persistence.trigger.TriggerInstance.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。