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


Python ActionAPI.parameters方法代码示例

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


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

示例1: get_all

# 需要导入模块: from st2common.models.api.action import ActionAPI [as 别名]
# 或者: from st2common.models.api.action.ActionAPI import parameters [as 别名]
    def get_all(self, exclude_attributes=None, include_attributes=None, sort=None, offset=0,
                limit=None, requester_user=None, **raw_filters):
        """
            List all actions.

            Handles requests:
                GET /actions/views/overview
        """
        resp = super(OverviewController, self)._get_all(exclude_fields=exclude_attributes,
                                                        include_fields=include_attributes,
                                                        sort=sort,
                                                        offset=offset,
                                                        limit=limit,
                                                        raw_filters=raw_filters,
                                                        requester_user=requester_user)
        runner_type_names = set([])
        action_ids = []

        result = []
        for item in resp.json:
            action_api = ActionAPI(**item)
            result.append(action_api)

            runner_type_names.add(action_api.runner_type)
            action_ids.append(str(action_api.id))

        # Add combined runner and action parameters to the compound result object
        # NOTE: This approach results in 2 additional queries while previous one resulted in
        # N * 2 additional queries

        # 1. Retrieve all the respective runner objects - we only need parameters
        runner_type_dbs = RunnerType.query(name__in=runner_type_names,
                                           only_fields=['name', 'runner_parameters'])
        runner_type_dbs = dict([(runner_db.name, runner_db) for runner_db in runner_type_dbs])

        # 2. Retrieve all the respective action objects - we only need parameters
        action_dbs = dict([(action_db.id, action_db) for action_db in result])

        for action_api in result:
            action_db = action_dbs.get(action_api.id, None)
            runner_db = runner_type_dbs.get(action_api.runner_type, None)
            all_params = action_param_utils.get_params_view(action_db=action_db,
                                                            runner_db=runner_db,
                                                            merged_only=True)
            action_api.parameters = all_params

        resp.json = result
        return resp
开发者ID:StackStorm,项目名称:st2,代码行数:50,代码来源:action_views.py


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