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
//! # S3 Pricing Library
//!
//! A Rust library to calculate AWS S3 operation pricing dynamically using the AWS Pricing API.
//!
//! ## Features
//!
//! - **Storage pricing**: Fetch storage costs per GB/month for any S3 storage class
//! - **Request pricing**: Get Class A (PUT, COPY, POST, LIST) and Class B (GET, etc.) request prices
//! - **Data transfer**: Calculate data transfer costs (to internet or cross-region)
//! - **China regions**: Support for AWS China regions (cn-north-1, cn-northwest-1) with CNY pricing
//!
//! ## Usage
//!
//! ```ignore
//! use s3_pricing::S3PricingClient;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! // For global AWS regions (USD pricing)
//! let client = S3PricingClient::new(None).await?;
//! let storage_price = client.get_storage_price("us-east-1", "STANDARD").await?;
//! println!("Storage: ${} per GB-Mo", storage_price);
//!
//! // For AWS China regions (CNY pricing)
//! let china_client = S3PricingClient::new_china(None).await?;
//! let cn_storage = china_client.get_storage_price("cn-north-1", "STANDARD").await?;
//! println!("Storage: ¥{} per GB-Mo", cn_storage);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Supported Storage Classes
//!
//! - `STANDARD` - S3 Standard
//! - `STANDARD_IA` - S3 Standard-Infrequent Access
//! - `ONEZONE_IA` - S3 One Zone-Infrequent Access
//! - `INTELLIGENT_TIERING` - S3 Intelligent-Tiering
//! - `GLACIER` / `GLACIER_FLEXIBLE_RETRIEVAL` - Amazon Glacier
//! - `DEEP_ARCHIVE` - Glacier Deep Archive
//! - `GLACIER_IR` / `GLACIER_INSTANT_RETRIEVAL` - Glacier Instant Retrieval
//! - `EXPRESS_ONEZONE` - S3 Express One Zone
//! - `REDUCED_REDUNDANCY` - S3 Reduced Redundancy
//!
//! ## Supported Regions
//!
//! - **Global regions**: All standard AWS regions (us-east-1, eu-west-1, etc.) - pricing in USD
//! - **China regions**: cn-north-1 (Beijing), cn-northwest-1 (Ningxia) - pricing in CNY
//!
//! ## Notes
//!
//! - The global Pricing API is available in `us-east-1` endpoint
//! - The China Pricing API is available in `cn-northwest-1` endpoint (api.pricing.cn-northwest-1.amazonaws.com.cn)
//! - Credentials are resolved from the environment, shared config, or SSO profile
//! - Use `S3PricingClient::new()` for global regions, `S3PricingClient::new_china()` for China regions