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

new endpoint /workflows/action #1928

Closed
8 tasks
Tracked by #1922
humansinstitute opened this issue Nov 11, 2024 · 3 comments
Closed
8 tasks
Tracked by #1922

new endpoint /workflows/action #1928

humansinstitute opened this issue Nov 11, 2024 · 3 comments
Assignees

Comments

@humansinstitute
Copy link
Contributor

humansinstitute commented Nov 11, 2024

Context

Develop a new endpoint '/workflows/action' to process the action object, which is a union of request and response objects, and trigger the next steps in the workflow.

The /workflows/action endpoint is a critical component of the Stakwork Common Workflow Plumbing feature. It is designed to process an "action" object, which is a union of request and response objects. This endpoint will trigger the subsequent steps in the workflow, ensuring that the system can handle complex interactions between requests and responses efficiently.

This is related to a broader project defined here:
For context see: #1922

System Schematic:

image

Design

  • Endpoint URL: /workflows/action
  • HTTP Method: POST
  • Request Body: The request will contain an "action" object, which includes both request and response data.
  • Example:
{
    "source": "string",
    "requestUUID": "string",
    "action": "string"
    "workflowID": interger,
    "requestData": { object },
    "responseData": { object }
}
  • Response: The endpoint will return a status indicating the success or failure of processing the action.
    • Example:
      {
        "status": "success",
        "message": "Action processed successfully."
      }

Logic:

  1. Validate the incoming action object to ensure it contains required data
  2. Log the action object for auditing and tracking purposes.
  3. Process the action by:
    i. updating the workflow request state in wf_requests
    ii. trigger the next action based on the action "string".
    iii. If there is no defined action then log "no action taken" and exit
  4. Return a response indicating the outcome of the processing.

Note the action string will need to map to a next function to take.

Assignment Criteria

  • Familiarity with RESTful API design and implementation.
  • Experience with JSON data structures and validation.
  • Communication via Sphinx V2 is required; ensure you are live on Sphinx V2.

Acceptance Criteria

  • The endpoint must accept a POST request at /workflows/action.
  • The request body must include a valid action object with both request and response data.
  • The endpoint must validate the action object and log it appropriately.
  • The workflow state must be updated based on the action data.
  • Any subsequent workflow steps must be triggered as necessary.
  • The endpoint must return a JSON response indicating success or failure.
  • The implementation must include unit tests covering both positive and negative cases.
  • The endpoint must handle errors gracefully and log them for further analysis.
@saithsab877
Copy link
Contributor

@humansinstitute Please assign?

@MuhammadUmer44
Copy link
Contributor

@humansinstitute I can help?

@humansinstitute
Copy link
Contributor Author

Given definition expansion of #1926 & #1927

This is no longer requied as it will already be implemented in the handlers and util functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants