Flow class -> flow blueprint

This commit is contained in:
Cyber MacGeddon 2026-01-14 12:13:27 +00:00
parent 4e5f73f597
commit ef576b9ad0
6 changed files with 532 additions and 532 deletions

View file

@ -1,24 +1,24 @@
# tg-delete-flow-class # tg-delete-flow-blueprint
Permanently deletes a flow class definition from TrustGraph. Permanently deletes a flow blueprint definition from TrustGraph.
## Synopsis ## Synopsis
```bash ```bash
tg-delete-flow-class -n CLASS_NAME [options] tg-delete-flow-blueprint -n CLASS_NAME [options]
``` ```
## Description ## Description
The `tg-delete-flow-class` command permanently removes a flow class definition from TrustGraph. This operation cannot be undone, so use with caution. The `tg-delete-flow-blueprint` command permanently removes a flow blueprint definition from TrustGraph. This operation cannot be undone, so use with caution.
**⚠️ Warning**: Deleting a flow class that has active flow instances may cause those instances to become unusable. Always check for active flows before deletion. **⚠️ Warning**: Deleting a flow blueprint that has active flow instances may cause those instances to become unusable. Always check for active flows before deletion.
## Options ## Options
### Required Arguments ### Required Arguments
- `-n, --class-name CLASS_NAME`: Name of the flow class to delete - `-n, --blueprint-name CLASS_NAME`: Name of the flow blueprint to delete
### Optional Arguments ### Optional Arguments
@ -26,65 +26,65 @@ The `tg-delete-flow-class` command permanently removes a flow class definition f
## Examples ## Examples
### Delete a Flow Class ### Delete a Flow Blueprint
```bash ```bash
tg-delete-flow-class -n "old-test-flow" tg-delete-flow-blueprint -n "old-test-flow"
``` ```
### Delete with Custom API URL ### Delete with Custom API URL
```bash ```bash
tg-delete-flow-class -n "deprecated-flow" -u http://staging:8088/ tg-delete-flow-blueprint -n "deprecated-flow" -u http://staging:8088/
``` ```
### Safe Deletion Workflow ### Safe Deletion Workflow
```bash ```bash
# 1. Check if flow class exists # 1. Check if flow blueprint exists
tg-show-flow-classes | grep "target-flow" tg-show-flow-blueprints | grep "target-flow"
# 2. Backup the flow class first # 2. Backup the flow blueprint first
tg-get-flow-class -n "target-flow" > backup-target-flow.json tg-get-flow-blueprint -n "target-flow" > backup-target-flow.json
# 3. Check for active flow instances # 3. Check for active flow instances
tg-show-flows | grep "target-flow" tg-show-flows | grep "target-flow"
# 4. Delete the flow class # 4. Delete the flow blueprint
tg-delete-flow-class -n "target-flow" tg-delete-flow-blueprint -n "target-flow"
# 5. Verify deletion # 5. Verify deletion
tg-show-flow-classes | grep "target-flow" || echo "Flow class deleted successfully" tg-show-flow-blueprints | grep "target-flow" || echo "Flow blueprint deleted successfully"
``` ```
## Prerequisites ## Prerequisites
### Flow Class Must Exist ### Flow Blueprint Must Exist
Verify the flow class exists before attempting deletion: Verify the flow blueprint exists before attempting deletion:
```bash ```bash
# List all flow classes # List all flow blueprintes
tg-show-flow-classes tg-show-flow-blueprints
# Check specific flow class # Check specific flow blueprint
tg-show-flow-classes | grep "target-class" tg-show-flow-blueprints | grep "target-class"
``` ```
### Check for Active Flow Instances ### Check for Active Flow Instances
Before deleting a flow class, check if any flow instances are using it: Before deleting a flow blueprint, check if any flow instances are using it:
```bash ```bash
# List all active flows # List all active flows
tg-show-flows tg-show-flows
# Look for instances using the flow class # Look for instances using the flow blueprint
tg-show-flows | grep "target-class" tg-show-flows | grep "target-class"
``` ```
## Error Handling ## Error Handling
### Flow Class Not Found ### Flow Blueprint Not Found
```bash ```bash
Exception: Flow class 'nonexistent-class' not found Exception: Flow blueprint 'nonexistent-class' not found
``` ```
**Solution**: Verify the flow class exists with `tg-show-flow-classes`. **Solution**: Verify the flow blueprint exists with `tg-show-flow-blueprints`.
### Connection Errors ### Connection Errors
```bash ```bash
@ -94,13 +94,13 @@ Exception: Connection refused
### Permission Errors ### Permission Errors
```bash ```bash
Exception: Access denied to delete flow class Exception: Access denied to delete flow blueprint
``` ```
**Solution**: Verify user permissions for flow class management. **Solution**: Verify user permissions for flow blueprint management.
### Active Flow Instances ### Active Flow Instances
```bash ```bash
Exception: Cannot delete flow class with active instances Exception: Cannot delete flow blueprint with active instances
``` ```
**Solution**: Stop all flow instances using this class before deletion. **Solution**: Stop all flow instances using this class before deletion.
@ -108,37 +108,37 @@ Exception: Cannot delete flow class with active instances
### Cleanup Development Classes ### Cleanup Development Classes
```bash ```bash
# Delete test and development flow classes # Delete test and development flow blueprintes
test_classes=("test-flow-v1" "dev-experiment" "prototype-flow") test_classes=("test-flow-v1" "dev-experiment" "prototype-flow")
for class in "${test_classes[@]}"; do for class in "${test_classes[@]}"; do
echo "Deleting $class..." echo "Deleting $class..."
tg-delete-flow-class -n "$class" tg-delete-flow-blueprint -n "$class"
done done
``` ```
### Migration Cleanup ### Migration Cleanup
```bash ```bash
# After migrating to new flow classes, remove old ones # After migrating to new flow blueprintes, remove old ones
old_classes=("legacy-flow" "deprecated-processor" "old-pipeline") old_classes=("legacy-flow" "deprecated-processor" "old-pipeline")
for class in "${old_classes[@]}"; do for class in "${old_classes[@]}"; do
# Backup first # Backup first
tg-get-flow-class -n "$class" > "backup-$class.json" 2>/dev/null tg-get-flow-blueprint -n "$class" > "backup-$class.json" 2>/dev/null
# Delete # Delete
tg-delete-flow-class -n "$class" tg-delete-flow-blueprint -n "$class"
echo "Deleted $class" echo "Deleted $class"
done done
``` ```
### Conditional Deletion ### Conditional Deletion
```bash ```bash
# Delete flow class only if no active instances exist # Delete flow blueprint only if no active instances exist
flow_class="target-flow" flow_class="target-flow"
active_instances=$(tg-show-flows | grep "$flow_class" | wc -l) active_instances=$(tg-show-flows | grep "$flow_class" | wc -l)
if [ $active_instances -eq 0 ]; then if [ $active_instances -eq 0 ]; then
echo "No active instances found, deleting flow class..." echo "No active instances found, deleting flow blueprint..."
tg-delete-flow-class -n "$flow_class" tg-delete-flow-blueprint -n "$flow_class"
else else
echo "Warning: $active_instances active instances found. Cannot delete." echo "Warning: $active_instances active instances found. Cannot delete."
tg-show-flows | grep "$flow_class" tg-show-flows | grep "$flow_class"
@ -154,13 +154,13 @@ flow_class="important-flow"
backup_dir="flow-class-backups/$(date +%Y%m%d-%H%M%S)" backup_dir="flow-class-backups/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir" mkdir -p "$backup_dir"
echo "Backing up flow class: $flow_class" echo "Backing up flow blueprint: $flow_class"
tg-get-flow-class -n "$flow_class" > "$backup_dir/$flow_class.json" tg-get-flow-blueprint -n "$flow_class" > "$backup_dir/$flow_class.json"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Backup created: $backup_dir/$flow_class.json" echo "Backup created: $backup_dir/$flow_class.json"
echo "Proceeding with deletion..." echo "Proceeding with deletion..."
tg-delete-flow-class -n "$flow_class" tg-delete-flow-blueprint -n "$flow_class"
else else
echo "Backup failed. Aborting deletion." echo "Backup failed. Aborting deletion."
exit 1 exit 1
@ -174,22 +174,22 @@ fi
flow_class="$1" flow_class="$1"
if [ -z "$flow_class" ]; then if [ -z "$flow_class" ]; then
echo "Usage: $0 <flow-class-name>" echo "Usage: $0 <flow-blueprint-name>"
exit 1 exit 1
fi fi
echo "Safety checks for deleting flow class: $flow_class" echo "Safety checks for deleting flow blueprint: $flow_class"
# Check if flow class exists # Check if flow blueprint exists
if ! tg-show-flow-classes | grep -q "$flow_class"; then if ! tg-show-flow-blueprints | grep -q "$flow_class"; then
echo "ERROR: Flow class '$flow_class' not found" echo "ERROR: Flow blueprint '$flow_class' not found"
exit 1 exit 1
fi fi
# Check for active instances # Check for active instances
active_count=$(tg-show-flows | grep "$flow_class" | wc -l) active_count=$(tg-show-flows | grep "$flow_class" | wc -l)
if [ $active_count -gt 0 ]; then if [ $active_count -gt 0 ]; then
echo "ERROR: Found $active_count active instances using this flow class" echo "ERROR: Found $active_count active instances using this flow blueprint"
echo "Active instances:" echo "Active instances:"
tg-show-flows | grep "$flow_class" tg-show-flows | grep "$flow_class"
exit 1 exit 1
@ -198,7 +198,7 @@ fi
# Create backup # Create backup
backup_file="backup-$flow_class-$(date +%Y%m%d-%H%M%S).json" backup_file="backup-$flow_class-$(date +%Y%m%d-%H%M%S).json"
echo "Creating backup: $backup_file" echo "Creating backup: $backup_file"
tg-get-flow-class -n "$flow_class" > "$backup_file" tg-get-flow-blueprint -n "$flow_class" > "$backup_file"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: Failed to create backup" echo "ERROR: Failed to create backup"
@ -206,19 +206,19 @@ if [ $? -ne 0 ]; then
fi fi
# Confirm deletion # Confirm deletion
echo "Ready to delete flow class: $flow_class" echo "Ready to delete flow blueprint: $flow_class"
echo "Backup saved as: $backup_file" echo "Backup saved as: $backup_file"
read -p "Are you sure you want to delete this flow class? (y/N): " confirm read -p "Are you sure you want to delete this flow blueprint? (y/N): " confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
echo "Deleting flow class..." echo "Deleting flow blueprint..."
tg-delete-flow-class -n "$flow_class" tg-delete-flow-blueprint -n "$flow_class"
# Verify deletion # Verify deletion
if ! tg-show-flow-classes | grep -q "$flow_class"; then if ! tg-show-flow-blueprints | grep -q "$flow_class"; then
echo "Flow class deleted successfully" echo "Flow blueprint deleted successfully"
else else
echo "ERROR: Flow class still exists after deletion" echo "ERROR: Flow blueprint still exists after deletion"
exit 1 exit 1
fi fi
else else
@ -229,13 +229,13 @@ fi
## Integration with Other Commands ## Integration with Other Commands
### Complete Flow Class Lifecycle ### Complete Flow Blueprint Lifecycle
```bash ```bash
# 1. List existing flow classes # 1. List existing flow blueprintes
tg-show-flow-classes tg-show-flow-blueprints
# 2. Get flow class details # 2. Get flow blueprint details
tg-get-flow-class -n "target-flow" tg-get-flow-blueprint -n "target-flow"
# 3. Check for active instances # 3. Check for active instances
tg-show-flows | grep "target-flow" tg-show-flows | grep "target-flow"
@ -244,25 +244,25 @@ tg-show-flows | grep "target-flow"
tg-stop-flow -i "instance-id" tg-stop-flow -i "instance-id"
# 5. Create backup # 5. Create backup
tg-get-flow-class -n "target-flow" > backup.json tg-get-flow-blueprint -n "target-flow" > backup.json
# 6. Delete flow class # 6. Delete flow blueprint
tg-delete-flow-class -n "target-flow" tg-delete-flow-blueprint -n "target-flow"
# 7. Verify deletion # 7. Verify deletion
tg-show-flow-classes | grep "target-flow" tg-show-flow-blueprints | grep "target-flow"
``` ```
### Bulk Deletion with Validation ### Bulk Deletion with Validation
```bash ```bash
# Delete multiple flow classes safely # Delete multiple flow blueprintes safely
classes_to_delete=("old-flow1" "old-flow2" "test-flow") classes_to_delete=("old-flow1" "old-flow2" "test-flow")
for class in "${classes_to_delete[@]}"; do for class in "${classes_to_delete[@]}"; do
echo "Processing $class..." echo "Processing $class..."
# Check if exists # Check if exists
if ! tg-show-flow-classes | grep -q "$class"; then if ! tg-show-flow-blueprints | grep -q "$class"; then
echo " $class not found, skipping" echo " $class not found, skipping"
continue continue
fi fi
@ -274,8 +274,8 @@ for class in "${classes_to_delete[@]}"; do
fi fi
# Backup and delete # Backup and delete
tg-get-flow-class -n "$class" > "backup-$class.json" tg-get-flow-blueprint -n "$class" > "backup-$class.json"
tg-delete-flow-class -n "$class" tg-delete-flow-blueprint -n "$class"
echo " $class deleted" echo " $class deleted"
done done
``` ```
@ -286,15 +286,15 @@ done
## Related Commands ## Related Commands
- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes - [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes
- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve flow class definitions - [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve flow blueprint definitions
- [`tg-put-flow-class`](tg-put-flow-class.md) - Create/update flow class definitions - [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Create/update flow blueprint definitions
- [`tg-show-flows`](tg-show-flows.md) - List active flow instances - [`tg-show-flows`](tg-show-flows.md) - List active flow instances
- [`tg-stop-flow`](tg-stop-flow.md) - Stop flow instances - [`tg-stop-flow`](tg-stop-flow.md) - Stop flow instances
## API Integration ## API Integration
This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` operation to remove flow class definitions. This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` operation to remove flow blueprint definitions.
## Best Practices ## Best Practices
@ -310,10 +310,10 @@ This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` op
### Command Succeeds but Class Still Exists ### Command Succeeds but Class Still Exists
```bash ```bash
# Check if deletion actually occurred # Check if deletion actually occurred
tg-show-flow-classes | grep "deleted-class" tg-show-flow-blueprints | grep "deleted-class"
# Verify API connectivity # Verify API connectivity
tg-show-flow-classes > /dev/null && echo "API accessible" tg-show-flow-blueprints > /dev/null && echo "API accessible"
``` ```
### Permissions Issues ### Permissions Issues

View file

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

View file

@ -1,25 +1,25 @@
# tg-put-flow-class # tg-put-flow-blueprint
Uploads or updates a flow class definition in TrustGraph. Uploads or updates a flow blueprint definition in TrustGraph.
## Synopsis ## Synopsis
```bash ```bash
tg-put-flow-class -n CLASS_NAME -c CONFIG_JSON [options] tg-put-flow-blueprint -n CLASS_NAME -c CONFIG_JSON [options]
``` ```
## Description ## Description
The `tg-put-flow-class` command creates or updates a flow class definition in TrustGraph. Flow classes are templates that define processing pipeline configurations, service interfaces, and resource requirements. These classes are used by `tg-start-flow` to create running flow instances. The `tg-put-flow-blueprint` command creates or updates a flow blueprint definition in TrustGraph. Flow blueprintes are templates that define processing pipeline configurations, service interfaces, and resource requirements. These classes are used by `tg-start-flow` to create running flow instances.
Flow classes define the structure and capabilities of processing flows, including which services are available and how they connect to Pulsar queues. Flow blueprintes define the structure and capabilities of processing flows, including which services are available and how they connect to Pulsar queues.
## Options ## Options
### Required Arguments ### Required Arguments
- `-n, --class-name CLASS_NAME`: Name for the flow class - `-n, --blueprint-name CLASS_NAME`: Name for the flow blueprint
- `-c, --config CONFIG_JSON`: Flow class configuration as raw JSON string - `-c, --config CONFIG_JSON`: Flow blueprint configuration as raw JSON string
### Optional Arguments ### Optional Arguments
@ -27,16 +27,16 @@ Flow classes define the structure and capabilities of processing flows, includin
## Examples ## Examples
### Basic Flow Class Creation ### Basic Flow Blueprint Creation
```bash ```bash
tg-put-flow-class \ tg-put-flow-blueprint \
-n "simple-processing" \ -n "simple-processing" \
-c '{"description": "Simple text processing flow", "interfaces": {"text-completion": {"request": "non-persistent://tg/request/text-completion:simple", "response": "non-persistent://tg/response/text-completion:simple"}}}' -c '{"description": "Simple text processing flow", "interfaces": {"text-completion": {"request": "non-persistent://tg/request/text-completion:simple", "response": "non-persistent://tg/response/text-completion:simple"}}}'
``` ```
### Document Processing Flow Class ### Document Processing Flow Blueprint
```bash ```bash
tg-put-flow-class \ tg-put-flow-blueprint \
-n "document-analysis" \ -n "document-analysis" \
-c '{ -c '{
"description": "Document analysis and RAG processing", "description": "Document analysis and RAG processing",
@ -80,14 +80,14 @@ cat > research-flow.json << 'EOF'
} }
EOF EOF
# Upload the flow class # Upload the flow blueprint
tg-put-flow-class -n "research-analysis" -c "$(cat research-flow.json)" tg-put-flow-blueprint -n "research-analysis" -c "$(cat research-flow.json)"
``` ```
### Update Existing Flow Class ### Update Existing Flow Blueprint
```bash ```bash
# Modify existing flow class by adding new service # Modify existing flow blueprint by adding new service
tg-put-flow-class \ tg-put-flow-blueprint \
-n "existing-flow" \ -n "existing-flow" \
-c '{ -c '{
"description": "Updated flow with new capabilities", "description": "Updated flow with new capabilities",
@ -104,14 +104,14 @@ tg-put-flow-class \
}' }'
``` ```
## Flow Class Configuration Format ## Flow Blueprint Configuration Format
### Required Fields ### Required Fields
#### Description #### Description
```json ```json
{ {
"description": "Human-readable description of the flow class" "description": "Human-readable description of the flow blueprint"
} }
``` ```
@ -180,9 +180,9 @@ persistent://tg/flow/{service}:{flow-identifier}
## Complete Example ## Complete Example
### Comprehensive Flow Class ### Comprehensive Flow Blueprint
```bash ```bash
tg-put-flow-class \ tg-put-flow-blueprint \
-n "full-processing-pipeline" \ -n "full-processing-pipeline" \
-c '{ -c '{
"description": "Complete document processing and analysis pipeline", "description": "Complete document processing and analysis pipeline",
@ -234,11 +234,11 @@ tg-put-flow-class \
Successful upload typically produces no output: Successful upload typically produces no output:
```bash ```bash
# Upload flow class (no output expected) # Upload flow blueprint (no output expected)
tg-put-flow-class -n "my-flow" -c '{"description": "test", "interfaces": {}}' tg-put-flow-blueprint -n "my-flow" -c '{"description": "test", "interfaces": {}}'
# Verify upload # Verify upload
tg-show-flow-classes | grep "my-flow" tg-show-flow-blueprints | grep "my-flow"
``` ```
## Error Handling ## Error Handling
@ -276,27 +276,27 @@ config='{"description": "test flow", "interfaces": {}}'
echo "$config" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON" echo "$config" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON"
``` ```
### Flow Class Verification ### Flow Blueprint Verification
```bash ```bash
# After uploading, verify the flow class exists # After uploading, verify the flow blueprint exists
tg-show-flow-classes | grep "my-flow-class" tg-show-flow-blueprints | grep "my-flow-class"
# Get the flow class definition to verify content # Get the flow blueprint definition to verify content
tg-get-flow-class -n "my-flow-class" tg-get-flow-blueprint -n "my-flow-class"
``` ```
## Flow Class Lifecycle ## Flow Blueprint Lifecycle
### Development Workflow ### Development Workflow
```bash ```bash
# 1. Create flow class # 1. Create flow blueprint
tg-put-flow-class -n "dev-flow" -c "$dev_config" tg-put-flow-blueprint -n "dev-flow" -c "$dev_config"
# 2. Test with flow instance # 2. Test with flow instance
tg-start-flow -n "dev-flow" -i "test-instance" -d "Testing" tg-start-flow -n "dev-flow" -i "test-instance" -d "Testing"
# 3. Update flow class as needed # 3. Update flow blueprint as needed
tg-put-flow-class -n "dev-flow" -c "$updated_config" tg-put-flow-blueprint -n "dev-flow" -c "$updated_config"
# 4. Restart flow instance with updates # 4. Restart flow instance with updates
tg-stop-flow -i "test-instance" tg-stop-flow -i "test-instance"
@ -309,53 +309,53 @@ tg-start-flow -n "dev-flow" -i "test-instance" -d "Testing updated"
## Related Commands ## Related Commands
- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve flow class definitions - [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve flow blueprint definitions
- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes - [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes
- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Remove flow class definitions - [`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 - [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes
## API Integration ## API Integration
This command uses the [Flow API](../apis/api-flow.md) with the `put-class` operation to store flow class definitions. This command uses the [Flow API](../apis/api-flow.md) with the `put-class` operation to store flow blueprint definitions.
## Use Cases ## Use Cases
### Custom Processing Pipelines ### Custom Processing Pipelines
```bash ```bash
# Create specialized medical analysis flow # Create specialized medical analysis flow
tg-put-flow-class -n "medical-nlp" -c "$medical_config" tg-put-flow-blueprint -n "medical-nlp" -c "$medical_config"
``` ```
### Development Environments ### Development Environments
```bash ```bash
# Create lightweight development flow # Create lightweight development flow
tg-put-flow-class -n "dev-minimal" -c "$minimal_config" tg-put-flow-blueprint -n "dev-minimal" -c "$minimal_config"
``` ```
### Production Deployments ### Production Deployments
```bash ```bash
# Create robust production flow with all services # Create robust production flow with all services
tg-put-flow-class -n "production-full" -c "$production_config" tg-put-flow-blueprint -n "production-full" -c "$production_config"
``` ```
### Domain-Specific Workflows ### Domain-Specific Workflows
```bash ```bash
# Create legal document analysis flow # Create legal document analysis flow
tg-put-flow-class -n "legal-analysis" -c "$legal_config" tg-put-flow-blueprint -n "legal-analysis" -c "$legal_config"
``` ```
## Best Practices ## Best Practices
1. **Descriptive Names**: Use clear, descriptive flow class names 1. **Descriptive Names**: Use clear, descriptive flow blueprint names
2. **Comprehensive Descriptions**: Include detailed descriptions of flow capabilities 2. **Comprehensive Descriptions**: Include detailed descriptions of flow capabilities
3. **Consistent Naming**: Follow consistent queue naming conventions 3. **Consistent Naming**: Follow consistent queue naming conventions
4. **Version Control**: Store flow class configurations in version control 4. **Version Control**: Store flow blueprint configurations in version control
5. **Testing**: Test flow classes thoroughly before production use 5. **Testing**: Test flow blueprintes thoroughly before production use
6. **Documentation**: Document flow class purposes and requirements 6. **Documentation**: Document flow blueprint purposes and requirements
## Template Examples ## Template Examples
### Minimal Flow Class ### Minimal Flow Blueprint
```json ```json
{ {
"description": "Minimal text processing flow", "description": "Minimal text processing flow",
@ -368,7 +368,7 @@ tg-put-flow-class -n "legal-analysis" -c "$legal_config"
} }
``` ```
### RAG-Focused Flow Class ### RAG-Focused Flow Blueprint
```json ```json
{ {
"description": "Retrieval Augmented Generation flow", "description": "Retrieval Augmented Generation flow",
@ -389,7 +389,7 @@ tg-put-flow-class -n "legal-analysis" -c "$legal_config"
} }
``` ```
### Document Processing Flow Class ### Document Processing Flow Blueprint
```json ```json
{ {
"description": "Document ingestion and processing flow", "description": "Document ingestion and processing flow",

View file

@ -0,0 +1,330 @@
# tg-show-flow-blueprints
Lists all defined flow blueprintes in TrustGraph with their descriptions and tags.
## Synopsis
```bash
tg-show-flow-blueprints [options]
```
## Description
The `tg-show-flow-blueprints` command displays a formatted table of all flow blueprint definitions currently stored in TrustGraph. Each flow blueprint is shown with its name, description, and associated tags.
Flow blueprintes are templates that define the structure and services available for creating flow instances. This command helps you understand what flow blueprintes are available for use.
## Options
### Optional Arguments
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
## Examples
### List All Flow Blueprintes
```bash
tg-show-flow-blueprints
```
Output:
```
+-----------------+----------------------------------+----------------------+
| flow blueprint | description | tags |
+-----------------+----------------------------------+----------------------+
| document-proc | Document processing pipeline | production, nlp |
| data-analysis | Data analysis and visualization | analytics, dev |
| web-scraper | Web content extraction flow | scraping, batch |
| chat-assistant | Conversational AI assistant | ai, interactive |
+-----------------+----------------------------------+----------------------+
```
### Using Custom API URL
```bash
tg-show-flow-blueprints -u http://production:8088/
```
### Filter Flow Blueprintes
```bash
# Show only production-tagged flow blueprintes
tg-show-flow-blueprints | grep "production"
# Count total flow blueprintes
tg-show-flow-blueprints | grep -c "^|"
# Show flow blueprintes with specific patterns
tg-show-flow-blueprints | grep -E "(document|text|nlp)"
```
## Output Format
The command displays results in a formatted table with columns:
- **flow blueprint**: The unique name/identifier of the flow blueprint
- **description**: Human-readable description of the flow blueprint purpose
- **tags**: Comma-separated list of categorization tags
### Empty Results
If no flow blueprintes exist:
```
No flows.
```
## Use Cases
### Flow Blueprint Discovery
```bash
# Find available flow blueprintes for document processing
tg-show-flow-blueprints | grep -i document
# List all AI-related flow blueprintes
tg-show-flow-blueprints | grep -i "ai\|nlp\|chat\|assistant"
# Find development vs production flow blueprintes
tg-show-flow-blueprints | grep -E "(dev|test|staging)"
tg-show-flow-blueprints | grep "production"
```
### Flow Blueprint Management
```bash
# Get list of flow blueprint names for scripting
tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); print $2}' | grep -v "^$"
# Check if specific flow blueprint exists
if tg-show-flow-blueprints | grep -q "target-flow"; then
echo "Flow blueprint 'target-flow' exists"
else
echo "Flow blueprint 'target-flow' not found"
fi
```
### Environment Comparison
```bash
# Compare flow blueprintes between environments
echo "Development environment:"
tg-show-flow-blueprints -u http://dev:8088/
echo "Production environment:"
tg-show-flow-blueprints -u http://prod:8088/
```
### Reporting and Documentation
```bash
# Generate flow blueprint inventory report
echo "Flow Blueprint Inventory - $(date)" > flow-inventory.txt
echo "=====================================" >> flow-inventory.txt
tg-show-flow-blueprints >> flow-inventory.txt
# Create CSV export
echo "flow_class,description,tags" > flow-classes.csv
tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {
gsub(/^\| */, "", $0); gsub(/ *\|$/, "", $0);
gsub(/ *\| */, ",", $0); print $0
}' >> flow-classes.csv
```
## Error Handling
### Connection Errors
```bash
Exception: Connection refused
```
**Solution**: Check the API URL and ensure TrustGraph is running.
### Permission Errors
```bash
Exception: Access denied to list flow blueprintes
```
**Solution**: Verify user permissions for reading flow blueprint definitions.
### Network Timeouts
```bash
Exception: Request timeout
```
**Solution**: Check network connectivity and API server status.
## Integration with Other Commands
### Flow Blueprint Lifecycle
```bash
# 1. List available flow blueprintes
tg-show-flow-blueprints
# 2. Get details of specific flow blueprint
tg-get-flow-blueprint -n "interesting-flow"
# 3. Start flow instance from class
tg-start-flow -n "interesting-flow" -i "my-instance"
# 4. Monitor flow instance
tg-show-flows | grep "my-instance"
```
### Bulk Operations
```bash
# Process all flow blueprintes
tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
echo "Processing flow blueprint: $class_name"
tg-get-flow-blueprint -n "$class_name" > "backup-$class_name.json"
fi
done
```
### Automated Validation
```bash
# Check flow blueprint health
echo "Validating flow blueprintes..."
tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
echo -n "Checking $class_name... "
if tg-get-flow-blueprint -n "$class_name" > /dev/null 2>&1; then
echo "OK"
else
echo "ERROR"
fi
fi
done
```
## Advanced Usage
### Flow Blueprint Analysis
```bash
# Analyze flow blueprint distribution by tags
tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {
# Extract tags column
split($0, parts, "|");
tags = parts[4];
gsub(/^ *| *$/, "", tags);
if (tags) {
split(tags, tag_array, ",");
for (i in tag_array) {
gsub(/^ *| *$/, "", tag_array[i]);
if (tag_array[i]) print tag_array[i];
}
}
}' | sort | uniq -c | sort -nr
```
### Environment Synchronization
```bash
# Sync flow blueprintes between environments
echo "Synchronizing flow blueprintes from dev to staging..."
# Get list from development
dev_classes=$(tg-show-flow-blueprints -u http://dev:8088/ | \
awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}')
# Check each class in staging
for class in $dev_classes; do
if tg-show-flow-blueprints -u http://staging:8088/ | grep -q "$class"; then
echo "$class: Already exists in staging"
else
echo "$class: Missing in staging - needs sync"
# Get from dev and put to staging
tg-get-flow-blueprint -n "$class" -u http://dev:8088/ > temp-class.json
tg-put-flow-blueprint -n "$class" -c "$(cat temp-class.json)" -u http://staging:8088/
rm temp-class.json
fi
done
```
### Monitoring Script
```bash
#!/bin/bash
# monitor-flow-classes.sh
api_url="${1:-http://localhost:8088/}"
echo "Flow Blueprint Monitoring Report - $(date)"
echo "API URL: $api_url"
echo "----------------------------------------"
# Total count
total=$(tg-show-flow-blueprints -u "$api_url" | grep -c "^|" 2>/dev/null || echo "0")
echo "Total flow blueprintes: $((total - 3))" # Subtract header rows
# Tag analysis
echo -e "\nTag distribution:"
tg-show-flow-blueprints -u "$api_url" | awk 'NR>3 && /^\|/ {
split($0, parts, "|");
tags = parts[4];
gsub(/^ *| *$/, "", tags);
if (tags) {
split(tags, tag_array, ",");
for (i in tag_array) {
gsub(/^ *| *$/, "", tag_array[i]);
if (tag_array[i]) print tag_array[i];
}
}
}' | sort | uniq -c | sort -nr
# Health check
echo -e "\nHealth check:"
healthy=0
unhealthy=0
tg-show-flow-blueprints -u "$api_url" | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
if tg-get-flow-blueprint -n "$class_name" -u "$api_url" > /dev/null 2>&1; then
healthy=$((healthy + 1))
else
unhealthy=$((unhealthy + 1))
echo " ERROR: $class_name"
fi
fi
done
echo "Healthy: $healthy, Unhealthy: $unhealthy"
```
## Environment Variables
- `TRUSTGRAPH_URL`: Default API URL
## Related Commands
- [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve specific flow blueprint definitions
- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Create/update flow blueprint definitions
- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Delete flow blueprint definitions
- [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes
- [`tg-show-flows`](tg-show-flows.md) - List active flow instances
## API Integration
This command uses the [Flow API](../apis/api-flow.md) with the `list-classes` operation to retrieve flow blueprint listings.
## Best Practices
1. **Regular Inventory**: Periodically review available flow blueprintes
2. **Documentation**: Ensure flow blueprintes have meaningful descriptions
3. **Tagging**: Use consistent tagging for better organization
4. **Cleanup**: Remove unused or deprecated flow blueprintes
5. **Monitoring**: Include flow blueprint health checks in monitoring
6. **Environment Parity**: Keep flow blueprintes synchronized across environments
## Troubleshooting
### No Output
```bash
# If command returns no output, check API connectivity
tg-show-flow-blueprints -u http://localhost:8088/
# Verify TrustGraph is running and accessible
```
### Formatting Issues
```bash
# If table formatting is broken, check terminal width
export COLUMNS=120
tg-show-flow-blueprints
```
### Missing Flow Blueprintes
```bash
# If expected flow blueprintes are missing, verify:
# 1. Correct API URL
# 2. Database connectivity
# 3. Flow blueprint definitions are properly stored
```

View file

@ -1,330 +0,0 @@
# tg-show-flow-classes
Lists all defined flow classes in TrustGraph with their descriptions and tags.
## Synopsis
```bash
tg-show-flow-classes [options]
```
## Description
The `tg-show-flow-classes` command displays a formatted table of all flow class definitions currently stored in TrustGraph. Each flow class is shown with its name, description, and associated tags.
Flow classes are templates that define the structure and services available for creating flow instances. This command helps you understand what flow classes are available for use.
## Options
### Optional Arguments
- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`)
## Examples
### List All Flow Classes
```bash
tg-show-flow-classes
```
Output:
```
+-----------------+----------------------------------+----------------------+
| flow class | description | tags |
+-----------------+----------------------------------+----------------------+
| document-proc | Document processing pipeline | production, nlp |
| data-analysis | Data analysis and visualization | analytics, dev |
| web-scraper | Web content extraction flow | scraping, batch |
| chat-assistant | Conversational AI assistant | ai, interactive |
+-----------------+----------------------------------+----------------------+
```
### Using Custom API URL
```bash
tg-show-flow-classes -u http://production:8088/
```
### Filter Flow Classes
```bash
# Show only production-tagged flow classes
tg-show-flow-classes | grep "production"
# Count total flow classes
tg-show-flow-classes | grep -c "^|"
# Show flow classes with specific patterns
tg-show-flow-classes | grep -E "(document|text|nlp)"
```
## Output Format
The command displays results in a formatted table with columns:
- **flow class**: The unique name/identifier of the flow class
- **description**: Human-readable description of the flow class purpose
- **tags**: Comma-separated list of categorization tags
### Empty Results
If no flow classes exist:
```
No flows.
```
## Use Cases
### Flow Class Discovery
```bash
# Find available flow classes for document processing
tg-show-flow-classes | grep -i document
# List all AI-related flow classes
tg-show-flow-classes | grep -i "ai\|nlp\|chat\|assistant"
# Find development vs production flow classes
tg-show-flow-classes | grep -E "(dev|test|staging)"
tg-show-flow-classes | grep "production"
```
### Flow Class Management
```bash
# Get list of flow class names for scripting
tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); print $2}' | grep -v "^$"
# Check if specific flow class exists
if tg-show-flow-classes | grep -q "target-flow"; then
echo "Flow class 'target-flow' exists"
else
echo "Flow class 'target-flow' not found"
fi
```
### Environment Comparison
```bash
# Compare flow classes between environments
echo "Development environment:"
tg-show-flow-classes -u http://dev:8088/
echo "Production environment:"
tg-show-flow-classes -u http://prod:8088/
```
### Reporting and Documentation
```bash
# Generate flow class inventory report
echo "Flow Class Inventory - $(date)" > flow-inventory.txt
echo "=====================================" >> flow-inventory.txt
tg-show-flow-classes >> flow-inventory.txt
# Create CSV export
echo "flow_class,description,tags" > flow-classes.csv
tg-show-flow-classes | awk 'NR>3 && /^\|/ {
gsub(/^\| */, "", $0); gsub(/ *\|$/, "", $0);
gsub(/ *\| */, ",", $0); print $0
}' >> flow-classes.csv
```
## Error Handling
### Connection Errors
```bash
Exception: Connection refused
```
**Solution**: Check the API URL and ensure TrustGraph is running.
### Permission Errors
```bash
Exception: Access denied to list flow classes
```
**Solution**: Verify user permissions for reading flow class definitions.
### Network Timeouts
```bash
Exception: Request timeout
```
**Solution**: Check network connectivity and API server status.
## Integration with Other Commands
### Flow Class Lifecycle
```bash
# 1. List available flow classes
tg-show-flow-classes
# 2. Get details of specific flow class
tg-get-flow-class -n "interesting-flow"
# 3. Start flow instance from class
tg-start-flow -n "interesting-flow" -i "my-instance"
# 4. Monitor flow instance
tg-show-flows | grep "my-instance"
```
### Bulk Operations
```bash
# Process all flow classes
tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
echo "Processing flow class: $class_name"
tg-get-flow-class -n "$class_name" > "backup-$class_name.json"
fi
done
```
### Automated Validation
```bash
# Check flow class health
echo "Validating flow classes..."
tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
echo -n "Checking $class_name... "
if tg-get-flow-class -n "$class_name" > /dev/null 2>&1; then
echo "OK"
else
echo "ERROR"
fi
fi
done
```
## Advanced Usage
### Flow Class Analysis
```bash
# Analyze flow class distribution by tags
tg-show-flow-classes | awk 'NR>3 && /^\|/ {
# Extract tags column
split($0, parts, "|");
tags = parts[4];
gsub(/^ *| *$/, "", tags);
if (tags) {
split(tags, tag_array, ",");
for (i in tag_array) {
gsub(/^ *| *$/, "", tag_array[i]);
if (tag_array[i]) print tag_array[i];
}
}
}' | sort | uniq -c | sort -nr
```
### Environment Synchronization
```bash
# Sync flow classes between environments
echo "Synchronizing flow classes from dev to staging..."
# Get list from development
dev_classes=$(tg-show-flow-classes -u http://dev:8088/ | \
awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}')
# Check each class in staging
for class in $dev_classes; do
if tg-show-flow-classes -u http://staging:8088/ | grep -q "$class"; then
echo "$class: Already exists in staging"
else
echo "$class: Missing in staging - needs sync"
# Get from dev and put to staging
tg-get-flow-class -n "$class" -u http://dev:8088/ > temp-class.json
tg-put-flow-class -n "$class" -c "$(cat temp-class.json)" -u http://staging:8088/
rm temp-class.json
fi
done
```
### Monitoring Script
```bash
#!/bin/bash
# monitor-flow-classes.sh
api_url="${1:-http://localhost:8088/}"
echo "Flow Class Monitoring Report - $(date)"
echo "API URL: $api_url"
echo "----------------------------------------"
# Total count
total=$(tg-show-flow-classes -u "$api_url" | grep -c "^|" 2>/dev/null || echo "0")
echo "Total flow classes: $((total - 3))" # Subtract header rows
# Tag analysis
echo -e "\nTag distribution:"
tg-show-flow-classes -u "$api_url" | awk 'NR>3 && /^\|/ {
split($0, parts, "|");
tags = parts[4];
gsub(/^ *| *$/, "", tags);
if (tags) {
split(tags, tag_array, ",");
for (i in tag_array) {
gsub(/^ *| *$/, "", tag_array[i]);
if (tag_array[i]) print tag_array[i];
}
}
}' | sort | uniq -c | sort -nr
# Health check
echo -e "\nHealth check:"
healthy=0
unhealthy=0
tg-show-flow-classes -u "$api_url" | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \
while read class_name; do
if [ -n "$class_name" ]; then
if tg-get-flow-class -n "$class_name" -u "$api_url" > /dev/null 2>&1; then
healthy=$((healthy + 1))
else
unhealthy=$((unhealthy + 1))
echo " ERROR: $class_name"
fi
fi
done
echo "Healthy: $healthy, Unhealthy: $unhealthy"
```
## Environment Variables
- `TRUSTGRAPH_URL`: Default API URL
## Related Commands
- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve specific flow class definitions
- [`tg-put-flow-class`](tg-put-flow-class.md) - Create/update flow class definitions
- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Delete flow class definitions
- [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes
- [`tg-show-flows`](tg-show-flows.md) - List active flow instances
## API Integration
This command uses the [Flow API](../apis/api-flow.md) with the `list-classes` operation to retrieve flow class listings.
## Best Practices
1. **Regular Inventory**: Periodically review available flow classes
2. **Documentation**: Ensure flow classes have meaningful descriptions
3. **Tagging**: Use consistent tagging for better organization
4. **Cleanup**: Remove unused or deprecated flow classes
5. **Monitoring**: Include flow class health checks in monitoring
6. **Environment Parity**: Keep flow classes synchronized across environments
## Troubleshooting
### No Output
```bash
# If command returns no output, check API connectivity
tg-show-flow-classes -u http://localhost:8088/
# Verify TrustGraph is running and accessible
```
### Formatting Issues
```bash
# If table formatting is broken, check terminal width
export COLUMNS=120
tg-show-flow-classes
```
### Missing Flow Classes
```bash
# If expected flow classes are missing, verify:
# 1. Correct API URL
# 2. Database connectivity
# 3. Flow class definitions are properly stored
```

View file

@ -16,15 +16,15 @@ def dump_status(metrics_url, api_url, flow_id, token=None):
api = Api(api_url, token=token).flow() api = Api(api_url, token=token).flow()
flow = api.get(flow_id) flow = api.get(flow_id)
class_name = flow["class-name"] blueprint_name = flow["blueprint-name"]
print() print()
print(f"Flow {flow_id}") print(f"Flow {flow_id}")
show_processors(metrics_url, flow_id) show_processors(metrics_url, flow_id)
print() print()
print(f"Class {class_name}") print(f"Blueprint {blueprint_name}")
show_processors(metrics_url, class_name) show_processors(metrics_url, blueprint_name)
print() print()