16. Flow Service
Accessed via client.flow(). Retrieves PlantPulse visual workflows (Flow) and the nodes within them (Flow Node). This is a service newly added in V5.
Note: The V5 Flow service is read-only. Creating, modifying, and executing Flows is done through the UI or the Flow engine's dedicated API. For details on how the Flow engine works, see the Flow engine documentation.
16.1 Method List
| Method | Return Type | HTTP | Endpoint |
|---|---|---|---|
get(flow_id) | FlowResponseV5 or null | GET | /api/v5/flow/{id} |
list() | List<FlowResponseV5> (with statistics) | GET | /api/v5/flow |
listNodes(flow_id) | List<FlowNodeResponseV5> | GET | /api/v5/flow/{id}/node |
16.2 FlowResponseV5 DTO
| Field | Type | Description |
|---|---|---|
flow_id | String | Flow ID (PK) |
flow_name | String | Flow name |
description | String | Description |
enabled | boolean | Whether enabled |
is_root | boolean | Whether it is a root Flow |
debug_mode | boolean | Debug mode |
insert_user / insert_date | String | Creator / timestamp |
update_user / update_date | String | Modifier / timestamp |
node_count | int | Node count (statistics) |
trigger_count | int | Trigger count (statistics) |
error_count | long | Cumulative error count (statistics) |
16.3 FlowNodeResponseV5 DTO
| Field | Type | Description |
|---|---|---|
flow_node_id | String | Node ID (PK) |
flow_id | String | Parent Flow |
type | String | Node type (trigger, function, action, etc.) |
name | String | Node name |
configuration_json | String | Node configuration JSON string |
position_x / position_y | int | Canvas position |
debug_mode | boolean | Per-node debug |
16.4 Usage Examples
Flow List (with statistics)
import java.util.List;
import plantpulse.api.v5.dto.response.FlowResponseV5;
List<FlowResponseV5> flows = client.flow().list();
for (FlowResponseV5 f : flows) {
System.out.printf("[%s] %s — 노드 %d개, 트리거 %d개, 에러 %d건%n",
f.isEnabled() ? "ON" : "OFF",
f.getFlow_name(),
f.getNode_count(),
f.getTrigger_count(),
f.getError_count());
}
Example output:
[ON] 생산 카운트 집계 — 노드 8개, 트리거 1개, 에러 0건
[ON] 알람 알림 라우팅 — 노드 12개, 트리거 3개, 에러 2건
[OFF] (실험) ML 예측 — 노드 5개, 트리거 0개, 에러 0건
Retrieving a Single Flow
FlowResponseV5 flow = client.flow().get("flow_001");
if (flow != null && !flow.isEnabled()) {
System.err.println("Flow가 비활성 상태: " + flow.getFlow_name());
}
Node List of a Flow
import plantpulse.api.v5.dto.response.FlowNodeResponseV5;
String flowId = "flow_001";
List<FlowNodeResponseV5> nodes = client.flow().listNodes(flowId);
for (FlowNodeResponseV5 n : nodes) {
System.out.printf(" [%s] %s (%s)%n",
n.getType(), n.getName(), n.getFlow_node_id());
}
Identifying Flows with Errors
import java.util.stream.Collectors;
List<FlowResponseV5> errored = client.flow().list().stream()
.filter(f -> f.getError_count() > 0)
.collect(Collectors.toList());
System.out.println("에러 발생 Flow: " + errored.size() + "개");
for (FlowResponseV5 f : errored) {
System.out.printf(" %s: %d건%n", f.getFlow_name(), f.getError_count());
}
16.5 Usage Scenarios
Scenario — Flow Health Dashboard
while (running) {
List<FlowResponseV5> all = client.flow().list();
long total = all.size();
long enabled = all.stream().filter(FlowResponseV5::isEnabled).count();
long errored = all.stream().filter(f -> f.getError_count() > 0).count();
long triggers = all.stream().mapToInt(FlowResponseV5::getTrigger_count).sum();
updateUI(total, enabled, errored, triggers);
Thread.sleep(5_000);
}
Next Steps
- Flow Engine Guide — how Flow works (separate document)
- Integration Examples — examples of integrating Flow with the API