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
//! # Cloudflare Client
//!
//! A comprehensive, well-documented Rust client for the Cloudflare API,
//! designed specifically for CI/CD and automation workflows.
//!
//! ## Features
//!
//! - **DNS Management**: Create, read, update, and delete DNS records with full control
//! - **Zone Management**: List and query zones (domains)
//! - **Cache Purging**: Clear cache by various methods (all, URLs, tags, hosts, prefixes)
//! - **Builder Pattern**: Ergonomic API with builder pattern for all operations
//! - **Custom Error Types**: Detailed error handling for programmatic responses
//! - **Diff Output**: See what changes will be made before applying them
//! - **Idempotent Operations**: Safe to run multiple times (perfect for CI/CD)
//! - **Well Documented**: Comprehensive docs and examples
//!
//! ## Quick Start
//!
//! ```no_run
//! use lmrc_cloudflare::{CloudflareClient, dns::RecordType};
//!
//! # async fn example() -> Result<(), lmrc_cloudflare::Error> {
//! // Create a client
//! let client = CloudflareClient::builder()
//! .api_token("your-api-token")
//! .build()?;
//!
//! // List zones
//! let zones = client.zones().list().send().await?;
//! println!("Found {} zones", zones.len());
//!
//! // Get zone ID
//! let zone_id = client.zones().get_zone_id("example.com").await?;
//!
//! // Create a DNS record
//! let record = client.dns()
//! .create_record(&zone_id)
//! .name("api.example.com")
//! .record_type(RecordType::A)
//! .content("192.0.2.1")
//! .proxied(true)
//! .send()
//! .await?;
//!
//! println!("Created record: {}", record.id);
//!
//! // List DNS records
//! let records = client.dns()
//! .list_records(&zone_id)
//! .record_type(RecordType::A)
//! .send()
//! .await?;
//!
//! // Update a record
//! client.dns()
//! .update_record(&zone_id, &record.id)
//! .content("192.0.2.2")
//! .send()
//! .await?;
//!
//! // Purge cache
//! client.cache()
//! .purge_urls(&zone_id)
//! .urls(vec!["https://example.com/page1"])
//! .send()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## CI/CD Integration
//!
//! The sync operations are designed for CI/CD workflows:
//!
//! ```no_run
//! use lmrc_cloudflare::{CloudflareClient, dns::{RecordType, DnsRecordBuilder}};
//!
//! # async fn example() -> Result<(), lmrc_cloudflare::Error> {
//! let client = CloudflareClient::new("your-api-token")?;
//! let zone_id = client.zones().get_zone_id("example.com").await?;
//!
//! // Define desired state
//! let desired_records = vec![
//! DnsRecordBuilder::new()
//! .name("api.example.com")
//! .record_type(RecordType::A)
//! .content("192.0.2.1")
//! .proxied(true),
//! DnsRecordBuilder::new()
//! .name("www.example.com")
//! .record_type(RecordType::CNAME)
//! .content("example.com")
//! .proxied(true),
//! ];
//!
//! // Dry run to see what would change
//! let changes = client.dns()
//! .sync_records(&zone_id)
//! .records(desired_records.clone())
//! .dry_run(true)
//! .send()
//! .await?;
//!
//! for change in &changes {
//! println!("{:?}: {}", change.action, change.description);
//! }
//!
//! // Apply changes
//! let changes = client.dns()
//! .sync_records(&zone_id)
//! .records(desired_records)
//! .dry_run(false)
//! .send()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! The library uses custom error types for better error handling:
//!
//! ```no_run
//! use lmrc_cloudflare::{CloudflareClient, Error};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let client = CloudflareClient::new("your-api-token")?;
//!
//! match client.zones().get_zone_id("nonexistent.com").await {
//! Ok(zone_id) => println!("Zone ID: {}", zone_id),
//! Err(Error::NotFound(msg)) => println!("Zone not found: {}", msg),
//! Err(Error::Unauthorized(msg)) => println!("Auth error: {}", msg),
//! Err(Error::RateLimited { retry_after }) => {
//! println!("Rate limited, retry after: {:?}", retry_after);
//! }
//! Err(e) => println!("Other error: {}", e),
//! }
//! # Ok(())
//! # }
//! ```
// Re-export main types at crate root
pub use CloudflareAdapter;
pub use ;
pub use ;
pub use ;
// Common type re-exports
pub use ;
pub use Zone;