예제 #1
0
파일: execution.py 프로젝트: baikai/qinling
    def get_all(self,
                function_id=None,
                all_projects=False,
                project_id=None,
                status=None,
                description=None):
        """Return a list of executions.

        :param function_id: Optional. Filtering executions by function_id.
        :param project_id: Optional. Admin user can query other projects
            resources, the param is ignored for normal user.
        :param all_projects: Optional. Get resources of all projects.
        :param status: Optional. Filter by execution status.
        :param description: Optional. Filter by description.
        """
        project_id, all_projects = rest_utils.get_project_params(
            project_id, all_projects)
        if all_projects:
            acl.enforce('execution:get_all:all_projects', context.get_ctx())

        filters = rest_utils.get_filters(function_id=function_id,
                                         project_id=project_id,
                                         status=status,
                                         description=description)
        LOG.info("Get all %ss. filters=%s", self.type, filters)

        db_execs = db_api.get_executions(insecure=all_projects, **filters)
        executions = [
            resources.Execution.from_db_obj(db_model) for db_model in db_execs
        ]

        return resources.Executions(executions=executions)
예제 #2
0
    def get_all(self, all_projects=False, project_id=None):
        """Get all the function aliases.

        :param project_id: Optional. Admin user can query other projects
            resources, the param is ignored for normal user.
        :param all_projects: Optional. Get resources of all projects.
        """
        ctx = context.get_ctx()
        project_id, all_projects = rest_utils.get_project_params(
            project_id, all_projects)
        if all_projects:
            acl.enforce('function_version:get_all:all_projects', ctx)

        filters = rest_utils.get_filters(project_id=project_id)

        LOG.info("Get all function aliases. filters=%s", filters)

        db_aliases = db_api.get_function_aliases(insecure=all_projects,
                                                 **filters)
        aliases = [
            resources.FunctionAlias.from_db_obj(db_model)
            for db_model in db_aliases
        ]

        return resources.FunctionAliases(function_aliases=aliases)
예제 #3
0
    def get_all(self, all_projects=False, project_id=None):
        project_id, all_projects = rest_utils.get_project_params(
            project_id, all_projects)
        if all_projects:
            acl.enforce('job:get_all:all_projects', context.get_ctx())

        filters = rest_utils.get_filters(project_id=project_id, )
        LOG.info("Get all %ss. filters=%s", self.type, filters)
        db_jobs = db_api.get_jobs(insecure=all_projects, **filters)
        jobs = [resources.Job.from_db_obj(db_model) for db_model in db_jobs]

        return resources.Jobs(jobs=jobs)
예제 #4
0
    def get_all(self, all_projects=False, project_id=None):
        project_id, all_projects = rest_utils.get_project_params(
            project_id, all_projects)
        if all_projects:
            acl.enforce('webhook:get_all:all_projects', context.get_ctx())

        filters = rest_utils.get_filters(project_id=project_id, )

        LOG.info("Get all %ss. filters=%s", self.type, filters)
        webhooks = []
        for i in db_api.get_webhooks(insecure=all_projects, **filters):
            webhooks.append(
                resources.Webhook.from_dict(
                    self._add_webhook_url(i.id, i.to_dict())))

        return resources.Webhooks(webhooks=webhooks)