Skip to main content

Crate dns_orchestrator_provider

Crate dns_orchestrator_provider 

Source
Expand description

§dns-orchestrator-provider

A unified DNS provider abstraction library for managing DNS records across multiple cloud platforms.

§Supported Providers

ProviderFeature FlagAuth Method
CloudflarecloudflareBearer Token
Aliyun DNSaliyunHMAC-SHA256 (V3)
DNSPod (Tencent Cloud)dnspodTC3-HMAC-SHA256
Huawei Cloud DNShuaweicloudAK/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 Cloud DNSPod provider.
  • 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:

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§

AliyunProvider
Aliyun DNS provider implementation.
BatchCreateFailure
Information about a single failed record creation in a batch.
BatchCreateResult
Result of a batch create operation.
BatchDeleteFailure
Information about a single failed record deletion in a batch.
BatchDeleteResult
Result of a batch delete operation.
BatchUpdateFailure
Information about a single failed record update in a batch.
BatchUpdateItem
A single item in a batch update request.
BatchUpdateResult
Result of a batch update operation.
CloudflareProvider
Cloudflare DNS provider implementation.
CreateDnsRecordRequest
Request to create a new DNS record.
DnsRecord
A DNS record as returned by a provider.
DnspodProvider
Tencent Cloud DNSPod provider implementation.
HuaweicloudProvider
Huawei Cloud DNS provider implementation.
PaginatedResponse
A paginated response wrapper.
PaginationParams
Pagination parameters for list operations.
ProviderCredentialField
Definition of a single credential field required by a provider.
ProviderDomain
A domain (zone) managed by a DNS provider.
ProviderFeatures
Provider-specific feature support flags.
ProviderLimits
Provider-specific pagination limits.
ProviderMetadata
Static metadata describing a DNS provider.
RecordQueryParams
Query parameters for DNS record listing, with optional search and filtering.
UpdateDnsRecordRequest
Request to update an existing DNS record.

Enums§

CredentialValidationError
Validation error for provider credentials.
DnsRecordType
DNS record type identifier, used for query filtering.
DomainStatus
Status of a domain/zone within a DNS provider.
FieldType
The input type of a credential field (affects UI rendering).
ProviderCredentials
Type-safe credential container for all supported DNS providers.
ProviderError
Unified error type for all DNS provider operations.
ProviderType
Identifies which DNS provider implementation to use.
RecordData
Type-safe representation of DNS record data.

Traits§

DnsProvider
The core DNS provider trait.

Functions§

create_provider
Creates a DnsProvider instance 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>.