add_zones

Function add_zones 

Source
pub async fn add_zones(
    client: &Arc<Client>,
    token: &Arc<String>,
    zone_name: &str,
    zone_type: &str,
    server: &str,
    key_data: &RndcKeyData,
    soa_record: Option<&SOARecord>,
    name_server_ips: Option<&HashMap<String, String>>,
    secondary_ips: Option<&[String]>,
    primary_ips: Option<&[String]>,
) -> Result<bool>
Expand description

Add a zone via HTTP API (primary or secondary).

This is the centralized zone addition function that dispatches to either add_primary_zone or add_secondary_zone based on the zone type.

This operation is idempotent - if the zone already exists, it returns success without attempting to re-add it.

§Arguments

  • client - HTTP client
  • token - Authentication token
  • zone_name - Name of the zone (e.g., “example.com”)
  • zone_type - Zone type (use ZONE_TYPE_PRIMARY or ZONE_TYPE_SECONDARY constants)
  • server - API endpoint (e.g., “bind9-primary-api:8080” or “bind9-secondary-api:8080”)
  • key_data - RNDC key data
  • soa_record - Optional SOA record data (required for primary zones, ignored for secondary)
  • name_server_ips - Optional map of nameserver hostnames to IP addresses (for primary zones)
  • secondary_ips - Optional list of secondary server IPs for also-notify and allow-transfer (for primary zones)
  • primary_ips - Optional list of primary server IPs to transfer from (for secondary zones)

§Returns

Returns Ok(true) if the zone was added, Ok(false) if it already existed.

§Errors

Returns an error if:

  • The HTTP request fails
  • The zone cannot be added
  • For primary zones: SOA record is None
  • For secondary zones: primary_ips is None or empty