trustgraph/docs/cli/tg-get-flow-blueprint.md

344 lines
9.2 KiB
Markdown
Raw Permalink Normal View History

2026-01-14 12:13:27 +00:00
# tg-get-flow-blueprint
2026-01-14 12:13:27 +00:00
Retrieves and displays a flow blueprint definition in JSON format.
## Synopsis
```bash
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n CLASS_NAME [options]
```
## Description
2026-01-14 12:13:27 +00:00
The `tg-get-flow-blueprint` command retrieves a stored flow blueprint definition from TrustGraph and displays it in formatted JSON. This is useful for examining flow blueprint configurations, creating backups, or preparing to modify existing flow blueprintes.
2026-01-14 12:13:27 +00:00
The output can be saved to files for version control, documentation, or as input for creating new flow blueprintes with `tg-put-flow-blueprint`.
## Options
### Required Arguments
2026-01-14 12:13:27 +00:00
- `-n, --blueprint-name CLASS_NAME`: Name of the flow blueprint to retrieve
### Optional Arguments
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
## Examples
2026-01-14 12:13:27 +00:00
### Display Flow Blueprint Definition
```bash
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "document-processing"
```
2026-01-14 12:13:27 +00:00
### Save Flow Blueprint to File
```bash
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "production-flow" > production-flow-backup.json
```
2026-01-14 12:13:27 +00:00
### Compare Flow Blueprintes
```bash
2026-01-14 12:13:27 +00:00
# Get multiple flow blueprintes for comparison
tg-get-flow-blueprint -n "dev-flow" > dev-flow.json
tg-get-flow-blueprint -n "prod-flow" > prod-flow.json
diff dev-flow.json prod-flow.json
```
### Using Custom API URL
```bash
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "remote-flow" -u http://production:8088/
```
## Output Format
2026-01-14 12:13:27 +00:00
The command outputs the flow blueprint definition in formatted JSON:
```json
{
"description": "Document processing and analysis flow",
"interfaces": {
"agent": {
"request": "non-persistent://tg/request/agent:doc-proc",
"response": "non-persistent://tg/response/agent:doc-proc"
},
"document-rag": {
"request": "non-persistent://tg/request/document-rag:doc-proc",
"response": "non-persistent://tg/response/document-rag:doc-proc"
},
"text-load": "persistent://tg/flow/text-document-load:doc-proc",
"document-load": "persistent://tg/flow/document-load:doc-proc",
"triples-store": "persistent://tg/flow/triples-store:doc-proc"
},
"tags": ["production", "document-processing"]
}
```
### Key Components
#### Description
2026-01-14 12:13:27 +00:00
Human-readable description of the flow blueprint purpose and capabilities.
#### Interfaces
Service definitions showing:
- **Request/Response Services**: Services with both request and response queues
- **Fire-and-Forget Services**: Services with only input queues
#### Tags (Optional)
2026-01-14 12:13:27 +00:00
Categorization tags for organizing flow blueprintes.
## Prerequisites
2026-01-14 12:13:27 +00:00
### Flow Blueprint Must Exist
Verify the flow blueprint exists before retrieval:
```bash
2026-01-14 12:13:27 +00:00
# Check available flow blueprintes
tg-show-flow-blueprints
# Look for specific class
2026-01-14 12:13:27 +00:00
tg-show-flow-blueprints | grep "target-class"
```
## Error Handling
2026-01-14 12:13:27 +00:00
### Flow Blueprint Not Found
```bash
2026-01-14 12:13:27 +00:00
Exception: Flow blueprint 'invalid-class' not found
```
2026-01-14 12:13:27 +00:00
**Solution**: Check available classes with `tg-show-flow-blueprints` and verify the class name.
### Connection Errors
```bash
Exception: Connection refused
```
**Solution**: Check the API URL and ensure TrustGraph is running.
### Permission Errors
```bash
2026-01-14 12:13:27 +00:00
Exception: Access denied to flow blueprint
```
2026-01-14 12:13:27 +00:00
**Solution**: Verify user permissions for accessing flow blueprint definitions.
## Use Cases
### Configuration Backup
```bash
2026-01-14 12:13:27 +00:00
# Backup all flow blueprintes
mkdir -p flow-class-backups/$(date +%Y%m%d)
2026-01-14 12:13:27 +00:00
tg-show-flow-blueprints | awk '{print $1}' | while read class; do
if [ "$class" != "flow" ]; then # Skip header
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "$class" > "flow-class-backups/$(date +%Y%m%d)/$class.json"
fi
done
```
2026-01-14 12:13:27 +00:00
### Flow Blueprint Migration
```bash
# Export from source environment
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "production-flow" -u http://source:8088/ > prod-flow.json
# Import to target environment
2026-01-14 12:13:27 +00:00
tg-put-flow-blueprint -n "production-flow" -c "$(cat prod-flow.json)" -u http://target:8088/
```
### Template Creation
```bash
2026-01-14 12:13:27 +00:00
# Get existing flow blueprint as template
tg-get-flow-blueprint -n "base-flow" > template.json
# Modify template and create new class
sed 's/base-flow/new-flow/g' template.json > new-flow.json
2026-01-14 12:13:27 +00:00
tg-put-flow-blueprint -n "custom-flow" -c "$(cat new-flow.json)"
```
### Configuration Analysis
```bash
2026-01-14 12:13:27 +00:00
# Analyze flow blueprint configurations
tg-get-flow-blueprint -n "complex-flow" | jq '.interfaces | keys'
tg-get-flow-blueprint -n "complex-flow" | jq '.interfaces | length'
```
### Version Control Integration
```bash
2026-01-14 12:13:27 +00:00
# Store flow blueprintes in git
mkdir -p flow-classes
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "main-flow" > flow-classes/main-flow.json
git add flow-classes/main-flow.json
git commit -m "Update main-flow configuration"
```
## JSON Processing
### Extract Specific Information
```bash
# Get only interface names
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow" | jq -r '.interfaces | keys[]'
# Get only description
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow" | jq -r '.description'
# Get request queues
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow" | jq -r '.interfaces | to_entries[] | select(.value.request) | .value.request'
```
### Validate Configuration
```bash
# Validate JSON structure
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON"
# Check required fields
2026-01-14 12:13:27 +00:00
config=$(tg-get-flow-blueprint -n "my-flow")
echo "$config" | jq -e '.description' > /dev/null || echo "Missing description"
echo "$config" | jq -e '.interfaces' > /dev/null || echo "Missing interfaces"
```
## Integration with Other Commands
2026-01-14 12:13:27 +00:00
### Flow Blueprint Lifecycle
```bash
2026-01-14 12:13:27 +00:00
# 1. Examine existing flow blueprint
tg-get-flow-blueprint -n "old-flow"
# 2. Save backup
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "old-flow" > old-flow-backup.json
# 3. Modify configuration
cp old-flow-backup.json new-flow.json
# Edit new-flow.json as needed
# 4. Upload new version
2026-01-14 12:13:27 +00:00
tg-put-flow-blueprint -n "updated-flow" -c "$(cat new-flow.json)"
2026-01-14 12:13:27 +00:00
# 5. Test new flow blueprint
tg-start-flow -n "updated-flow" -i "test-instance" -d "Testing updated flow"
```
### Bulk Operations
```bash
2026-01-14 12:13:27 +00:00
# Process multiple flow blueprintes
flow_classes=("flow1" "flow2" "flow3")
for class in "${flow_classes[@]}"; do
echo "Processing $class..."
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "$class" > "backup-$class.json"
# Modify configuration
sed 's/old-pattern/new-pattern/g' "backup-$class.json" > "updated-$class.json"
# Upload updated version
2026-01-14 12:13:27 +00:00
tg-put-flow-blueprint -n "$class" -c "$(cat updated-$class.json)"
done
```
## Environment Variables
- `TRUSTGRAPH_URL`: Default API URL
## Related Commands
2026-01-14 12:13:27 +00:00
- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Upload/update flow blueprint definitions
- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes
- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Remove flow blueprint definitions
- [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes
## API Integration
2026-01-14 12:13:27 +00:00
This command uses the [Flow API](../apis/api-flow.md) with the `get-class` operation to retrieve flow blueprint definitions.
## Advanced Usage
### Configuration Diff
```bash
2026-01-14 12:13:27 +00:00
# Compare flow blueprint versions
tg-get-flow-blueprint -n "flow-v1" > v1.json
tg-get-flow-blueprint -n "flow-v2" > v2.json
diff -u v1.json v2.json
```
### Extract Queue Information
```bash
2026-01-14 12:13:27 +00:00
# Get all queue names from flow blueprint
tg-get-flow-blueprint -n "my-flow" | jq -r '
.interfaces |
to_entries[] |
if .value | type == "object" then
.value.request, .value.response
else
.value
end
' | sort | uniq
```
### Configuration Validation Script
```bash
#!/bin/bash
# validate-flow-class.sh
flow_class="$1"
if [ -z "$flow_class" ]; then
2026-01-14 12:13:27 +00:00
echo "Usage: $0 <flow-blueprint-name>"
exit 1
fi
2026-01-14 12:13:27 +00:00
echo "Validating flow blueprint: $flow_class"
# Get configuration
2026-01-14 12:13:27 +00:00
config=$(tg-get-flow-blueprint -n "$flow_class" 2>/dev/null)
if [ $? -ne 0 ]; then
2026-01-14 12:13:27 +00:00
echo "ERROR: Flow blueprint not found"
exit 1
fi
# Validate JSON
echo "$config" | jq . > /dev/null
if [ $? -ne 0 ]; then
echo "ERROR: Invalid JSON structure"
exit 1
fi
# Check required fields
desc=$(echo "$config" | jq -r '.description // empty')
if [ -z "$desc" ]; then
echo "WARNING: Missing description"
fi
interfaces=$(echo "$config" | jq -r '.interfaces // empty')
if [ -z "$interfaces" ] || [ "$interfaces" = "null" ]; then
echo "ERROR: Missing interfaces"
exit 1
fi
2026-01-14 12:13:27 +00:00
echo "Flow blueprint validation passed"
```
## Best Practices
2026-01-14 12:13:27 +00:00
1. **Regular Backups**: Save flow blueprint definitions before modifications
2. **Version Control**: Store configurations in version control systems
2026-01-14 12:13:27 +00:00
3. **Documentation**: Include meaningful descriptions in flow blueprintes
4. **Validation**: Validate JSON structure before using configurations
5. **Template Management**: Use existing classes as templates for new ones
2026-01-14 12:13:27 +00:00
6. **Change Tracking**: Document changes when updating flow blueprintes
## Troubleshooting
### Empty Output
```bash
# If command returns empty output
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow"
# Check if flow blueprint exists
tg-show-flow-blueprints | grep "my-flow"
```
### Invalid JSON Output
```bash
# If output appears corrupted
2026-01-14 12:13:27 +00:00
tg-get-flow-blueprint -n "my-flow" | jq .
# Should show parsing error if JSON is invalid
```
### Permission Issues
```bash
# If access denied errors occur
# Verify authentication and user permissions
# Contact system administrator if needed
```