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
// Allow doc strings with quoted values like 'true'/'false' from OpenAPI spec
//! Redis Cloud REST API Client
//!
//! A comprehensive Rust client for the Redis Cloud REST API, providing full access to
//! subscription management, database operations, billing, monitoring, and advanced features
//! like VPC peering, SSO/SAML, and Private Service Connect.
//!
//! ## Features
//!
//! - **Subscription Management**: Create, update, delete subscriptions across AWS, GCP, Azure
//! - **Database Operations**: Full CRUD operations, backups, imports, metrics
//! - **Advanced Networking**: VPC peering, Transit Gateway, Private Service Connect
//! - **Security & Access**: ACLs, SSO/SAML integration, API key management
//! - **Monitoring & Billing**: Comprehensive metrics, logs, billing and payment management
//! - **Enterprise Features**: Active-Active databases (CRDB), fixed/essentials plans
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use redis_cloud::{CloudClient, DatabaseHandler};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create client with API credentials
//! let client = CloudClient::builder()
//! .api_key("your-api-key")
//! .api_secret("your-api-secret")
//! .build()?;
//!
//! // List all databases
//! let db_handler = DatabaseHandler::new(client.clone());
//! let databases = db_handler.get_subscription_databases(123, None, None).await?;
//! println!("Found databases: {:?}", databases);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Core Usage Patterns
//!
//! ### Client Creation
//!
//! The client uses a builder pattern for flexible configuration:
//!
//! ```rust,no_run
//! use redis_cloud::CloudClient;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Basic client with default settings
//! let client = CloudClient::builder()
//! .api_key("your-api-key")
//! .api_secret("your-api-secret")
//! .build()?;
//!
//! // Custom configuration
//! let client2 = CloudClient::builder()
//! .api_key("your-api-key")
//! .api_secret("your-api-secret")
//! .base_url("https://api.redislabs.com/v1".to_string())
//! .timeout(std::time::Duration::from_secs(60))
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Typed vs Raw API
//!
//! This client offers typed handlers for common operations as well as raw helpers when you
//! need full control over request/response payloads:
//!
//! - Prefer typed handlers (e.g., `CloudDatabaseHandler`) for structured, ergonomic access.
//! - Use raw helpers for passthroughs: `get_raw`, `post_raw`, `put_raw`, `patch_raw`, `delete_raw`.
//!
//! ```rust,no_run
//! use redis_cloud::CloudClient;
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! // Raw call example
//! let created = client.post_raw("/subscriptions", json!({ "name": "example" })).await?;
//! println!("{}", created);
//! # Ok(())
//! # }
//! ```
//!
//! ### Working with Subscriptions
//!
//! ```rust,no_run
//! use redis_cloud::{CloudClient, SubscriptionHandler};
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! let sub_handler = SubscriptionHandler::new(client.clone());
//!
//! // List subscriptions
//! let subscriptions = sub_handler.get_all_subscriptions().await?;
//!
//! // Create a new subscription using raw API
//! let new_subscription = json!({
//! "name": "my-redis-subscription",
//! "provider": "AWS",
//! "region": "us-east-1",
//! "plan": "cache.m5.large"
//! });
//! let created = client.post_raw("/subscriptions", new_subscription).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Database Management
//!
//! ```rust,no_run
//! use redis_cloud::{CloudClient, DatabaseHandler};
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! let db_handler = DatabaseHandler::new(client.clone());
//!
//! // Create database using raw API
//! let database_config = json!({
//! "name": "my-database",
//! "memoryLimitInGb": 1.0,
//! "support_oss_cluster_api": false,
//! "replication": true
//! });
//! let database = client.post_raw("/subscriptions/123/databases", database_config).await?;
//!
//! // Get database info
//! let db_info = db_handler.get_subscription_database_by_id(123, 456).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Advanced Features
//!
//! #### VPC Peering
//! ```rust,no_run
//! use redis_cloud::{CloudClient, ConnectivityHandler};
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! let peering_handler = ConnectivityHandler::new(client.clone());
//!
//! let peering_request = json!({
//! "aws_account_id": "123456789012",
//! "vpc_id": "vpc-12345678",
//! "vpc_cidr": "10.0.0.0/16",
//! "region": "us-east-1"
//! });
//! let peering = client.post_raw("/subscriptions/123/peerings", peering_request).await?;
//! # Ok(())
//! # }
//! ```
//!
//! #### SSO/SAML Management
//! ```rust,no_run
//! use redis_cloud::{CloudClient, AccountHandler};
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! let sso_handler = AccountHandler::new(client.clone());
//!
//! // Configure SSO using raw API
//! let sso_config = json!({
//! "enabled": true,
//! "auto_provision": true
//! });
//! let config = client.put_raw("/sso", sso_config).await?;
//! # Ok(())
//! # }
//! ```
//!
//! #### API Keys (Typed)
//! ```rust,no_run
//! use redis_cloud::{CloudClient, AccountHandler};
//! use serde_json::json;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build()?;
//!
//! let account = AccountHandler::new(client.clone());
//! let account_info = account.get_current_account().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! The client provides comprehensive error handling for different failure scenarios:
//!
//! ```rust,no_run
//! use redis_cloud::{CloudClient, CloudError, DatabaseHandler};
//!
//! # #[tokio::main]
//! # async fn main() {
//! let client = CloudClient::builder()
//! .api_key("key")
//! .api_secret("secret")
//! .build().unwrap();
//!
//! let db_handler = DatabaseHandler::new(client.clone());
//!
//! match db_handler.get_subscription_database_by_id(123, 456).await {
//! Ok(database) => println!("Database: {:?}", database),
//! Err(CloudError::ApiError { code: 404, .. }) => {
//! println!("Database not found");
//! },
//! Err(CloudError::AuthenticationFailed { message }) => {
//! println!("Invalid API credentials");
//! },
//! Err(e) => println!("Other error: {}", e),
//! }
//! # }
//! ```
//!
//! ## Handler Overview
//!
//! The client provides specialized handlers for different API domains:
//!
//! | Handler | Purpose | Key Operations |
//! |---------|---------|----------------|
//! | [`SubscriptionHandler`] | Pro subscriptions | create, list, update, delete, pricing |
//! | [`FixedSubscriptionHandler`] | Essentials subscriptions | fixed plans, create, update, delete |
//! | [`DatabaseHandler`] | Pro databases | create, backup, import, metrics, resize |
//! | [`FixedDatabaseHandler`] | Essentials databases | fixed capacity, backup, import |
//! | [`AccountHandler`] | Account management | info, API keys, payment methods, SSO |
//! | [`UserHandler`] | User management | create, update, delete, invite, roles |
//! | [`AclHandler`] | Access control | users, roles, Redis rules, database ACLs |
//! | [`ConnectivityHandler`] | Network connectivity | VPC peering, Transit Gateway, PSC |
//! | [`CloudAccountHandler`] | Cloud providers | AWS, GCP, Azure account integration |
//! | [`TaskHandler`] | Async operations | track long-running operations |
//!
//! ## Authentication
//!
//! Redis Cloud uses API key authentication with two required headers:
//! - `x-api-key`: Your API key
//! - `x-api-secret-key`: Your API secret
//!
//! These credentials can be obtained from the Redis Cloud console under Account Settings > API Keys.
//!
//! Environment variables commonly used with this client:
//! - `REDIS_CLOUD_API_KEY`
//! - `REDIS_CLOUD_API_SECRET`
//! - Optional: set a custom base URL via the builder for non‑prod/test environments (defaults to `https://api.redislabs.com/v1`).
// Re-export client types
pub use ;
// Re-export error types
pub use ;
// Re-export Tower integration when feature is enabled
pub use tower_support;
// Test support module - only available with test-support feature
// Types module for shared models
// Handler modules - each handles a specific API domain
// Backward compatibility module aliases
pub use databases as fixed_databases;
pub use subscriptions as fixed_subscriptions;
pub use databases;
pub use subscriptions;
// Re-export handlers with standard naming
pub use AccountHandler;
pub use AclHandler;
pub use CloudAccountsHandler as CloudAccountHandler;
// Connectivity handlers
pub use PrivateLinkHandler;
pub use PscHandler;
pub use TransitGatewayHandler;
pub use VpcPeeringHandler;
// Connectivity types
pub use ;
// Legacy connectivity export for backward compatibility
pub use ConnectivityHandler;
// Fixed plan handlers
pub use FixedDatabaseHandler;
pub use FixedSubscriptionHandler;
// Legacy exports for backward compatibility
pub use FixedDatabaseHandler as FixedDatabasesHandler;
pub use FixedSubscriptionHandler as FixedSubscriptionsHandler;
// Flexible plan handlers (pay-as-you-go)
pub use DatabaseHandler;
pub use SubscriptionHandler;
// Legacy exports for backward compatibility
pub use DatabaseHandler as DatabasesHandler;
pub use SubscriptionHandler as SubscriptionsHandler;
pub use CostReportHandler;
pub use ;
pub use TasksHandler as TaskHandler;
pub use UsersHandler as UserHandler;