Event Based Workflow REST API
Aside from programmatically managing your Event Based Workflow services via
Event Based WorkflowMethods
, Martini also allows you to manage your workflows via the
Event Based Workflow REST API. With this API, you can:
- Execute a Event Based Workflow service
- Terminate a Event Based Workflow service
- Send an event to Event Based Workflow services
- Get all Event Based Workflow services' contexts
- Get a Event Based Workflow service's context
- Get a Event Based Workflow state's context
- Add a tag to a Event Based Workflow service
- Remove a Event Based Workflow service's tag
- Get a Event Based Workflow service's definition
Event Based Workflow REST API or Event Based WorkflowMethods
?
If you are trying to handle Event Based Workflow service(s) from another service,
TORO recommends you use Event Based WorkflowMethods
instead.
Headers
By default, the Event Based Workflow REST API allows access to all Event Based Workflow services. The request privilege
may be elevated by providing an Authorization
header:
Header Name | Data Type | Description |
---|---|---|
Authorization | string | Bearer <The access token of a Martini user> |
Endpoints
All endpoints of the Event Based Workflow REST API have paths beginning with /flux-api
. Read on below for more information about the
API's endpoints.
Available as a Postman collection (v2.1)
You can use Postman to try out and call the endpoints of the Event Based Workflow REST API. Simply download and import this Postman collection.
Execute a Event Based Workflow service
Method | Path |
---|---|
POST |
/flux-api/{package}/execute |
Request
Path parameters
Parameter name | Data type | Required | Description |
---|---|---|---|
package |
string | true | The name of the Martini package where the Event Based Workflow is contained. |
Body Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
fluxName |
string | true | The name of the Event Based Workflow service to be run. If the service is located inside a directory, its name should be prepended by the name of its subdirectories separated by periods. For example, org.your.SendAlerts . |
startState |
string | false | The name of the state where the Event Based Workflow execution should start. |
input |
object | false | The inputs which will be fed to the target Event Based Workflow service. |
tags |
string[] | false | The tags to be added to the Event Based Workflow service during execution. |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 4 |
|
Terminate a Event Based Workflow service
Method | Path |
---|---|
DELETE |
/flux-api/terminate |
Request
Query Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
contextId |
long | true | The context ID of the to-be-stopped but running Event Based Workflow service. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 |
|
Send an event to Event Based Workflow services
Method | Path |
---|---|
POST |
/flux-api/event |
Request
Query Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
contextId |
long | false | The context ID of the running Event Based Workflow service you want to send the event to. Specify this parameter only when a single Event Based Workflow service will receive the event. |
Body Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
event |
string | true | The name of the event the waiting state should transition to. |
input |
object | false | The inputs to be given to the Event Based Workflow service(s). |
tags |
string[] | false | The tags to use for determining which Event Based Workflow Services the external event should be sent to. |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Response
Parameter Name | Data Type | Description |
---|---|---|
transitions |
object[] | The Event Based Workflow services which were transitioned by the external event. |
executions |
object[] | The Event Based Workflow services which were triggered by the external event. |
Content Type
application/json
application/xml
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Get all Event Based Workflow services' contexts
Method | Path |
---|---|
GET |
/flux-api/contexts |
Request
Query Parameters
Parameter Name | Data Type | Required | Multiple | Description |
---|---|---|---|---|
fluxName |
string | false | false | Specify to fetch only the contexts of Event Based Workflow services whose names match the value of this parameter. |
tag |
string | false | true | Specify to fetch only the contexts of Event Based Workflow services whose tags match all the values of this parameter. |
status |
string | false | false | Specify to fetch only the contexts of Event Based Workflow services whose statuses match the value of this parameter. |
currentState |
string | false | false | Specify to fetch only the contexts of Event Based Workflow services whose current states match the value of this parameter. |
startState |
string | false | false | Specify to fetch only the contexts of Event Based Workflow services whose starting states match the value of this parameter. |
limit |
integer | false | false | Limits the number of contexts returned. The default value is 30 . |
page |
integer | false | false | Used with limit to select which page of the response should be returned. Its default value is 0 . |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
Get a Event Based Workflow service's context
Method | Path |
---|---|
GET |
/flux-api/context |
Request
Query Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
contextId |
long | true | The context ID of the running Event Based Workflow service whose context is to be fetched. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
Get a Event Based Workflow state's context
Method | Path |
---|---|
GET |
/flux-api/context/state |
Request
Query Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
contextId |
long | true | The context ID of the running Event Based Workflow service that owns the state whose context is to be fetched. |
stateName |
string | true | The name of the state whose context is to be fetched. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Add a tag to a Event Based Workflow service
Method | Path |
---|---|
POST |
/flux-api/context/tag |
PUT |
/flux-api/context/tag |
Request
Query Parameters
Parameter Name | Data Type | Required | Multiple | Description |
---|---|---|---|---|
contextId |
long | true | false | The context ID of the running Event Based Workflow service that will receive the new tag. |
tag |
string | true | true | The tag to add. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 |
|
Remove a Event Based Workflow service's tag
Method | Path |
---|---|
DELETE |
/flux-api/context/tag |
Request
Query Parameters
Parameter Name | Data Type | Required | Multiple | Description |
---|---|---|---|---|
contextId |
long | true | false | The context ID of the running Event Based Workflow service whose tag will be removed. |
tag |
string | true | true | The tag to remove. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 |
|
Get a Event Based Workflow service's definition
Method | Path |
---|---|
GET |
/flux-api/definition |
Request
Query Parameters
The parameter fluxName
and contextId
are mutually exclusive; only one of them is required for the request. If both
are specified, contextId
takes precedence over fluxName
.
Parameter Name | Data Type | Required | Description |
---|---|---|---|
fluxName |
string | false | The name of the Event Based Workflow service whose definition is to be fetched. If the service is located inside a directory, its name should be prepended by the name of its subdirectories separated by periods. For example, org.your.SendAlerts . |
contextId |
long | false | The context ID of the specific running Event Based Workflow service whose definition is to be fetched. |
Example
1 2 3 |
|
Response
Content Type
application/json
application/xml
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|