Python bindings for Redis Cloud REST API client
Project description
redis-cloud
A comprehensive Rust client library for the Redis Cloud REST API, with Python bindings.
Features
- 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)
Installation
[dependencies]
redis-cloud = "0.8"
# Optional: Enable Tower service integration
redis-cloud = { version = "0.8", features = ["tower-integration"] }
Quick Start
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(())
}
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 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_ID
Python Bindings
This library also provides Python bindings via PyO3:
pip install redis-cloud
from 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()
Python API
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()/account_sync()- Get current account information
Subscriptions
subscriptions()/subscriptions_sync()- List all subscriptionssubscription(id)/subscription_sync(id)- Get subscription by ID
Databases
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)
Raw API
get(path)/get_sync(path)- Raw GET requestpost(path, body)/post_sync(path, body)- Raw POST requestdelete(path)/delete_sync(path)- Raw DELETE request
Environment Variables
REDIS_CLOUD_API_KEY- API keyREDIS_CLOUD_API_SECRET- API secretREDIS_CLOUD_BASE_URL- Base URL (optional)
API Coverage
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 |
Documentation
License
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redis_cloud-0.9.3.tar.gz.
File metadata
- Download URL: redis_cloud-0.9.3.tar.gz
- Upload date:
- Size: 187.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5050365b7cc79c8e13ce4e0725296ceaa719f270cb805041c91ce5e51c53089b
|
|
| MD5 |
b064b23732d35d8990f036ba19211071
|
|
| BLAKE2b-256 |
c8a502a59032069398af36e98532c5c563afc7f69ca1f7cac4ba2caa02bb9f04
|
Provenance
The following attestation bundles were made for redis_cloud-0.9.3.tar.gz:
Publisher:
python.yml on redis-developer/redis-cloud-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redis_cloud-0.9.3.tar.gz -
Subject digest:
5050365b7cc79c8e13ce4e0725296ceaa719f270cb805041c91ce5e51c53089b - Sigstore transparency entry: 922888283
- Sigstore integration time:
-
Permalink:
redis-developer/redis-cloud-rs@989a32c1aac960945a4742e07da4dff07911d0ef -
Branch / Tag:
refs/tags/v0.9.5 - Owner: https://github.com/redis-developer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@989a32c1aac960945a4742e07da4dff07911d0ef -
Trigger Event:
release
-
Statement type:
File details
Details for the file redis_cloud-0.9.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: redis_cloud-0.9.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66d1fef314d47bbbe76294ae49d94f5948e80b01db6f78005e92fc14ee3efcc1
|
|
| MD5 |
6212e381e3090e0a916ed46037efb718
|
|
| BLAKE2b-256 |
52e9b4b87d70cd92d7868012811e57a93188c87c965e9364012b695ba8638afd
|
Provenance
The following attestation bundles were made for redis_cloud-0.9.3-cp312-cp312-win_amd64.whl:
Publisher:
python.yml on redis-developer/redis-cloud-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redis_cloud-0.9.3-cp312-cp312-win_amd64.whl -
Subject digest:
66d1fef314d47bbbe76294ae49d94f5948e80b01db6f78005e92fc14ee3efcc1 - Sigstore transparency entry: 922888364
- Sigstore integration time:
-
Permalink:
redis-developer/redis-cloud-rs@989a32c1aac960945a4742e07da4dff07911d0ef -
Branch / Tag:
refs/tags/v0.9.5 - Owner: https://github.com/redis-developer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@989a32c1aac960945a4742e07da4dff07911d0ef -
Trigger Event:
release
-
Statement type:
File details
Details for the file redis_cloud-0.9.3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: redis_cloud-0.9.3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48121a10ca5f77b2fef8c76da1d41d81cf674df3dc253c5454aa98713e1940c4
|
|
| MD5 |
ce615d4063de647e9dbe540b0d12a106
|
|
| BLAKE2b-256 |
91eb553015ac39f264eabfe3cd962a556b5df06c64354ba305d2aa0a32f37b51
|
Provenance
The following attestation bundles were made for redis_cloud-0.9.3-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
python.yml on redis-developer/redis-cloud-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redis_cloud-0.9.3-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
48121a10ca5f77b2fef8c76da1d41d81cf674df3dc253c5454aa98713e1940c4 - Sigstore transparency entry: 922888314
- Sigstore integration time:
-
Permalink:
redis-developer/redis-cloud-rs@989a32c1aac960945a4742e07da4dff07911d0ef -
Branch / Tag:
refs/tags/v0.9.5 - Owner: https://github.com/redis-developer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@989a32c1aac960945a4742e07da4dff07911d0ef -
Trigger Event:
release
-
Statement type:
File details
Details for the file redis_cloud-0.9.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: redis_cloud-0.9.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4cb7f1526cf1ef49f0f53c9445de1e3af29f85d306983375ed1e9793194282e
|
|
| MD5 |
0440c4be2234b7774acad84ba78a70bd
|
|
| BLAKE2b-256 |
53dcde642c77734567987b02bfb21b6b6b1b9066ee8da5ffb5fe56a531aeee8f
|
Provenance
The following attestation bundles were made for redis_cloud-0.9.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python.yml on redis-developer/redis-cloud-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redis_cloud-0.9.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
a4cb7f1526cf1ef49f0f53c9445de1e3af29f85d306983375ed1e9793194282e - Sigstore transparency entry: 922888339
- Sigstore integration time:
-
Permalink:
redis-developer/redis-cloud-rs@989a32c1aac960945a4742e07da4dff07911d0ef -
Branch / Tag:
refs/tags/v0.9.5 - Owner: https://github.com/redis-developer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@989a32c1aac960945a4742e07da4dff07911d0ef -
Trigger Event:
release
-
Statement type: