Expand description
§dns-orchestrator-provider
A unified DNS provider abstraction library for managing DNS records across multiple cloud platforms.
§Supported Providers
| Provider | Feature Flag | Auth Method |
|---|---|---|
| Cloudflare | cloudflare | Bearer Token |
| Aliyun DNS | aliyun | HMAC-SHA256 (V3) |
| DNSPod (Tencent Cloud) | dnspod | TC3-HMAC-SHA256 |
| Huawei Cloud DNS | huaweicloud | AK/SK Signing |
§Feature Flags
§Provider Selection
all-providers(default) — Enable all providers listed above.cloudflare— Enable only the Cloudflare provider.aliyun— Enable only the Aliyun DNS provider.dnspod— Enable only the Tencent CloudDNSPodprovider.huaweicloud— Enable only the Huawei Cloud DNS provider.
§TLS Backend
native-tls— Use the platform’s native TLS implementation.rustls(default) — Use rustls, a pure-Rust TLS implementation.
§Quick Start
Add to your Cargo.toml:
[dependencies]
dns-orchestrator-provider = { version = "0.1", features = ["all-providers"] }Or enable only the providers you need:
[dependencies]
dns-orchestrator-provider = { version = "0.1", default-features = false, features = ["cloudflare", "rustls"] }§Usage
use dns_orchestrator_provider::{
create_provider, DnsProvider, PaginationParams, ProviderCredentials,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1. Create a provider from credentials
let credentials = ProviderCredentials::Cloudflare {
api_token: "your-token".to_string(),
};
let provider = create_provider(credentials)?;
// 2. Validate credentials against the remote API
provider.validate_credentials().await?;
// 3. List domains
let domains = provider.list_domains(&PaginationParams::default()).await?;
for domain in &domains.items {
println!("{} ({:?})", domain.name, domain.status);
}
// 4. List DNS records for the first domain
let records = provider
.list_records(&domains.items[0].id, &Default::default())
.await?;
for record in &records.items {
println!(
"{} {:?} -> {}",
record.name,
record.data.record_type(),
record.data.display_value()
);
}
Ok(())
}§Creating Records
let request = CreateDnsRecordRequest {
domain_id: "example.com".to_string(),
name: "www".to_string(),
ttl: 600,
data: RecordData::A { address: "1.2.3.4".to_string() },
proxied: None,
};
let record = provider.create_record(&request).await?;§Error Handling
All provider operations return Result<T, ProviderError>.
The error enum provides structured variants for common failure modes:
ProviderError::InvalidCredentials— authentication failedProviderError::RecordNotFound— DNS record not foundProviderError::RateLimited— API rate limit exceeded (retryable)ProviderError::NetworkError— network connectivity issue (retryable)
Transient errors (NetworkError, Timeout, RateLimited) are automatically
retried with exponential backoff. See ProviderError for the full list.
Modules§
- datetime
- Date/time serialization helpers shared by providers. Date/time serialization and deserialization utilities.
Structs§
- Aliyun
Provider - Aliyun DNS provider implementation.
- Batch
Create Failure - Information about a single failed record creation in a batch.
- Batch
Create Result - Result of a batch create operation.
- Batch
Delete Failure - Information about a single failed record deletion in a batch.
- Batch
Delete Result - Result of a batch delete operation.
- Batch
Update Failure - Information about a single failed record update in a batch.
- Batch
Update Item - A single item in a batch update request.
- Batch
Update Result - Result of a batch update operation.
- Cloudflare
Provider - Cloudflare DNS provider implementation.
- Create
DnsRecord Request - Request to create a new DNS record.
- DnsRecord
- A DNS record as returned by a provider.
- Dnspod
Provider - Tencent Cloud
DNSPodprovider implementation. - Huaweicloud
Provider - Huawei Cloud DNS provider implementation.
- Paginated
Response - A paginated response wrapper.
- Pagination
Params - Pagination parameters for list operations.
- Provider
Credential Field - Definition of a single credential field required by a provider.
- Provider
Domain - A domain (zone) managed by a DNS provider.
- Provider
Features - Provider-specific feature support flags.
- Provider
Limits - Provider-specific pagination limits.
- Provider
Metadata - Static metadata describing a DNS provider.
- Record
Query Params - Query parameters for DNS record listing, with optional search and filtering.
- Update
DnsRecord Request - Request to update an existing DNS record.
Enums§
- Credential
Validation Error - Validation error for provider credentials.
- DnsRecord
Type - DNS record type identifier, used for query filtering.
- Domain
Status - Status of a domain/zone within a DNS provider.
- Field
Type - The input type of a credential field (affects UI rendering).
- Provider
Credentials - Type-safe credential container for all supported DNS providers.
- Provider
Error - Unified error type for all DNS provider operations.
- Provider
Type - Identifies which DNS provider implementation to use.
- Record
Data - Type-safe representation of DNS record data.
Traits§
- DnsProvider
- The core DNS provider trait.
Functions§
- create_
provider - Creates a
DnsProviderinstance from the given credentials. - get_
all_ provider_ metadata - Returns metadata for all providers enabled via feature flags.
Type Aliases§
- Result
- Convenience type alias for
Result<T, ProviderError>.