API Operations#
The bfabric-cli api command provides generic CRUD (Create, Read, Update, Delete) operations on all B-Fabric entity types from the command line.
Note
Use the CLI when you need quick one-off operations, want to test API calls, or prefer working from the terminal. For complex workflows, automated processing, or programmatic logic, use the Python API instead.
Overview#
bfabric-cli api --help
Subcommand |
Purpose |
|---|---|
|
Create new entities |
|
Query and retrieve entities |
|
Modify existing entities |
|
Remove entities |
|
Inspect SOAP API structure |
Reading Entities#
Basic Usage#
bfabric-cli api read [ENDPOINT] [QUERY] [OPTIONS]
Parameters#
Parameter |
Required |
Description |
|---|---|---|
|
Yes |
Entity type (e.g., |
|
No |
Key-value pairs to filter results |
|
No |
Output: |
|
No |
Maximum results (default: 100) |
|
No |
Comma-separated columns to display |
|
No |
Write output to file |
Examples#
# List recent resources
bfabric-cli api read resource --limit 10
# Filter by columns
bfabric-cli api read resource --limit 10 --columns id,name,relativepath
# Query by multiple criteria
bfabric-cli api read resource createdby pfeeder createdafter 2024-05-01
# Query multiple IDs
bfabric-cli api read resource id 2784586 id 2784576
# Output formats
bfabric-cli api read resource --limit 10 --format json
bfabric-cli api read resource --limit 10 --format tsv
# Save to file
bfabric-cli api read resource --limit 100 --format json --file results.json
Creating Entities#
Basic Usage#
bfabric-cli api create [ENDPOINT] [ATTRIBUTES]
Examples#
# Create a resource
bfabric-cli api create resource name "hello.txt" workunitid 321802 base64 aGVsbG8=
# Create a sample
bfabric-cli api create sample name "My Sample" containerid 1234
Updating Entities#
Basic Usage#
bfabric-cli api update [ENDPOINT] [ENTITY_ID] [ATTRIBUTES]
Examples#
# Update a workunit
bfabric-cli api update workunit 321802 description "Updated description"
# Update multiple attributes
bfabric-cli api update sample 12345 name "New Name" description "Updated"
# Skip confirmation (use with caution!)
bfabric-cli api update resource 12345 name "New Name" --no-confirm
Deleting Entities#
Basic Usage#
bfabric-cli api delete [ENDPOINT] [ID] [OPTIONS]
Examples#
# Delete a single entity
bfabric-cli api delete resource 12345
# Delete multiple entities
bfabric-cli api delete resource 12345 12346 12347
# Skip confirmation (dangerous!)
bfabric-cli api delete resource 12345 --no-confirm
Inspecting API Structure#
For detailed information about discovering endpoints and understanding API structure, see API Inspection.
# Quick inspect
bfabric-cli api inspect [ENDPOINT] [METHOD]
Common Entity Types#
Endpoint |
Description |
|---|---|
|
File resources |
|
Samples |
|
Workunits/jobs |
|
Datasets |
|
Projects |
|
Containers |
|
Applications |
|
Application executables |
|
Import resources |
Tips#
Test with small limits first:
bfabric-cli api read resource --limit 5Use named parameters:
--limit 10is clearer than positional10Save output:
--file results.jsonfor further processingCheck Python equivalence: CLI shows the equivalent Python code on stderr
See Also#
Python API: Writing Data - Programmatic write operations
CLI Reference: Datasets - Dataset-specific operations
CLI Reference: Workunits - Workunit-specific operations