Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Combine create and provision APIs #259

Closed
dbwiddis opened this issue Dec 7, 2023 · 2 comments
Closed

[FEATURE] Combine create and provision APIs #259

dbwiddis opened this issue Dec 7, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request v2.12.0

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Dec 7, 2023

If we add validation by default as a prerequisite to saving a WIP template, that could be a frustrating experience for a builder. In that regard, I think it should be a separate capability and having an optional dry-run param for the RestCreateWorkflowAction to validate prior to saving makes sense.

I think validation goes more with the "execution" portion, but we should be able to do the validation before saving. Which means we sort of need a "save-and-execute" single API call.

Which brings back up the possibility of combining APIs.

We have

POST _plugins/_flow_framework/workflow
{
    // use case template
}

followed by

POST _plugins/_flow_framework/workflow/<workflow_id>/_provision
{}

This works well for a "save WIP and finally execute when done" but in the case we have a completed/debugged template that we always want to execute, we could do that all-in-one with:

POST _plugins/_flow_framework/workflow/_provision
{
    // use case template
}

Now, throw a validation param in there and we have a one-liner just like we want:

POST _plugins/_flow_framework/workflow/_provision?dryrun=true
{
    // use case template
}

(or similar)

Originally posted by @dbwiddis in #88 (comment)

@dbwiddis
Copy link
Member Author

dbwiddis commented Dec 7, 2023

It's also possible to add provision=true as a param to the existing create API rather than having a new API.

@joshpalis
Copy link
Member

It's also possible to add provision=true as a param to the existing create API rather than having a new API.

+1 to this approach :

// Request
POST _plugins/_flow_framework/workflow?provision=true 
{
    // use case template
}

// Response
{"workflow_id":"<workflowId>"}

From what I can gather, the sequence would be as follows :

  1. User invokes the above API with provision=true
  2. This hits our RestCreateWorkflowAction, which passes the request to the CreateWorkflowTransportAction
  3. The CreateWorkflowTransportAction indexes the template into the Global Context index and responds to the action listener with a workflow_id
  4. Once we get the response back in the ResCreateWorkflowAction, we check if provision param is true and then invoke ProvisionWokflowTransportAction, which will handle validation/executing the workflow
  5. The ProvisionWorkflowTrasportAction will respond with a workflow_id or an error if validation/execution fails

CC : @jackiehanyang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v2.12.0
Projects
None yet
Development

No branches or pull requests

3 participants