redisctl 0.2.0

Unified CLI for Redis Cloud and Enterprise
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# redisctl

[![CI](https://github.com/joshrotenberg/redisctl/actions/workflows/ci.yml/badge.svg)](https://github.com/joshrotenberg/redisctl/actions/workflows/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/redisctl.svg)](https://crates.io/crates/redisctl)
[![Documentation](https://docs.rs/redisctl/badge.svg)](https://docs.rs/redisctl)
[![License](https://img.shields.io/crates/l/redisctl.svg)](https://github.com/joshrotenberg/redisctl/blob/main/LICENSE-MIT)

A unified command-line interface for managing Redis deployments across Cloud and Enterprise.

## Overview

`redisctl` is a comprehensive CLI and Rust library that unifies management of both Redis Cloud and Redis Enterprise deployments. It automatically detects which API to use based on your configuration profile or explicit command selection, providing a consistent interface for all Redis management tasks.

## Features

### Core Capabilities
- **Unified Interface** - Single CLI for both Redis Cloud and Enterprise
- **Smart Command Routing** - Automatically routes commands based on deployment type
- **Profile Management** - Save and switch between multiple Redis deployments
- **Multiple Output Formats** - JSON, YAML, and Table output with JMESPath queries
- **Type-Safe Rust Libraries** - Build custom tools with our async Rust client libraries
- **Comprehensive API Coverage** - Full implementation of both Cloud and Enterprise REST APIs

### Advanced Features
- **Cluster Initialization** - Bootstrap and configure new Enterprise clusters
- **Backup & Restore** - Automated backup management and recovery
- **VPC Peering & Transit Gateway** - Complete networking management for Cloud
- **ACL Management** - Database access control and security rules
- **Docker Integration** - Easy local testing with Redis Enterprise
- **Raw API Access** - Direct access to any API endpoint

## Installation

### CLI Tool (Recommended for most users)
```bash
# Install the CLI tool
cargo install redisctl
```

### Rust Libraries (For developers building custom tools)

This project also provides **comprehensive Rust client libraries** for both Redis Cloud and Enterprise REST APIs:

```toml
# Add to your Cargo.toml
[dependencies]
redis-cloud = "0.1.0"       # Full Redis Cloud REST API client
redis-enterprise = "0.1.0"  # Full Redis Enterprise REST API client
```

These libraries offer:
- **100% API coverage** - Every documented endpoint implemented
- **Full type safety** - Strongly typed request/response structures
- **Async/await** - Modern async Rust with Tokio
- **Builder patterns** - Ergonomic client configuration
- **Comprehensive testing** - Battle-tested with 500+ tests

Perfect for building custom automation, integrations, or management tools.

### From Source
```bash
# Clone and build
git clone https://github.com/joshrotenberg/redisctl.git
cd redisctl
cargo build --release

# Install to PATH
cargo install --path crates/redisctl

# Or use the binary directly
./target/release/redisctl --help
```

### Platform-Specific Binaries
```bash
# Build Cloud-only binary (smaller size)
cargo build --release --features cloud-only --bin redis-cloud

# Build Enterprise-only binary (smaller size)
cargo build --release --features enterprise-only --bin redis-enterprise

# Build unified binary (default, includes both)
cargo build --release --bin redisctl
```

### Using Docker Hub Image

The official Docker images are available on Docker Hub at [joshrotenberg/redisctl](https://hub.docker.com/r/joshrotenberg/redisctl):

#### Available Tags
- `latest` - Latest stable release
- `v0.1.0`, `v0.2.0`, etc. - Specific version tags
- `main` - Latest development build from main branch

```bash
# Pull the latest image
docker pull joshrotenberg/redisctl:latest

# Or pull a specific version
docker pull joshrotenberg/redisctl:v0.1.0

# Run a command directly
docker run --rm joshrotenberg/redisctl:latest --help

# Use with environment variables for Redis Cloud
docker run --rm \
  -e REDIS_CLOUD_API_KEY="your-key" \
  -e REDIS_CLOUD_API_SECRET="your-secret" \
  joshrotenberg/redisctl:latest cloud subscription list

# Use with environment variables for Redis Enterprise
docker run --rm \
  -e REDIS_ENTERPRISE_URL="https://your-cluster:9443" \
  -e REDIS_ENTERPRISE_USER="admin@example.com" \
  -e REDIS_ENTERPRISE_PASSWORD="your-password" \
  -e REDIS_ENTERPRISE_INSECURE="true" \
  joshrotenberg/redisctl:latest enterprise cluster info

# Run interactively with a shell
docker run -it --rm \
  -e REDIS_ENTERPRISE_URL="https://your-cluster:9443" \
  -e REDIS_ENTERPRISE_USER="admin@example.com" \
  -e REDIS_ENTERPRISE_PASSWORD="your-password" \
  --entrypoint /bin/sh \
  joshrotenberg/redisctl:latest
```

### Local Development with Docker Compose
```bash
# Start Redis Enterprise cluster with initialization
docker compose up -d

# Check cluster status
docker compose logs init-cluster

# Watch logs
docker compose logs -f

# Clean up
docker compose down -v
```

## Quick Start

### 1. Configure Authentication

#### Option 1: Interactive Setup Wizard (Recommended)
```bash
# Launch guided setup for any deployment type
redisctl auth setup

# Test your authentication
redisctl auth test
```

The interactive setup wizard will:
- Guide you through credential collection
- Test authentication during setup
- Create and save working profiles
- Set up your first profile as default

#### Option 2: Manual Profile Creation

##### Redis Cloud
```bash
# Create a Cloud profile manually
redisctl profile set prod-cloud cloud \
  --api-key "your-api-key" \
  --api-secret "your-api-secret"

# Set as default profile
redisctl profile default prod-cloud
```

##### Redis Enterprise
```bash
# Create an Enterprise profile manually
redisctl profile set prod-enterprise enterprise \
  --url https://cluster:9443 \
  --username admin@example.com \
  --password your-password
```

#### Option 3: Environment Variables
```bash
# Redis Cloud
export REDIS_CLOUD_API_KEY="your-api-key"
export REDIS_CLOUD_API_SECRET="your-api-secret"

# Redis Enterprise
export REDIS_ENTERPRISE_URL="https://cluster.example.com:9443"
export REDIS_ENTERPRISE_USER="admin@example.com"  
export REDIS_ENTERPRISE_PASSWORD="your-password"

# Test authentication works
redisctl auth test
```

### 2. Verify Your Setup

```bash
# Test authentication for any profile or environment vars
redisctl auth test
redisctl auth test --profile prod-cloud

# View your configuration
redisctl config show

# Validate all profiles  
redisctl config validate

# Find your config file location
redisctl config path
```

### 3. Basic Usage

```bash
# List all profiles
redisctl profile list

# Set default profile
redisctl profile default prod-cloud

# Explicit deployment commands
redisctl cloud subscription list
redisctl enterprise cluster info

# Smart routing (auto-detects based on profile)
redisctl database list --profile prod-cloud
redisctl user list --profile prod-enterprise

# Query and format output
redisctl database list -o json | jq '.[] | .name'
redisctl database list -q "[?status=='active'].name" -o yaml
```

### 4. Common Workflows

```bash
# Initialize a new Enterprise cluster
redisctl enterprise bootstrap create-cluster \
  --name "my-cluster" \
  --username admin@example.com \
  --accept-eula

# Create a database
redisctl database create \
  --name "my-database" \
  --memory-limit 1024 \
  --modules search,json

# Cloud-specific workflows
redisctl cloud backup create --subscription-id 123 --database-id 456
redisctl cloud peering create --subscription-id 123 --region us-east-1 --provider aws
redisctl cloud acl create --subscription-id 123 --database-id 456 --name readonly-rule

# Enterprise workflows  
redisctl enterprise database backup --database-id 1
redisctl enterprise database import --database-id 1 --source-uri redis://source:6379
```

## Architecture

### Workspace Structure
```
redisctl/
├── crates/
│   ├── redis-cloud/         # Cloud API client library
│   ├── redis-enterprise/    # Enterprise API client library
│   └── redisctl/           # Unified CLI application
├── docs/                    # Documentation (mdBook)
├── tests/                   # Integration tests
└── examples/               # Usage examples
```

### Key Components

#### Libraries
- **redis-cloud** - Complete Redis Cloud REST API client
  - All Cloud API endpoints implemented
  - Async/await with Tokio
  - Full type safety with Rust
  
- **redis-enterprise** - Complete Redis Enterprise REST API client
  - All Enterprise API endpoints implemented
  - Support for cluster management, CRDB, modules
  - Bootstrap and initialization workflows

#### CLI Application
- **redisctl** - Unified command-line interface
  - Smart command routing
  - Profile-based configuration
  - High-level workflows
  - Interactive mode (planned)

## Development

### Building
```bash
# Run tests
cargo test --workspace

# Run with all features
cargo test --all-features

# Check formatting
cargo fmt --all -- --check

# Run clippy
cargo clippy --all-targets --all-features -- -D warnings
```

### Documentation
```bash
# Build documentation
cd docs && mdbook build

# Serve documentation locally
cd docs && mdbook serve

# Generate API docs
cargo doc --no-deps --open

# Pre-commit hooks (recommended)
./scripts/install-hooks.sh
```

### Contributing
Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
- Code style and standards
- Testing requirements
- Pull request process
- Issue reporting

## API Coverage

### Redis Cloud API (95%+ Coverage)
- **Core Operations**: Subscriptions, Databases, Users, Payment Methods
-**Security**: ACLs, API Keys, Redis Rules, SSO/SAML Integration
-**Networking**: VPC Peering, Transit Gateway, Private Service Connect
-**Data Management**: Backup/Restore, Import/Export, Active-Active (CRDB)
-**Monitoring**: Metrics, Logs, Tasks, Alerts
-**Cloud Integration**: AWS, GCP, Azure Cloud Accounts
-**Billing**: Invoices, Payment Methods, Cost Analysis
-**21 Handler Modules** with 200+ API endpoints implemented

### Redis Enterprise API (100% Coverage)
- **Cluster Operations**: Bootstrap, Join, Management, Recovery
-**Database Management**: Full BDB lifecycle, Actions, Stats, Shards
-**Security**: Users, Roles, LDAP, Redis ACLs, OCSP
-**Active-Active**: CRDB management, Tasks, Multi-region
-**Monitoring**: Alerts, Stats, Logs, Diagnostics
-**Advanced Features**: Modules, Proxies, Services, Migrations
-**29 Handler Modules** covering all documented REST API endpoints

## Roadmap

See our [GitHub Issues](https://github.com/joshrotenberg/redisctl/issues) for the complete roadmap.

### **Phase 1** - Raw API Access (Complete)
   - Redis Cloud API coverage (95%+)
   - Redis Enterprise API coverage (100%)
   - Comprehensive test suite (500+ tests)
   - CI/CD automation with pre-commit hooks
   - Published to crates.io as v0.1.0

### **Phase 2** - Human-Friendly Commands (Complete)
   - Enhanced command interface with smart routing
   - Consistent --force flags and output formatting
   - JMESPath queries and multiple output formats
   - Major Cloud API categories now supported

### 🚧 **Phase 3** - Workflow Commands (In Progress)
   - High-level operations for complex multi-step tasks
   - Migration tools (Cloud ↔ Enterprise)
   - Cluster initialization workflows
   - Disaster recovery automation

### 🔮 **Phase 4** - Advanced Features (Planned)
   - Interactive TUI mode
   - Plugin system
   - Terraform provider integration
   - Kubernetes operator

## Rust Library Usage

For developers who want to build their own tools, our libraries provide complete, type-safe access to Redis Cloud and Enterprise APIs:

Add to your `Cargo.toml`:
```toml
[dependencies]
redis-cloud = "0.1.0"        # For Cloud API
redis-enterprise = "0.1.0"   # For Enterprise API
```

### Quick Example
```rust
use redis_cloud::CloudClient;
use redis_enterprise::EnterpriseClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Redis Cloud API client
    let cloud = CloudClient::new("api_key", "api_secret")?;
    
    // List all databases in a subscription
    let databases = cloud.database().list(subscription_id).await?;
    
    // Create a new database
    let new_db = cloud.database()
        .create(subscription_id, CreateDatabaseRequest {
            name: "production-cache".to_string(),
            memory_limit_in_gb: 10.0,
            // ... other settings
        })
        .await?;
    
    // Redis Enterprise API client
    let enterprise = EnterpriseClient::builder()
        .url("https://cluster:9443")
        .username("admin@example.com")
        .password("secure_password")
        .insecure(false)  // Set true for self-signed certs
        .build()?;
    
    // Get cluster information
    let cluster = enterprise.cluster().get().await?;
    
    // Create a database
    let db = enterprise.database()
        .create(CreateDatabaseRequest {
            name: "mydb".to_string(),
            memory_size: 1073741824,  // 1GB in bytes
            // ... other settings
        })
        .await?;
    
    Ok(())
}
```

### Library Features
- **Comprehensive handlers** for all API endpoints (subscriptions, databases, users, ACLs, etc.)
- **Builder patterns** for complex request construction
- **Error handling** with detailed context and retry logic
- **Both typed and untyped** responses (use `.raw()` methods for `serde_json::Value`)
- **Extensive documentation** on [docs.rs]https://docs.rs/redis-cloud and [docs.rs]https://docs.rs/redis-enterprise

## Support

- **Issues**: [GitHub Issues]https://github.com/joshrotenberg/redisctl/issues
- **Documentation**: [docs.rs/redisctl]https://docs.rs/redisctl/
- **Examples**: See the [examples/]examples/ directory
- **Crates.io**: [crates.io/crates/redisctl]https://crates.io/crates/redisctl

## License

Licensed under either of:
- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT]LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.