Ejemplo n.º 1
0
    def get_all(self, marker=None, limit=None, sort_keys='created_at',
                sort_dirs='asc', fields='', name=None, description=None,
                variables=None, scope=None, created_at=None, updated_at=None):
        """Return all environments.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param variables: Optional. Keep only resources with specific
                          variables.
        :param scope: Optional. Keep only resources with a specific scope.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('environments:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            updated_at=updated_at,
            description=description,
            variables=variables,
            scope=scope
        )

        LOG.debug("Fetch environments. marker=%s, limit=%s, sort_keys=%s, "
                  "sort_dirs=%s, filters=%s", marker, limit, sort_keys,
                  sort_dirs, filters)

        return rest_utils.get_all(
            resources.Environments,
            resources.Environment,
            db_api.get_environments,
            db_api.get_environment,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 2
0
    def get_all(self, marker=None, limit=None, sort_keys='created_at',
                sort_dirs='asc', fields='', created_at=None,
                definition=None, name=None, scope=None, tags=None,
                updated_at=None, namespace=None):
        """Return a list of workbooks.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: asc.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param definition: Optional. Keep only resources with a specific
                           definition.
        :param tags: Optional. Keep only resources containing specific tags.
        :param scope: Optional. Keep only resources with a specific scope.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param namespace: Optional. Keep only resources with specific
                          namespace.
        """
        acl.enforce('workbooks:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            definition=definition,
            name=name,
            scope=scope,
            tags=tags,
            updated_at=updated_at,
            namespace=namespace
        )

        LOG.debug("Fetch workbooks. marker=%s, limit=%s, sort_keys=%s, "
                  "sort_dirs=%s, fields=%s, filters=%s", marker, limit,
                  sort_keys, sort_dirs, fields, filters)

        return rest_utils.get_all(
            resources.Workbooks,
            resources.Workbook,
            db_api.get_workbooks,
            db_api.get_workbook,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 3
0
    def get_all(self, task_execution_id, marker=None, limit=None,
                sort_keys='created_at', sort_dirs='asc', fields='',
                created_at=None, name=None, tags=None,
                updated_at=None, workflow_name=None, task_name=None,
                state=None, state_info=None, accepted=None, input=None,
                output=None, params=None, description=None,
                include_output=None):
        """Return all tasks within the execution.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param task_execution_id: Keep only resources within a specific task
                                  execution.
        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param task_name: Optional. Keep only resources with a specific
                          task name.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific state
                           information.
        :param accepted: Optional. Keep only resources which have been accepted
                         or not.
        :param input: Optional. Keep only resources with a specific input.
        :param output: Optional. Keep only resources with a specific output.
        :param params: Optional. Keep only resources with specific parameters.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param tags: Optional. Keep only resources containing specific tags.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param include_output: Optional. Include the output for all executions
                               in the list
        """
        acl.enforce('action_executions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            tags=tags,
            updated_at=updated_at,
            workflow_name=workflow_name,
            task_name=task_name,
            task_execution_id=task_execution_id,
            state=state,
            state_info=state_info,
            accepted=accepted,
            input=input,
            output=output,
            params=params,
            description=description
        )

        LOG.debug(
            "Fetch action_executions. marker=%s, limit=%s, "
            "sort_keys=%s, sort_dirs=%s, filters=%s",
            marker,
            limit,
            sort_keys,
            sort_dirs,
            filters
        )

        return _get_action_executions(
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            include_output=include_output,
            **filters
        )
Ejemplo n.º 4
0
    def get_all(self, task_execution_id, marker=None, limit=None,
                sort_keys='created_at', sort_dirs='asc', fields='',
                workflow_name=None, workflow_id=None, description=None,
                params=None, state=None, state_info=None, input=None,
                output=None, created_at=None, updated_at=None):
        """Return all executions that belong to the given task execution.

        :param task_execution_id: Task task execution ID.
        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param params: Optional. Keep only resources with specific parameters.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific
                           state information.
        :param input: Optional. Keep only resources with a specific input.
        :param output: Optional. Keep only resources with a specific output.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('executions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            task_execution_id=task_execution_id,
            created_at=created_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            params=params,
            state=state,
            state_info=state_info,
            input=input,
            output=output,
            updated_at=updated_at,
            description=description
        )

        LOG.debug(
            "Fetch executions. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s", marker, limit, sort_keys, sort_dirs,
            filters
        )

        return rest_utils.get_all(
            resources.Executions,
            resources.Execution,
            db_api.get_workflow_executions,
            db_api.get_workflow_execution,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 5
0
    def get_all(self, workflow_execution_id, marker=None, limit=None,
                sort_keys='created_at', sort_dirs='asc', fields='', name=None,
                workflow_name=None, workflow_id=None, state=None,
                state_info=None, result=None, published=None, processed=None,
                created_at=None, updated_at=None, reset=None, env=None):
        """Return all tasks within the execution.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param workflow_execution_id: Optional. Keep only resources with a
                                      specific workflow execution ID.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific
                           state information.
        :param result: Optional. Keep only resources with a specific result.
        :param published: Optional. Keep only resources with specific
                          published content.
        :param processed: Optional. Keep only resources which have been
                          processed or not.
        :param reset: Optional. Keep only resources which have been reset or
                      not.
        :param env: Optional. Keep only resources with a specific environment.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('tasks:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            workflow_execution_id=workflow_execution_id,
            created_at=created_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            state=state,
            state_info=state_info,
            updated_at=updated_at,
            name=name,
            result=result,
            published=published,
            processed=processed,
            reset=reset,
            env=env
        )

        LOG.debug(
            "Fetch tasks. workflow_execution_id=%s, marker=%s, limit=%s, "
            "sort_keys=%s, sort_dirs=%s, filters=%s",
            workflow_execution_id, marker, limit, sort_keys, sort_dirs,
            filters
        )

        return rest_utils.get_all(
            resources.Tasks,
            resources.Task,
            db_api.get_task_executions,
            db_api.get_task_execution,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 6
0
    def get_all(self, marker=None, limit=None, sort_keys='name',
                sort_dirs='asc', fields='', created_at=None, name=None,
                scope=None, tags=None, updated_at=None,
                description=None, definition=None, is_system=None, input=None):
        """Return all actions.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: name.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: asc.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param scope: Optional. Keep only resources with a specific scope.
        :param definition: Optional. Keep only resources with a specific
                           definition.
        :param is_system: Optional. Keep only system actions or ad-hoc
                          actions (if False).
        :param input: Optional. Keep only resources with a specific input.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param tags: Optional. Keep only resources containing specific tags.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.
        """
        acl.enforce('actions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            scope=scope,
            tags=tags,
            updated_at=updated_at,
            description=description,
            definition=definition,
            is_system=is_system,
            input=input
        )

        LOG.info("Fetch actions. marker=%s, limit=%s, sort_keys=%s, "
                 "sort_dirs=%s, filters=%s", marker, limit, sort_keys,
                 sort_dirs, filters)

        return rest_utils.get_all(
            resources.Actions,
            resources.Action,
            db_api.get_action_definitions,
            db_api.get_action_definition_by_id,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 7
0
    def get_all(self, marker=None, limit=None, sort_keys='created_at',
                sort_dirs='asc', fields='', name=None, workflow_name=None,
                workflow_id=None, workflow_input=None, workflow_params=None,
                scope=None, pattern=None, remaining_executions=None,
                first_execution_time=None, next_execution_time=None,
                created_at=None, updated_at=None, project_id=None,
                all_projects=False):
        """Return all cron triggers.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param workflow_input: Optional. Keep only resources with a specific
                               workflow input.
        :param workflow_params: Optional. Keep only resources with specific
                                workflow parameters.
        :param scope: Optional. Keep only resources with a specific scope.
        :param pattern: Optional. Keep only resources with a specific pattern.
        :param remaining_executions: Optional. Keep only resources with a
                                     specific number of remaining executions.
        :param project_id: Optional. Keep only resources with the specific
                           project id.
        :param first_execution_time: Optional. Keep only resources with a
                                     specific time and date of first execution.
        :param next_execution_time: Optional. Keep only resources with a
                                    specific time and date of next execution.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param all_projects: Optional. Get resources of all projects.
        """
        acl.enforce('cron_triggers:list', context.ctx())

        if all_projects:
            acl.enforce('cron_triggers:list:all_projects', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            updated_at=updated_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            workflow_input=workflow_input,
            workflow_params=workflow_params,
            scope=scope,
            pattern=pattern,
            remaining_executions=remaining_executions,
            first_execution_time=first_execution_time,
            next_execution_time=next_execution_time,
            project_id=project_id,
        )

        LOG.debug(
            "Fetch cron triggers. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s, all_projects=%s",
            marker, limit, sort_keys, sort_dirs, filters, all_projects
        )

        return rest_utils.get_all(
            resources.CronTriggers,
            resources.CronTrigger,
            db_api.get_cron_triggers,
            db_api.get_cron_trigger,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            all_projects=all_projects,
            **filters
        )
Ejemplo n.º 8
0
    def get_all(self,
                workflow_execution_id,
                marker=None,
                limit=None,
                sort_keys='created_at',
                sort_dirs='asc',
                fields='',
                name=None,
                workflow_name=None,
                workflow_id=None,
                state=None,
                state_info=None,
                result=None,
                published=None,
                processed=None,
                created_at=None,
                updated_at=None,
                reset=None,
                env=None):
        """Return all tasks within the execution.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param workflow_execution_id: Optional. Keep only resources with a
                                      specific workflow execution ID.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific
                           state information.
        :param result: Optional. Keep only resources with a specific result.
        :param published: Optional. Keep only resources with specific
                          published content.
        :param processed: Optional. Keep only resources which have been
                          processed or not.
        :param reset: Optional. Keep only resources which have been reset or
                      not.
        :param env: Optional. Keep only resources with a specific environment.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('tasks:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            workflow_execution_id=workflow_execution_id,
            created_at=created_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            state=state,
            state_info=state_info,
            updated_at=updated_at,
            name=name,
            result=result,
            published=published,
            processed=processed,
            reset=reset,
            env=env)

        LOG.debug(
            "Fetch tasks. workflow_execution_id=%s, marker=%s, limit=%s, "
            "sort_keys=%s, sort_dirs=%s, filters=%s", workflow_execution_id,
            marker, limit, sort_keys, sort_dirs, filters)

        return rest_utils.get_all(resources.Tasks,
                                  resources.Task,
                                  db_api.get_task_executions,
                                  db_api.get_task_execution,
                                  marker=marker,
                                  limit=limit,
                                  sort_keys=sort_keys,
                                  sort_dirs=sort_dirs,
                                  fields=fields,
                                  **filters)
Ejemplo n.º 9
0
    def get_all(self, marker=None, limit=None, sort_keys='created_at',
                sort_dirs='asc', fields='', workflow_name=None,
                workflow_id=None, description=None, params=None,
                task_execution_id=None, root_execution_id=None, state=None,
                state_info=None, input=None, output=None, created_at=None,
                updated_at=None, include_output=None, project_id=None,
                all_projects=False):
        """Return all Executions.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param params: Optional. Keep only resources with specific parameters.
        :param task_execution_id: Optional. Keep only resources with a
                                  specific task execution ID.
        :param root_execution_id: Optional. Keep only resources with a
                                  specific root execution ID.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific
                           state information.
        :param input: Optional. Keep only resources with a specific input.
        :param output: Optional. Keep only resources with a specific output.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param include_output: Optional. Include the output for all executions
                               in the list.
        :param project_id: Optional. Only get exectuions belong to the project.
            Admin required.
        :param all_projects: Optional. Get resources of all projects. Admin
            required.
        """
        acl.enforce('executions:list', context.ctx())

        if all_projects or project_id:
            acl.enforce('executions:list:all_projects', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            params=params,
            task_execution_id=task_execution_id,
            state=state,
            state_info=state_info,
            input=input,
            output=output,
            updated_at=updated_at,
            description=description,
            project_id=project_id,
            root_execution_id=root_execution_id,
        )

        LOG.debug(
            "Fetch executions. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s, all_projects=%s", marker, limit,
            sort_keys, sort_dirs, filters, all_projects
        )

        if include_output:
            resource_function = _get_workflow_execution_resource
        else:
            resource_function = None

        return rest_utils.get_all(
            resources.Executions,
            resources.Execution,
            db_api.get_workflow_executions,
            db_api.get_workflow_execution,
            resource_function=resource_function,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            all_projects=all_projects,
            **filters
        )
Ejemplo n.º 10
0
    def get_all(self, task_execution_id, marker=None, limit=None,
                sort_keys='created_at', sort_dirs='asc', fields='',
                created_at=None, name=None, tags=None,
                updated_at=None, workflow_name=None, task_name=None,
                state=None, state_info=None, accepted=None, input=None,
                output=None, params=None, description=None,
                include_output=None):
        """Return all tasks within the execution.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param task_execution_id: Keep only resources within a specific task
                                  execution.
        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param task_name: Optional. Keep only resources with a specific
                          task name.
        :param state: Optional. Keep only resources with a specific state.
        :param state_info: Optional. Keep only resources with specific state
                           information.
        :param accepted: Optional. Keep only resources which have been accepted
                         or not.
        :param input: Optional. Keep only resources with a specific input.
        :param output: Optional. Keep only resources with a specific output.
        :param params: Optional. Keep only resources with specific parameters.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param tags: Optional. Keep only resources containing specific tags.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param include_output: Optional. Include the output for all executions
                               in the list
        """
        acl.enforce('action_executions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            tags=tags,
            updated_at=updated_at,
            workflow_name=workflow_name,
            task_name=task_name,
            task_execution_id=task_execution_id,
            state=state,
            state_info=state_info,
            accepted=accepted,
            input=input,
            output=output,
            params=params,
            description=description
        )

        LOG.info(
            "Fetch action_executions. marker=%s, limit=%s, "
            "sort_keys=%s, sort_dirs=%s, filters=%s",
            marker,
            limit,
            sort_keys,
            sort_dirs,
            filters
        )

        return _get_action_executions(
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            include_output=include_output,
            **filters
        )
Ejemplo n.º 11
0
    def get_all(self,
                marker=None,
                limit=None,
                sort_keys='created_at',
                sort_dirs='asc',
                fields='',
                name=None,
                input=None,
                definition=None,
                tags=None,
                scope=None,
                project_id=None,
                created_at=None,
                updated_at=None,
                all_projects=False):
        """Return a list of workflows.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: asc.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param input: Optional. Keep only resources with a specific input.
        :param definition: Optional. Keep only resources with a specific
                           definition.
        :param tags: Optional. Keep only resources containing specific tags.
        :param scope: Optional. Keep only resources with a specific scope.
        :param project_id: Optional. The same as the requester project_id
                           or different if the scope is public.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param all_projects: Optional. Get resources of all projects.
        """
        acl.enforce('workflows:list', context.ctx())

        if all_projects:
            acl.enforce('workflows:list:all_projects', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            scope=scope,
            tags=tags,
            updated_at=updated_at,
            input=input,
            definition=definition,
            project_id=project_id)

        LOG.info(
            "Fetch workflows. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, fields=%s, filters=%s, all_projects=%s", marker,
            limit, sort_keys, sort_dirs, fields, filters, all_projects)

        return rest_utils.get_all(resources.Workflows,
                                  resources.Workflow,
                                  db_api.get_workflow_definitions,
                                  db_api.get_workflow_definition_by_id,
                                  marker=marker,
                                  limit=limit,
                                  sort_keys=sort_keys,
                                  sort_dirs=sort_dirs,
                                  fields=fields,
                                  all_projects=all_projects,
                                  **filters)
Ejemplo n.º 12
0
    def get_all(self, marker=None, limit=None, sort_keys='name',
                sort_dirs='asc', fields='', created_at=None, name=None,
                scope=None, tags=None, updated_at=None,
                description=None, definition=None, is_system=None, input=None):
        """Return all actions.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: name.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: asc.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param scope: Optional. Keep only resources with a specific scope.
        :param definition: Optional. Keep only resources with a specific
                           definition.
        :param is_system: Optional. Keep only system actions or ad-hoc
                          actions (if False).
        :param input: Optional. Keep only resources with a specific input.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param tags: Optional. Keep only resources containing specific tags.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('actions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            scope=scope,
            tags=tags,
            updated_at=updated_at,
            description=description,
            definition=definition,
            is_system=is_system,
            input=input
        )

        LOG.info("Fetch actions. marker=%s, limit=%s, sort_keys=%s, "
                 "sort_dirs=%s, filters=%s", marker, limit, sort_keys,
                 sort_dirs, filters)

        return rest_utils.get_all(
            resources.Actions,
            resources.Action,
            db_api.get_action_definitions,
            db_api.get_action_definition_by_id,
            marker=marker,
            limit=limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            fields=fields,
            **filters
        )
Ejemplo n.º 13
0
    def get_all(self,
                marker=None,
                limit=None,
                sort_keys='name',
                sort_dirs='asc',
                fields='',
                created_at=None,
                name=None,
                scope=None,
                tags=None,
                updated_at=None,
                description=None,
                definition=None,
                is_system=None,
                input=None,
                namespace=''):
        """Return all actions.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: name.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: asc.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param scope: Optional. Keep only resources with a specific scope.
        :param definition: Optional. Keep only resources with a specific
                           definition.
        :param is_system: Optional. Keep only system actions or ad-hoc
                          actions (if False).
        :param input: Optional. Keep only resources with a specific input.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param tags: Optional. Keep only resources containing specific tags.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        :param namespace: Optional. The namespace of the action.
        """
        acl.enforce('actions:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            scope=scope,
            tags=tags,
            updated_at=updated_at,
            description=description,
            definition=definition,
            is_system=is_system,
            input=input,
            namespace=namespace)

        LOG.debug(
            "Fetch actions. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s", marker, limit, sort_keys, sort_dirs,
            filters)

        sort_keys = ['name'] if sort_keys is None else sort_keys
        sort_dirs = ['asc'] if sort_dirs is None else sort_dirs
        fields = [] if fields is None else fields

        if fields and 'name' not in fields:
            fields.insert(0, 'name')

        rest_utils.validate_query_params(limit, sort_keys, sort_dirs)

        action_provider = action_service.get_system_action_provider()

        # Here we assume that the action search might involve DB operations
        # so we need to apply the regular retrying logic as everywhere else.
        action_descriptors = rest_utils.rest_retry_on_db_error(
            action_provider.find_all)(namespace=namespace,
                                      limit=limit,
                                      sort_fields=sort_keys,
                                      sort_dirs=sort_dirs,
                                      filters=filters)

        # We can't guarantee that at this point the collection of action
        # descriptors is properly filtered and sorted.

        # Apply filters.
        action_descriptors = filter(
            lambda a_d: filter_utils.match_filters(a_d, filters),
            action_descriptors)

        # Apply sorting.
        def compare_(a_d1, a_d2):
            # TODO(rakhmerov): Implement properly
            return 0

        action_descriptors = sorted(action_descriptors,
                                    key=functools.cmp_to_key(compare_))

        if limit and limit > 0:
            action_descriptors = action_descriptors[0:limit]

        action_resources = [
            _action_descriptor_to_resource(a_d) for a_d in action_descriptors
        ]

        # TODO(rakhmerov): Fix pagination so that it doesn't work with
        # the 'id' field as a marker. We can't use IDs anymore. "name"
        # seems a good candidate for this.
        return resources.Actions.convert_with_links(
            action_resources,
            limit,
            pecan.request.application_url,
            sort_keys=','.join(sort_keys),
            sort_dirs=','.join(sort_dirs),
            **filters)
Ejemplo n.º 14
0
    def get_all(self,
                marker=None,
                limit=None,
                sort_keys='created_at',
                sort_dirs='asc',
                fields='',
                name=None,
                description=None,
                variables=None,
                scope=None,
                created_at=None,
                updated_at=None):
        """Return all environments.

        Where project_id is the same as the requester or
        project_id is different but the scope is public.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param description: Optional. Keep only resources with a specific
                            description.
        :param variables: Optional. Keep only resources with specific
                          variables.
        :param scope: Optional. Keep only resources with a specific scope.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('environments:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            updated_at=updated_at,
            description=description,
            variables=variables,
            scope=scope)

        LOG.info(
            "Fetch environments. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s", marker, limit, sort_keys, sort_dirs,
            filters)

        return rest_utils.get_all(resources.Environments,
                                  resources.Environment,
                                  db_api.get_environments,
                                  db_api.get_environment,
                                  marker=marker,
                                  limit=limit,
                                  sort_keys=sort_keys,
                                  sort_dirs=sort_dirs,
                                  fields=fields,
                                  **filters)
Ejemplo n.º 15
0
    def get_all(self,
                marker=None,
                limit=None,
                sort_keys='created_at',
                sort_dirs='asc',
                fields='',
                name=None,
                workflow_name=None,
                workflow_id=None,
                workflow_input=None,
                workflow_params=None,
                scope=None,
                pattern=None,
                remaining_executions=None,
                first_execution_time=None,
                next_execution_time=None,
                created_at=None,
                updated_at=None):
        """Return all cron triggers.

        :param marker: Optional. Pagination marker for large data sets.
        :param limit: Optional. Maximum number of resources to return in a
                      single result. Default value is None for backward
                      compatibility.
        :param sort_keys: Optional. Columns to sort results by.
                          Default: created_at, which is backward compatible.
        :param sort_dirs: Optional. Directions to sort corresponding to
                          sort_keys, "asc" or "desc" can be chosen.
                          Default: desc. The length of sort_dirs can be equal
                          or less than that of sort_keys.
        :param fields: Optional. A specified list of fields of the resource to
                       be returned. 'id' will be included automatically in
                       fields if it's provided, since it will be used when
                       constructing 'next' link.
        :param name: Optional. Keep only resources with a specific name.
        :param workflow_name: Optional. Keep only resources with a specific
                              workflow name.
        :param workflow_id: Optional. Keep only resources with a specific
                            workflow ID.
        :param workflow_input: Optional. Keep only resources with a specific
                               workflow input.
        :param workflow_params: Optional. Keep only resources with specific
                                workflow parameters.
        :param scope: Optional. Keep only resources with a specific scope.
        :param pattern: Optional. Keep only resources with a specific pattern.
        :param remaining_executions: Optional. Keep only resources with a
                                     specific number of remaining executions.
        :param first_execution_time: Optional. Keep only resources with a
                                     specific time and date of first execution.
        :param next_execution_time: Optional. Keep only resources with a
                                    specific time and date of next execution.
        :param created_at: Optional. Keep only resources created at a specific
                           time and date.
        :param updated_at: Optional. Keep only resources with specific latest
                           update time and date.
        """
        acl.enforce('cron_triggers:list', context.ctx())

        filters = filter_utils.create_filters_from_request_params(
            created_at=created_at,
            name=name,
            updated_at=updated_at,
            workflow_name=workflow_name,
            workflow_id=workflow_id,
            workflow_input=workflow_input,
            workflow_params=workflow_params,
            scope=scope,
            pattern=pattern,
            remaining_executions=remaining_executions,
            first_execution_time=first_execution_time,
            next_execution_time=next_execution_time)

        LOG.info(
            "Fetch cron triggers. marker=%s, limit=%s, sort_keys=%s, "
            "sort_dirs=%s, filters=%s", marker, limit, sort_keys, sort_dirs,
            filters)

        return rest_utils.get_all(resources.CronTriggers,
                                  resources.CronTrigger,
                                  db_api.get_cron_triggers,
                                  db_api.get_cron_trigger,
                                  marker=marker,
                                  limit=limit,
                                  sort_keys=sort_keys,
                                  sort_dirs=sort_dirs,
                                  fields=fields,
                                  **filters)