Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .orchestrator_creation_workflow_rules import creation_workflow_rules
from .orchestrator_get_sample_workflow import orchestrator_get_sample_workflow
from .orchestrator_workflow_renderer import orchestrator_preview_workflow

__all__ = [creation_workflow_rules, orchestrator_preview_workflow]
__all__ = [
creation_workflow_rules,
orchestrator_get_sample_workflow,
orchestrator_preview_workflow,
]
1 change: 1 addition & 0 deletions tools/examples/conditional_logic_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This example shows off the Switch State and the subflow action. The workflow is started with application information data as input
62 changes: 62 additions & 0 deletions tools/examples/conditional_logic_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

```json
{
"id": "applicantrequest",
"version": "1.0",
"specVersion": "0.8",
"name": "Applicant Request Decision Workflow",
"description": "Determine if applicant request is valid",
"start": "CheckApplication",
"functions": [
{
"name": "sendRejectionEmailFunction",
"operation": "http://myapis.org/applicationapi.json#emailRejection"
}
],
"states":[
{
"name":"CheckApplication",
"type":"switch",
"dataConditions": [
{
"condition": "${ .applicants | .age >= 18 }",
"transition": "StartApplication"
},
{
"condition": "${ .applicants | .age < 18 }",
"transition": "RejectApplication"
}
],
"defaultCondition": {
"transition": "RejectApplication"
}
},
{
"name": "StartApplication",
"type": "operation",
"actions": [
{
"subFlowRef": "startApplicationWorkflowId"
}
],
"end": true
},
{
"name":"RejectApplication",
"type":"operation",
"actionMode":"sequential",
"actions":[
{
"functionRef": {
"refName": "sendRejectionEmailFunction",
"arguments": {
"applicant": "${ .applicant }"
}
}
}
],
"end": true
}
]
}
```
5 changes: 5 additions & 0 deletions tools/examples/http_requests_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Gpenerate a serverless workflow which:
- Obtain the public IP info from http://ipinfo.io/json
- If the request is 404, please log the error.
- If the request is sucessfull make an http request to https://httpbin.org/post which the payload from previous request with city and public ip
- Log all the final state variable in the logs on log level INFO
110 changes: 110 additions & 0 deletions tools/examples/http_requests_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
```json
{
"id": "get_public_info",
"name": "Get And publish ip information",
"version": "1.0",
"specVersion": "0.8",
"start": "Get public IP",
"errors": [
{
"name": "notAvailable",
"code": "404"
}
],
"functions": [
{
"name": "getIP",
"type": "custom",
"operation": "rest:get:https://ipinfo.io/json"
},
{
"name": "pushData",
"type": "custom",
"operation": "rest:post:https://httpbin.org/post"
},
{
"name": "logInfo",
"type": "custom",
"operation": "sysout:INFO"
}
],
"states": [
{
"name": "Get public IP",
"type": "operation",
"actions": [
{
"functionRef": {
"refName": "getIP"
},
"actionDataFilter": {
"toStateData": ".ip_info"
}
}
],
"onErrors": [
{
"errorRef": "notAvailable",
"transition": "logError"
}
],
"transition": "push_host_data"
},
{
"name": "push_host_data",
"type": "operation",
"actions": [
{
"functionRef": {
"refName": "pushData",
"arguments": {
"city": ".ip_info.city",
"ip": ".ip_info.ip"
}
},
"actionDataFilter": {
"toStateData": ".results"
}
}
],
"onErrors": [
{
"errorRef": "notAvailable",
"transition": "logError"
}
],
"transition": "finalState"
},
{
"name": "finalState",
"type": "operation",
"actions": [
{
"functionRef": {
"refName": "logInfo",
"arguments": {
"message": "\"FINAL INFORMATION!: \\(.)\""
}
}
}
],
"end": true
},
{
"name": "logError",
"type": "operation",
"actions": [
{
"functionRef": {
"refName": "logInfo",
"arguments": {
"message": "\"GOT 404 message, state value=\\(.)\""
}
}
}
],
"end": true
}
]
}
```
20 changes: 20 additions & 0 deletions tools/examples/iteration_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
I need to generate a workflow wich track room temperature for different rooms on my building.

