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
//! # Carbem
//!
//! A Rust library for retrieving carbon emission values from cloud providers.
//!
//! This library provides both a native Rust API and an FFI layer for use in other languages.
//!
//! ## Rust API (Recommended for Rust applications)
//!
//! ```rust,no_run
//! use carbem::{CarbemClient, EmissionQuery, TimePeriod};
//! use carbem::{ProviderQueryConfig, AzureQueryConfig, AzureReportType};
//! use chrono::Utc;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CarbemClient::builder()
//! .with_azure_from_env()?
//! .build();
//!
//! let query = EmissionQuery {
//! provider: "azure".to_string(),
//! regions: vec!["eastus".to_string(), "westus".to_string()], // location_list
//! time_period: TimePeriod {
//! start: Utc::now() - chrono::Duration::days(30),
//! end: Utc::now(),
//! },
//! services: None,
//! resources: None,
//! provider_config: Some(ProviderQueryConfig::Azure(AzureQueryConfig {
//! report_type: AzureReportType::MonthlySummaryReport,
//! subscription_list: vec!["subscription-id".to_string()],
//! ..Default::default()
//! })),
//! };
//!
//! let emissions = client.query_emissions(&query).await?;
//! println!("Found {} emissions", emissions.len());
//! Ok(())
//! }
//! ```
//!
//! ## FFI API (For Python/TypeScript bindings)
//!
//! ```rust,no_run
//! use carbem::get_emissions;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = r#"{"access_token": "your-token"}"#;
//! let payload = r#"{"start_date": "2024-01-01T00:00:00Z", "end_date": "2024-02-01T00:00:00Z", "regions": ["sub-id"], "services": null, "resources": null}"#;
//! let emissions = get_emissions("azure", config, payload).await?;
//! Ok(())
//! }
//! ```
use *;
use PyModule;
// Export the main Rust API
pub use *;
// Export core types
pub use ;
pub use ;
pub use ;
pub use ProviderQueryConfig;
pub use ;
// Export FFI functions for Python/TS bindings
pub use get_emissions;
/// Get carbon emissions from cloud providers (Python-compatible function)
/// Python module