Skip to content

Commit

Permalink
add an endpoint to check workflow status (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
crm-dhu authored Dec 12, 2024
1 parent e645e56 commit 915dbf1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ sdk env install
sdk env

# use brew to install postman (for API calls) and docker (if needed)
brew install -cask postman
brew install -cask docker
brew install --cask postman
brew install --cask docker
```

**Configure Postgres Database**
Expand Down Expand Up @@ -103,13 +103,26 @@ Once generated, your `sample_workflow.json` can be used to create a workflow:
```html
POST http://localhost:9001/v1/workflow
```
OR
```sh
curl -X POST \
-H "Content-type: application/json" \
-d "$(jq -c . < path/to/sample_workflow.json)" \
"http://localhost:9001/v1/workflow"
```

Which returns a workflow_id. For example: `wf-f231a08f-60e4-480a-b845-e53e06918f77`

Once defined, activate a workflow using the workflow id like so:
```html
PUT http://localhost:9001/v1/workflow/wf-f231a08f-60e4-480a-b845-e53e06918f77
```
OR
```sh
curl -X PUT \
-H "Content-type: application/json" \
"http://localhost:9001/v1/workflow/wf-f231a08f-60e4-480a-b845-e53e06918f77/activate"
```

**Resource and Activity Types**

Expand Down
9 changes: 9 additions & 0 deletions orchard-ws/app/workflow/Controller.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ class Controller @Inject() (
}
}

def details(id: String) = userAction.async {
db.orchardDB
.async(new WorkflowQuery(id).get())
.flatMap {
case Some(wf) => Future.successful(Ok(toResponse(wf)))
case _ => Future.successful(NotFound(Json.toJson(s"Workflow $id does not exist")))
}
}

private def toResponse(r: WorkflowTable.R): JsValue = Json.toJson(
WorkflowResponse(
r.id,
Expand Down
2 changes: 1 addition & 1 deletion orchard-ws/app/workflow/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Router @Inject() (ctrl: Controller) extends SimpleRouter {
) =>
ctrl.filter(like, statuses, orderBy, order, page, perPage)


case GET(p"/$id/details") => ctrl.details(id)
case GET(p"/$id/activities") => ctrl.activities(id)
case GET(p"/$id/activity/$actId") => ctrl.activityAttempts(id, actId)

Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.23.6"
ThisBuild / version := "0.24.0"

0 comments on commit 915dbf1

Please sign in to comment.