A comprehensive Rust client library for the Redis Cloud REST API, with Python bindings.
- Complete coverage of Redis Cloud REST API endpoints
- Async/await support with tokio
- Strong typing for API requests and responses
- Comprehensive error handling
- Optional Tower service integration for middleware composition
- Support for all Redis Cloud features including:
- Pro and Essentials subscriptions and databases
- User and ACL management
- Backup, restore, and import operations
- VPC peering, Transit Gateway, Private Service Connect, PrivateLink
- Cloud account integration (AWS, GCP, Azure)
- Task tracking for async operations
- Cost reports (FOCUS format)
[dependencies]
redis-cloud = "0.8"
# Optional: Enable Tower service integration
redis-cloud = { version = "0.8", features = ["tower-integration"] }use redis_cloud::CloudClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client using builder pattern
let client = CloudClient::builder()
.api_key("your-api-key")
.api_secret("your-api-secret")
.build()?;
// Get account information using fluent API
let account = client.account().get_current_account().await?;
println!("Account: {:?}", account);
// List all subscriptions
let subscriptions = client.subscriptions().get_all_subscriptions().await?;
println!("Subscriptions: {:?}", subscriptions);
// List databases in a subscription
let databases = client.databases().get_subscription_databases(123, None, None).await?;
println!("Databases: {:?}", databases);
Ok(())
}You can also use explicit handler creation if preferred:
use redis_cloud::{CloudClient, SubscriptionHandler};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = CloudClient::builder()
.api_key("your-api-key")
.api_secret("your-api-secret")
.build()?;
// Explicit handler creation
let handler = SubscriptionHandler::new(client.clone());
let subscriptions = handler.get_all_subscriptions().await?;
Ok(())
}Enable the tower-integration feature to use the client with Tower middleware:
use redis_cloud::CloudClient;
use redis_cloud::tower_support::ApiRequest;
use tower::ServiceExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = CloudClient::builder()
.api_key("your-api-key")
.api_secret("your-api-secret")
.build()?;
// Convert to a Tower service
let mut service = client.into_service();
// Use the service
let response = service
.oneshot(ApiRequest::get("/subscriptions"))
.await?;
println!("Response: {:?}", response.body);
Ok(())
}This enables composition with Tower middleware like circuit breakers, retry, rate limiting, and more.
See the examples/ directory for runnable examples:
# Basic usage - connect and list subscriptions
REDIS_CLOUD_API_KEY=xxx REDIS_CLOUD_API_SECRET=yyy cargo run --example basic
# Database operations
REDIS_CLOUD_API_KEY=xxx REDIS_CLOUD_API_SECRET=yyy cargo run --example databases
# Streaming with pagination
REDIS_CLOUD_API_KEY=xxx REDIS_CLOUD_API_SECRET=yyy cargo run --example stream_databases -- SUBSCRIPTION_IDThis library also provides Python bindings via PyO3:
pip install redis-cloudfrom redis_cloud import CloudClient
# Create client
client = CloudClient(
api_key="your-api-key",
api_secret="your-api-secret"
)
# Or from environment variables
client = CloudClient.from_env()
# Async usage
async def main():
subs = await client.subscriptions()
for sub in subs:
print(sub["name"], sub["id"])
# Sync usage
subs = client.subscriptions_sync()CloudClient(api_key, api_secret, base_url=None, timeout_secs=None)CloudClient.from_env()- Create from environment variablesclient.timeout- Get configured timeout in seconds (property)
account()/account_sync()- Get current account information
subscriptions()/subscriptions_sync()- List all subscriptionssubscription(id)/subscription_sync(id)- Get subscription by ID
databases(subscription_id, offset=None, limit=None)/databases_sync(...)- List databases (paginated)database(subscription_id, database_id)/database_sync(...)- Get databaseall_databases(subscription_id)/all_databases_sync(...)- Get all databases (auto-pagination)
get(path)/get_sync(path)- Raw GET requestpost(path, body)/post_sync(path, body)- Raw POST requestdelete(path)/delete_sync(path)- Raw DELETE request
REDIS_CLOUD_API_KEY- API keyREDIS_CLOUD_API_SECRET- API secretREDIS_CLOUD_BASE_URL- Base URL (optional)
This library provides comprehensive coverage of the Redis Cloud REST API:
| Handler | Description |
|---|---|
account() |
Account info, payment methods, regions, logs |
subscriptions() |
Pro subscription CRUD, pricing, CIDR, maintenance windows |
databases() |
Pro database lifecycle, backups, imports, flush |
fixed_subscriptions() |
Essentials subscription management |
fixed_databases() |
Essentials database management |
acl() |
ACL users, roles, Redis rules |
users() |
Account user management |
cloud_accounts() |
Cloud provider integration (AWS, GCP, Azure) |
vpc_peering() |
VPC peering (standard and Active-Active) |
transit_gateway() |
AWS Transit Gateway attachments |
psc() |
GCP Private Service Connect |
private_link() |
AWS PrivateLink |
tasks() |
Async operation tracking |
cost_reports() |
Cost reports in FOCUS format |
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.