-
Notifications
You must be signed in to change notification settings - Fork 1
/
example2_output.txt
81 lines (77 loc) · 2.44 KB
/
example2_output.txt
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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