The workflow should have an input with multiple rooms, in json array, like:

```
{"rooms": ["kitchen", "bedroom1", "bathroom"]}
```

for each room, you need to iterate over the array and make an http request to http://office-status.local/temperature/$ROOM. When you made all request, please create a json like

```
[
{ "room": "kitchen", "temperature": 23 },
{ "room": "bedroom1", "temperature": 18 },
{ "room": "bathroom", "temperature": 18 }
]
```

This json need to be posted into http://erp.local/roomTemperatures, using a POST request and all rooms information should be in a json object, with the key .rooms

81 changes: 81 additions & 0 deletions tools/examples/iteration_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Here you have the workflow:

```json
{
"id": "getTemperature",
"name": "Get temperature by room",
"version": "1.0",
"specVersion": "0.8",
"start": "getAllRoomTemperature",
"functions": [
{
"name": "getRoomTemperature",
"type": "custom",
"operation": "rest:get:http://office-status.local/temperature/{room_name}"
},
{
"name": "reportInfo",
"type": "custom",
"operation": "rest:post:http://erp.local/roomTemperatures"
}
],
"states": [
{
"name": "getAllRoomTemperature",
"type": "foreach",
"inputCollection": "${ .rooms }",
"outputCollection": "${ .results }",
"iterationParam": "roomName",
"actions": [
{
"functionRef": {
"refName": "getRoomTemperature",
"arguments": {
"room_name": "${ .roomName }"
}
},
"actionDataFilter": {
"results": "{room: .roomName, temperature:.temperature}"
}
}
],
"transition": "reportInfo"
},
{
"name": "reportInfo",
"type": "operation",
"actions": [
{
"functionRef": {
"refName": "reportInfo",
"arguments": {
"rooms": "${ .results }"
}
},
"actionDataFilter": {
"toStateData": ".reportInformation"
}
}
],
"end": true
}
]
}
```

Key points for this workflow:

- *Functions*: Two functions are created:
- `getRoomTemperature` which uses your url and has an argument `room_name`
- `reportInfo` which POST the information to the given url.
- *States*:
- `getAllRoomTemperature`:
- I assume that the input of rooms will be part of the object when calling the worklow, under "rooms" field. The state iterate over each entry of the array and get information using the `getRoomTemperature` function.
- To create a valid information for the next stage, the output is filtered and prepared in the actionDataFilter action with the roomName and the temperature.
- When finished, the workflow will call the `reportInfo` state.
- `reportInfo`:
- It'll use the reportInfo function, because it's already defined.
- It'll create an argument which will be posted with the rooms key
- It'll return the report information under the `.reportInformation` key
- Because the workflow does not have more steps, set end:true

2 changes: 2 additions & 0 deletions tools/examples/scheduling_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In this example we show the use of scheduled cron-based start event property. The example workflow checks the users inbox every 15 minutes and send them a text message when there are important emails.

55 changes: 55 additions & 0 deletions tools/examples/scheduling_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
```json
{
"id": "checkInbox",
"name": "Check Inbox Workflow",
"version": "1.0",
"specVersion": "0.8",
"description": "Periodically Check Inbox",
"start": {
"stateName": "CheckInbox",
"schedule": {
"cron": "0 0/15 * * * ?"
}
},
"functions": [
{
"name": "checkInboxFunction",
"operation": "http://myapis.org/inboxapi.json#checkNewMessages"
},
{
"name": "sendTextFunction",
"operation": "http://myapis.org/inboxapi.json#sendText"
}
],
"states": [
{
"name": "CheckInbox",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"functionRef": "checkInboxFunction"
}
],
"transition": "SendTextForHighPriority"
},
{
"name": "SendTextForHighPriority",
"type": "foreach",
"inputCollection": "${ .messages }",
"iterationParam": "singlemessage",
"actions": [
{
"functionRef": {
"refName": "sendTextFunction",
"arguments": {
"message": "${ .singlemessage }"
}
}
}
],
"end": true
}
]
}
```
Loading