2026-01-14 12:31:40 +00:00
# tg-delete-flow-blueprint
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
Permanently deletes a flow blueprint definition from TrustGraph.
2025-07-03 14:58:32 +01:00
## Synopsis
```bash
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n CLASS_NAME [options]
2025-07-03 14:58:32 +01:00
```
## Description
2026-01-14 12:31:40 +00:00
The `tg-delete-flow-blueprint` command permanently removes a flow blueprint definition from TrustGraph. This operation cannot be undone, so use with caution.
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
**⚠️ Warning**: Deleting a flow blueprint that has active flow instances may cause those instances to become unusable. Always check for active flows before deletion.
2025-07-03 14:58:32 +01:00
## Options
### Required Arguments
2026-01-14 12:31:40 +00:00
- `-n, --blueprint-name CLASS_NAME` : Name of the flow blueprint to delete
2025-07-03 14:58:32 +01:00
### Optional Arguments
- `-u, --api-url URL` : TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/` )
## Examples
2026-01-14 12:31:40 +00:00
### Delete a Flow Blueprint
2025-07-03 14:58:32 +01:00
```bash
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n "old-test-flow"
2025-07-03 14:58:32 +01:00
```
### Delete with Custom API URL
```bash
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n "deprecated-flow" -u http://staging:8088/
2025-07-03 14:58:32 +01:00
```
### Safe Deletion Workflow
```bash
2026-01-14 12:31:40 +00:00
# 1. Check if flow blueprint exists
tg-show-flow-blueprints | grep "target-flow"
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
# 2. Backup the flow blueprint first
tg-get-flow-blueprint -n "target-flow" > backup-target-flow.json
2025-07-03 14:58:32 +01:00
# 3. Check for active flow instances
tg-show-flows | grep "target-flow"
2026-01-14 12:31:40 +00:00
# 4. Delete the flow blueprint
tg-delete-flow-blueprint -n "target-flow"
2025-07-03 14:58:32 +01:00
# 5. Verify deletion
2026-01-14 12:31:40 +00:00
tg-show-flow-blueprints | grep "target-flow" || echo "Flow blueprint deleted successfully"
2025-07-03 14:58:32 +01:00
```
## Prerequisites
2026-01-14 12:31:40 +00:00
### Flow Blueprint Must Exist
Verify the flow blueprint exists before attempting deletion:
2025-07-03 14:58:32 +01:00
```bash
2026-01-14 12:31:40 +00:00
# List all flow blueprintes
tg-show-flow-blueprints
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
# Check specific flow blueprint
tg-show-flow-blueprints | grep "target-class"
2025-07-03 14:58:32 +01:00
```
### Check for Active Flow Instances
2026-01-14 12:31:40 +00:00
Before deleting a flow blueprint, check if any flow instances are using it:
2025-07-03 14:58:32 +01:00
```bash
# List all active flows
tg-show-flows
2026-01-14 12:31:40 +00:00
# Look for instances using the flow blueprint
2025-07-03 14:58:32 +01:00
tg-show-flows | grep "target-class"
```
## Error Handling
2026-01-14 12:31:40 +00:00
### Flow Blueprint Not Found
2025-07-03 14:58:32 +01:00
```bash
2026-01-14 12:31:40 +00:00
Exception: Flow blueprint 'nonexistent-class' not found
2025-07-03 14:58:32 +01:00
```
2026-01-14 12:31:40 +00:00
**Solution**: Verify the flow blueprint exists with `tg-show-flow-blueprints` .
2025-07-03 14:58:32 +01:00
### Connection Errors
```bash
Exception: Connection refused
```
**Solution**: Check the API URL and ensure TrustGraph is running.
### Permission Errors
```bash
2026-01-14 12:31:40 +00:00
Exception: Access denied to delete flow blueprint
2025-07-03 14:58:32 +01:00
```
2026-01-14 12:31:40 +00:00
**Solution**: Verify user permissions for flow blueprint management.
2025-07-03 14:58:32 +01:00
### Active Flow Instances
```bash
2026-01-14 12:31:40 +00:00
Exception: Cannot delete flow blueprint with active instances
2025-07-03 14:58:32 +01:00
```
**Solution**: Stop all flow instances using this class before deletion.
## Use Cases
### Cleanup Development Classes
```bash
2026-01-14 12:31:40 +00:00
# Delete test and development flow blueprintes
2025-07-03 14:58:32 +01:00
test_classes=("test-flow-v1" "dev-experiment" "prototype-flow")
for class in "${test_classes[@]}"; do
echo "Deleting $class..."
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n "$class"
2025-07-03 14:58:32 +01:00
done
```
### Migration Cleanup
```bash
2026-01-14 12:31:40 +00:00
# After migrating to new flow blueprintes, remove old ones
2025-07-03 14:58:32 +01:00
old_classes=("legacy-flow" "deprecated-processor" "old-pipeline")
for class in "${old_classes[@]}"; do
# Backup first
2026-01-14 12:31:40 +00:00
tg-get-flow-blueprint -n "$class" > "backup-$class.json" 2>/dev/null
2025-07-03 14:58:32 +01:00
# Delete
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n "$class"
2025-07-03 14:58:32 +01:00
echo "Deleted $class"
done
```
### Conditional Deletion
```bash
2026-01-14 12:31:40 +00:00
# Delete flow blueprint only if no active instances exist
2025-07-03 14:58:32 +01:00
flow_class="target-flow"
active_instances=$(tg-show-flows | grep "$flow_class" | wc -l)
if [ $active_instances -eq 0 ]; then
2026-01-14 12:31:40 +00:00
echo "No active instances found, deleting flow blueprint..."
tg-delete-flow-blueprint -n "$flow_class"
2025-07-03 14:58:32 +01:00
else
echo "Warning: $active_instances active instances found. Cannot delete."
tg-show-flows | grep "$flow_class"
fi
```
## Safety Considerations
### Always Backup First
```bash
# Create backup before deletion
flow_class="important-flow"
backup_dir="flow-class-backups/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
2026-01-14 12:31:40 +00:00
echo "Backing up flow blueprint: $flow_class"
tg-get-flow-blueprint -n "$flow_class" > "$backup_dir/$flow_class.json"
2025-07-03 14:58:32 +01:00
if [ $? -eq 0 ]; then
echo "Backup created: $backup_dir/$flow_class.json"
echo "Proceeding with deletion..."
2026-01-14 12:31:40 +00:00
tg-delete-flow-blueprint -n "$flow_class"
2025-07-03 14:58:32 +01:00
else
echo "Backup failed. Aborting deletion."
exit 1
fi
```
### Verification Script
```bash
#!/bin/bash
# safe-delete-flow-class.sh
flow_class="$1"
if [ -z "$flow_class" ]; then
2026-01-14 12:31:40 +00:00
echo "Usage: $0 < flow-blueprint-name > "
2025-07-03 14:58:32 +01:00
exit 1
fi
2026-01-14 12:31:40 +00:00
echo "Safety checks for deleting flow blueprint: $flow_class"
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
# Check if flow blueprint exists
if ! tg-show-flow-blueprints | grep -q "$flow_class"; then
echo "ERROR: Flow blueprint '$flow_class' not found"
2025-07-03 14:58:32 +01:00
exit 1
fi
# Check for active instances
active_count=$(tg-show-flows | grep "$flow_class" | wc -l)
if [ $active_count -gt 0 ]; then
2026-01-14 12:31:40 +00:00
echo "ERROR: Found $active_count active instances using this flow blueprint"
2025-07-03 14:58:32 +01:00
echo "Active instances:"
tg-show-flows | grep "$flow_class"
exit 1
fi
# Create backup
backup_file="backup-$flow_class-$(date +%Y%m%d-%H%M%S).json"
echo "Creating backup: $backup_file"
2026-01-14 12:31:40 +00:00
tg-get-flow-blueprint -n "$flow_class" > "$backup_file"
2025-07-03 14:58:32 +01:00
if [ $? -ne 0 ]; then
echo "ERROR: Failed to create backup"
exit 1
fi
# Confirm deletion
2026-01-14 12:31:40 +00:00
echo "Ready to delete flow blueprint: $flow_class"
2025-07-03 14:58:32 +01:00
echo "Backup saved as: $backup_file"
2026-01-14 12:31:40 +00:00
read -p "Are you sure you want to delete this flow blueprint? (y/N): " confirm
2025-07-03 14:58:32 +01:00
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
2026-01-14 12:31:40 +00:00
echo "Deleting flow blueprint..."
tg-delete-flow-blueprint -n "$flow_class"
2025-07-03 14:58:32 +01:00
# Verify deletion
2026-01-14 12:31:40 +00:00
if ! tg-show-flow-blueprints | grep -q "$flow_class"; then
echo "Flow blueprint deleted successfully"
2025-07-03 14:58:32 +01:00
else
2026-01-14 12:31:40 +00:00
echo "ERROR: Flow blueprint still exists after deletion"
2025-07-03 14:58:32 +01:00
exit 1
fi
else
echo "Deletion cancelled"
rm "$backup_file"
fi
```
## Integration with Other Commands
2026-01-14 12:31:40 +00:00
### Complete Flow Blueprint Lifecycle
2025-07-03 14:58:32 +01:00
```bash
2026-01-14 12:31:40 +00:00
# 1. List existing flow blueprintes
tg-show-flow-blueprints
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
# 2. Get flow blueprint details
tg-get-flow-blueprint -n "target-flow"
2025-07-03 14:58:32 +01:00
# 3. Check for active instances
tg-show-flows | grep "target-flow"
# 4. Stop active instances if needed
tg-stop-flow -i "instance-id"
# 5. Create backup
2026-01-14 12:31:40 +00:00
tg-get-flow-blueprint -n "target-flow" > backup.json
2025-07-03 14:58:32 +01:00
2026-01-14 12:31:40 +00:00
# 6. Delete flow blueprint
tg-delete-flow-blueprint -n "target-flow"
2025-07-03 14:58:32 +01:00
# 7. Verify deletion
2026-01-14 12:31:40 +00:00
tg-show-flow-blueprints | grep "target-flow"
2025-07-03 14:58:32 +01:00
```
### Bulk Deletion with Validation
```bash
2026-01-14 12:31:40 +00:00
# Delete multiple flow blueprintes safely
2025-07-03 14:58:32 +01:00
classes_to_delete=("old-flow1" "old-flow2" "test-flow")
for class in "${classes_to_delete[@]}"; do
echo "Processing $class..."
# Check if exists
2026-01-14 12:31:40 +00:00
if ! tg-show-flow-blueprints | grep -q "$class"; then
2025-07-03 14:58:32 +01:00
echo " $class not found, skipping"
continue
fi
# Check for active instances
if tg-show-flows | grep -q "$class"; then
echo " $class has active instances, skipping"
continue
fi
# Backup and delete
2026-01-14 12:31:40 +00:00
tg-get-flow-blueprint -n "$class" > "backup-$class.json"
tg-delete-flow-blueprint -n "$class"
2025-07-03 14:58:32 +01:00
echo " $class deleted"
done
```
## Environment Variables
- `TRUSTGRAPH_URL` : Default API URL
## Related Commands
2026-01-14 12:31:40 +00:00
- [`tg-show-flow-blueprints` ](tg-show-flow-blueprints.md ) - List available flow blueprintes
- [`tg-get-flow-blueprint` ](tg-get-flow-blueprint.md ) - Retrieve flow blueprint definitions
- [`tg-put-flow-blueprint` ](tg-put-flow-blueprint.md ) - Create/update flow blueprint definitions
2025-07-03 14:58:32 +01:00
- [`tg-show-flows` ](tg-show-flows.md ) - List active flow instances
- [`tg-stop-flow` ](tg-stop-flow.md ) - Stop flow instances
## API Integration
2026-01-14 12:31:40 +00:00
This command uses the [Flow API ](../apis/api-flow.md ) with the `delete-class` operation to remove flow blueprint definitions.
2025-07-03 14:58:32 +01:00
## Best Practices
1. **Always Backup** : Create backups before deletion
2. **Check Dependencies** : Verify no active flow instances exist
3. **Confirmation** : Use interactive confirmation for important deletions
4. **Logging** : Log deletion operations for audit trails
5. **Permissions** : Ensure appropriate access controls for deletion operations
6. **Testing** : Test deletion procedures in non-production environments first
## Troubleshooting
### Command Succeeds but Class Still Exists
```bash
# Check if deletion actually occurred
2026-01-14 12:31:40 +00:00
tg-show-flow-blueprints | grep "deleted-class"
2025-07-03 14:58:32 +01:00
# Verify API connectivity
2026-01-14 12:31:40 +00:00
tg-show-flow-blueprints > /dev/null & & echo "API accessible"
2025-07-03 14:58:32 +01:00
```
### Permissions Issues
```bash
# Verify user has deletion permissions
# Contact system administrator if access denied
```
### Network Connectivity
```bash
# Test API connectivity
curl -s "$TRUSTGRAPH_URL/api/v1/flow/classes" > /dev/null
echo "API response: $?"
```