lmrc-cloudflare 0.3.16

Cloudflare API client library for the LMRC Stack - comprehensive DNS, zones, and cache management with automatic retry logic
Documentation
//! # 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(())
//! # }
//! ```

pub mod adapter;
pub mod cache;
pub mod client;
pub mod dns;
pub mod error;
pub mod types;
pub mod zones;

// Re-export main types at crate root
pub use adapter::CloudflareAdapter;
pub use client::{CloudflareClient, CloudflareClientBuilder, RetryConfig};
pub use error::{Error, Result};
pub use types::{Change, ChangeAction};

// Common type re-exports
pub use dns::{DnsRecord, DnsRecordBuilder, RecordType};
pub use zones::Zone;