예제 #1
0
파일: workflow.py 프로젝트: dizzler/mistral
    def put(self, identifier=None):
        """Update one or more workflows.

        :param identifier: Optional. If provided, it's UUID of a workflow.
            Only one workflow can be updated with identifier param.

        The text is allowed to have definitions of multiple workflows. In this
        case they all will be updated.
        """
        acl.enforce('workflows:update', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')

        if scope not in resources.SCOPE_TYPES.values:
            raise exc.InvalidModelException(
                "Scope must be one of the following: %s; actual: "
                "%s" % (resources.SCOPE_TYPES.values, scope))

        LOG.info("Update workflow(s) [definition=%s]", definition)

        db_wfs = workflows.update_workflows(definition,
                                            scope=scope,
                                            identifier=identifier)

        models_dicts = [db_wf.to_dict() for db_wf in db_wfs]
        workflow_list = [
            resources.Workflow.from_dict(wf) for wf in models_dicts
        ]

        return (workflow_list[0].to_json() if identifier else
                resources.Workflows(workflows=workflow_list).to_json())
예제 #2
0
    def put(self, identifier=None, namespace=''):
        """Update one or more workflows.

        :param identifier: Optional. If provided, it's UUID of a workflow.
            Only one workflow can be updated with identifier param.
        :param namespace: Optional. If provided, it's the namespace of the
                          workflow/workflows. Currently, namespace cannot be
                          changed.

        The text is allowed to have definitions of multiple workflows. In such
        case, they all will be updated.
        """
        acl.enforce('workflows:update', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')

        resources.Workflow.validate_scope(scope)
        if scope == 'public':
            acl.enforce('workflows:publicize', context.ctx())

        LOG.debug("Update workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.update_workflows)(
            definition,
            scope=scope,
            identifier=identifier,
            namespace=namespace)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return (workflow_list[0].to_json() if identifier else
                resources.Workflows(workflows=workflow_list).to_json())
예제 #3
0
파일: workflow.py 프로젝트: dizzler/mistral
    def post(self):
        """Create a new workflow.

        NOTE: The text is allowed to have definitions
            of multiple workflows. In this case they all will be created.
        """
        acl.enforce('workflows:create', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')
        pecan.response.status = 201

        if scope not in resources.SCOPE_TYPES.values:
            raise exc.InvalidModelException(
                "Scope must be one of the following: %s; actual: "
                "%s" % (resources.SCOPE_TYPES.values, scope))

        LOG.info("Create workflow(s) [definition=%s]", definition)

        db_wfs = workflows.create_workflows(definition, scope=scope)
        models_dicts = [db_wf.to_dict() for db_wf in db_wfs]

        workflow_list = [
            resources.Workflow.from_dict(wf) for wf in models_dicts
        ]

        return resources.Workflows(workflows=workflow_list).to_json()
예제 #4
0
    def post(self, namespace=''):
        """Create a new workflow.

        :param namespace: Optional. The namespace to create the workflow
            in. Workflows with the same name can be added to a given
            project if they are in two different namespaces.

        The text is allowed to have definitions of multiple workflows.
        In such case, they all will be created.
        """
        acl.enforce('workflows:create', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')
        pecan.response.status = 201

        resources.Workflow.validate_scope(scope)
        if scope == 'public':
            acl.enforce('workflows:publicize', context.ctx())

        LOG.debug("Create workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.create_workflows)(
            definition, scope=scope, namespace=namespace)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return resources.Workflows(workflows=workflow_list).to_json()
예제 #5
0
    def post(self, namespace=''):
        """Create a new workflow.

        NOTE: The text is allowed to have definitions
            of multiple workflows. In this case they all will be created.

        :param namespace: Optional. The namespace to create the workflow
            in. Workflows with the same name can be added to a given
            project if are in two different namespaces.
        """
        acl.enforce('workflows:create', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')
        pecan.response.status = 201

        if scope not in resources.SCOPE_TYPES.values:
            raise exc.InvalidModelException(
                "Scope must be one of the following: %s; actual: "
                "%s" % (resources.SCOPE_TYPES.values, scope))

        LOG.debug("Create workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.create_workflows)(
            definition, scope=scope, namespace=namespace)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return resources.Workflows(workflows=workflow_list).to_json()
예제 #6
0
    def put(self, identifier=None, namespace=''):
        """Update one or more workflows.

        :param identifier: Optional. If provided, it's UUID of a workflow.
            Only one workflow can be updated with identifier param.
        :param namespace: Optional. If provided, it's the namespace of the
                          workflow/workflows. Currently, namespace cannot be
                          changed.

        The text is allowed to have definitions of multiple workflows. In such
        case, they all will be updated.
        """
        acl.enforce('workflows:update', context.ctx())

        # NOTE(rakhmerov): We can't use normal method arguments to access
        # request data because it will break dynamic sub controller lookup
        # functionality (see _lookup() above) so we have to get the data
        # directly from the request object.

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')

        # If "skip_validation" is present in the query string parameters
        # then workflow language validation will be disabled.
        skip_validation = 'skip_validation' in pecan.request.GET

        resources.Workflow.validate_scope(scope)

        if scope == 'public':
            acl.enforce('workflows:publicize', context.ctx())

        LOG.debug("Update workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.update_workflows)(
            definition,
            scope=scope,
            identifier=identifier,
            namespace=namespace,
            validate=not skip_validation)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return (workflow_list[0].to_json() if identifier else
                resources.Workflows(workflows=workflow_list).to_json())
예제 #7
0
    def post(self, namespace=''):
        """Create a new workflow.

        :param namespace: Optional. The namespace to create the workflow
            in. Workflows with the same name can be added to a given
            project if they are in two different namespaces.

        The text is allowed to have definitions of multiple workflows.
        In such case, they all will be created.
        """
        acl.enforce('workflows:create', context.ctx())

        # NOTE(rakhmerov): We can't use normal method arguments to access
        # request data because it will break dynamic sub controller lookup
        # functionality (see _lookup() above) so we have to get the data
        # directly from the request object.

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')

        # If "skip_validation" is present in the query string parameters
        # then workflow language validation will be disabled.
        skip_validation = 'skip_validation' in pecan.request.GET

        pecan.response.status = 201

        resources.Workflow.validate_scope(scope)

        if scope == 'public':
            acl.enforce('workflows:publicize', context.ctx())

        LOG.debug("Create workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.create_workflows)(
            definition,
            scope=scope,
            namespace=namespace,
            validate=not skip_validation)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return resources.Workflows(workflows=workflow_list).to_json()
예제 #8
0
    def put(self, identifier=None, namespace=''):
        """Update one or more workflows.

        :param identifier: Optional. If provided, it's UUID of a workflow.
            Only one workflow can be updated with identifier param.
        :param namespace: Optional. If provided int's the namespace of the
                          workflow/workflows. currently namespace cannot be
                          changed.

        The text is allowed to have definitions of multiple workflows. In this
        case they all will be updated.
        """
        acl.enforce('workflows:update', context.ctx())

        definition = pecan.request.text
        scope = pecan.request.GET.get('scope', 'private')

        if scope not in resources.SCOPE_TYPES.values:
            raise exc.InvalidModelException(
                "Scope must be one of the following: %s; actual: "
                "%s" % (resources.SCOPE_TYPES.values, scope))

        LOG.debug("Update workflow(s) [definition=%s]", definition)

        db_wfs = rest_utils.rest_retry_on_db_error(workflows.update_workflows)(
            definition,
            scope=scope,
            identifier=identifier,
            namespace=namespace)

        workflow_list = [
            resources.Workflow.from_db_model(db_wf) for db_wf in db_wfs
        ]

        return (workflow_list[0].to_json() if identifier else
                resources.Workflows(workflows=workflow_list).to_json())