Skip to main content

Python bindings for Redis Cloud REST API client

Project description

redis-cloud

Crates.io Documentation CI License PyPI

A comprehensive Rust client library for the Redis Cloud REST API, with Python bindings.

Features

  • Complete coverage of all Redis Cloud REST API endpoints (155/155 routes verified against the bundled OpenAPI spec in CI)
  • 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)

Installation

[dependencies]
redis-cloud = "0.10"

# Optional: Enable Tower service integration
redis-cloud = { version = "0.10", features = ["tower-integration"] }

Quick Start

use redis_cloud::CloudClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = CloudClient::builder()
        .api_key(std::env::var("REDIS_CLOUD_API_KEY")?)
        .api_secret(std::env::var("REDIS_CLOUD_API_SECRET")?)
        .build()?;

    // Account info
    let account = client.account().get_current_account().await?;
    if let Some(acc) = account.account {
        println!("Account: {:?} ({:?})", acc.name, acc.id);
    }

    // List Pro subscriptions
    let subs = client.subscriptions().list().await?;
    for sub in subs.subscriptions.unwrap_or_default() {
        println!("  - subscription {:?}: {:?}", sub.id, sub.name);
    }

    // List databases for a subscription (unwrapped helper)
    let dbs = client.databases().list(123).await?;
    for db in &dbs {
        println!("  - db {:?}: {:?}", db.database_id, db.name);
    }

    Ok(())
}

Environment Variables

  • REDIS_CLOUD_API_KEY — API key
  • REDIS_CLOUD_API_SECRET — API secret
  • REDIS_CLOUD_BASE_URL — Override the API base URL (optional; defaults to the production Redis Cloud endpoint)

Tower Integration

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.

Examples

See the examples/ directory for runnable end-to-end programs:

# Basic — connect, fetch account, list Pro + Essentials subscriptions
cargo run --example basic

# Database operations — list databases for a subscription, paginated
cargo run --example databases [SUBSCRIPTION_ID]

# Streaming — process databases one at a time via the paginated stream
cargo run --example stream_databases -- SUBSCRIPTION_ID

# Tasks — poll an async task by ID
cargo run --example tasks -- TASK_ID

# Cost reports — fetch a cost report in FOCUS-format JSON
cargo run --example cost_report -- START_DATE END_DATE

All examples read credentials from REDIS_CLOUD_API_KEY / REDIS_CLOUD_API_SECRET.

Python Bindings

A PyO3 binding providing a convenience layer covering read operations across all major API domains is published at redis-cloud on PyPI. See python/README.md for the full supported API, the parity scope decision, and what is intentionally out of scope (connectivity handlers, cost reports, and write operations — all reachable via the raw HTTP helpers or the Rust client).

The PyPI publish workflow has been failing since the reqwest 0.13 upgrade (#48).

API Coverage

The crate covers 100% of the documented Redis Cloud REST API surface (155/155 routes). Route coverage is enforced by an executable check (tests/openapi_route_coverage.rs) that diffs the typed handlers against the bundled OpenAPI spec; intentional gaps (currently none) and known off-spec routes (currently none) are tracked in tests/fixtures/openapi_unsupported_routes.txt and tests/fixtures/openapi_non_spec_routes.txt.

Handler organization:

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

For the authoritative per-endpoint mapping see the bundled OpenAPI spec at tests/fixtures/cloud_openapi.json.

Documentation

License

Licensed under either of

at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis_cloud-0.9.5.tar.gz (234.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

redis_cloud-0.9.5-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

redis_cloud-0.9.5-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

redis_cloud-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file redis_cloud-0.9.5.tar.gz.

File metadata

  • Download URL: redis_cloud-0.9.5.tar.gz
  • Upload date:
  • Size: 234.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for redis_cloud-0.9.5.tar.gz
Algorithm Hash digest
SHA256 e4e1dd41e6cd45946f182844019babe3cd6b8649d18390d875ad93f04723f0ec
MD5 e483df61b89396fd2e896f7f46d1ef06
BLAKE2b-256 2bb44cc038ad4a17f864133bfe14ca986edd074873286f79431d3696edc3820e

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_cloud-0.9.5.tar.gz:

Publisher: python.yml on redis-developer/redis-cloud-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redis_cloud-0.9.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for redis_cloud-0.9.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 86779b6e834af605c727e8238a5d3eb9d3140b69e7ec7a1c470e63c9da12528f
MD5 b17743c2e8b9a7f342c7ddddb52822b3
BLAKE2b-256 813c898e772925e606225ef0a939b1c461f4829e6e31d25bc266af9e9d754713

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_cloud-0.9.5-cp312-cp312-win_amd64.whl:

Publisher: python.yml on redis-developer/redis-cloud-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redis_cloud-0.9.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for redis_cloud-0.9.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4aac360d8d0f303d103ee77da6c9ed044cf0825f1e4c7d2a5a9e7cf6ee0562b1
MD5 de4459936d737c1d9f9500bfddf5e474
BLAKE2b-256 9254ab8b3f7f19def7b64d456efab7a67b034e74f4915f03101658e8d813b1e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_cloud-0.9.5-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: python.yml on redis-developer/redis-cloud-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redis_cloud-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for redis_cloud-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e8be760d973a4effc508bc1d00aad951f89a01877b6ffcd1c82660608596db4
MD5 976742c4405c788ae1aaf8683dd16835
BLAKE2b-256 d5c3150adcbbf0210acbd2660bcb3577ae58ebe13de7cedd2ec7d4def0cbeabc

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_cloud-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yml on redis-developer/redis-cloud-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page