A Ruby command-line application for managing assets, racks, templates, roles, and permissions through the Asset Rack REST API.
The CLI provides both a traditional command-based interface using Dry::CLI and an interactive terminal interface built with TTY::Prompt.
- 🔐 JWT authentication
- ⚙️ Configurable API endpoint
- 🖥 Interactive terminal interface
- 📦 Asset management
- 🗄 Rack management
- 📋 Template management
- 👥 Role management
- 🔑 Permission browser
- 📊 Statistics
- 🎨 Pretty terminal tables using TTY::Table
Install dependencies:
bundle installConfigure the API endpoint:
./bin/redfish-inventory config set-url http://localhost:3000/api/v1Replace the URL with your Asset Rack API server.
The URL is stored locally, so this only needs to be configured once.
Run the CLI:
./bin/redfish-inventoryor launch the interactive interface:
./bin/redfish-inventory interactiveView the configured API endpoint:
./bin/redfish-inventory config set-url http://localhost:3000/api/v1You can run the command again at any time to point the CLI at another Asset Rack API instance.
./bin/redfish-inventory loginYou'll be prompted for:
- Username
- Password
The CLI securely stores your JWT token and automatically includes it with future API requests.
./bin/redfish-inventory remove-token./bin/redfish-inventory assets listDisplays all assets in a formatted table.
./bin/redfish-inventory assets show <id>Displays:
- Asset details
- Selected JSON fields
- Option to display the stored JSON document
./bin/redfish-inventory assets create <json-file> \
name="Server 1" \
rackId=1 \
size=2 \
position=4Features:
- Reads a JSON document
- Interactive JSON path search
- Select multiple fields
- Assign friendly field names
- Upload original JSON alongside metadata
./bin/redfish-inventory assets update <id> \
name="Updated Server"Supports updating:
- Name
- Rack
- Position
- Size
./bin/redfish-inventory assets update-json <id> file.jsonReplaces the stored JSON while preserving asset metadata.
./bin/redfish-inventory assets delete <id>./bin/redfish-inventory assets show-version <id> <version>./bin/redfish-inventory assets add-data <id>Interactively searches JSON and adds additional tracked fields.
./bin/redfish-inventory assets delete-data <id>./bin/redfish-inventory racks listDisplays racks in a formatted table.
./bin/redfish-inventory racks show <id>Displays:
- ID
- Name
- Size
- Notes
./bin/redfish-inventory racks create \
name="Rack A" \
size=42 \
notes="GPU Rack"./bin/redfish-inventory racks update <id>Supports updating:
- Name
- Size
- Notes
./bin/redfish-inventory racks delete <id>./bin/redfish-inventory racks list-assets <id>./bin/redfish-inventory templates list./bin/redfish-inventory templates show <id>Displays template information and associated JSON paths.
./bin/redfish-inventory templates createInteractive creation of reusable templates.
./bin/redfish-inventory templates update-name <id>./bin/redfish-inventory templates add-path <id>./bin/redfish-inventory templates update-path <template-id> <path-id>./bin/redfish-inventory templates delete <id>./bin/redfish-inventory roles listDisplays:
- Role ID
- Role Name
- Permission Count
./bin/redfish-inventory roles show <id>Displays:
- Role details
- Assigned permissions
./bin/redfish-inventory roles create \
--name="Rack Viewer" \
--permissions=4,7Creates a role with the selected permissions.
./bin/redfish-inventory roles add-permissions <id> \
--permissions=4,7Adds permissions to an existing role.
./bin/redfish-inventory roles remove-permissions <id> \
--permissions=4,7Removes permissions from an existing role.
The CLI validates that the selected permissions currently exist before attempting removal.
./bin/redfish-inventory roles delete <id>./bin/redfish-inventory permissions listDisplays every available permission in a formatted table.
./bin/redfish-inventory stats./bin/redfish-inventory stats racks./bin/redfish-inventory stats assetsLaunch the interactive interface:
./bin/redfish-inventory interactiveThe interactive interface provides menu-driven navigation for the majority of CLI functionality.
- List Assets
- Show Asset
- Create Asset
- Update Asset
- Delete Asset
- Manage Asset Data
- View JSON
- Browse JSON History
- List Racks
- Show Rack
- Create Rack
- Delete Rack
- Browse Assets in a Rack
- List Templates
- Show Template
- Create Template
- Delete Template
- Manage Template Paths
- List Roles
- Show Role
- Create Role
- Alter Permissions
- Delete Role
- Browse all available permissions
- Overall Statistics
- Rack Statistics
- Asset Statistics
- Ruby
- Dry::CLI
- TTY::Prompt
- TTY::Table
- Net::HTTP
- JSON
The CLI communicates with the Asset Rack REST API using authenticated JSON requests.
Authentication uses JWT Bearer tokens stored locally after a successful login.
lib/
├── auth/
├── commands/
├── dry_cli/
├── interactive/
├── api_client.rb
├── config.rb
├── config_store.rb
├── errors.rb
└── json_field_selector.rb