Skip to main content

Zones

Struct Zones 

Source
pub struct Zones<'a> { /* private fields */ }
Expand description

Zone routes, from Client::zones.

A zone is addressed by its uuid or its name ("example.com"). Access: a personal key reaches the zones its user is a member of; a zone key only its own zone.

Implementations§

Source§

impl<'a> Zones<'a>

Source

pub async fn list(&self, page: PageRequest) -> Result<Page<Zone>>

Zones visible to the caller. Core paginates only for an Admin; everyone else gets their whole list on one page. Prefer list_all unless you page yourself.

GET /api/v1/zones

Source

pub async fn list_all(&self) -> Result<Vec<Zone>>

All visible zones, following pagination.

GET /api/v1/zones, as many times as there are pages.

Source

pub async fn get(&self, zone: &str) -> Result<Zone>

One zone by uuid or name.

GET /api/v1/zones/:ref

§Errors

ErrorCode::NotFound if there is no such zone.

§Examples
let zone = client.zones().get("example.com").await?;
println!("{} is {}", zone.name, zone.uuid);
Source

pub async fn create(&self, name: &str) -> Result<Zone>

Creates a zone; the caller becomes its Owner and Core adds the apex SOA and NS. Not allowed with a zone-scoped key.

A name directly below a free domain (FreeDomains::list) is a lease: one label of 3–63 characters, not reserved, not taken, and at most the free domains’ limit leases per user. Core then also delegates the name from the free domain.

POST /api/v1/zones

§Errors
Source

pub async fn create_api_key(&self, zone: &str) -> Result<Secret>

Issues a new zone-scoped key (dz_…) and returns it. Core shows the key only in this response and keeps just its hash, so store it now. A previous key of the zone stops working immediately; if it is the key this client uses, build a new client with the new key. Allowed for the zone’s own key, its Owner or Administrator, and Admin.

POST /api/v1/zones/:ref/api-key

§Errors

ErrorCode::NotFound if there is no such zone.

§Examples
let key = client.zones().create_api_key("example.com").await?;
// Show the key to the user now; Core never returns it again.
println!("{}", key.expose());
Source

pub async fn revoke_api_key(&self, zone: &str) -> Result<Zone>

Revokes the zone’s key; the zone then has none (Zone::has_api_key is false). Same access as create_api_key.

DELETE /api/v1/zones/:ref/api-key

§Errors

ErrorCode::NotFound if there is no such zone.

Source

pub async fn delete(&self, zone: &str) -> Result<()>

Deletes the zone with all its records, geo bans and health checks. Irreversible. Allowed for the zone’s Owner, an Admin or the zone’s own key; a delegated Administrator may not.

DELETE /api/v1/zones/:ref

§Errors
Source

pub async fn export(&self, zone: &str, format: ZoneFileFormat) -> Result<String>

The zone as a file, exactly as Core writes it. Json is the dinio-zone document (parse it into ZoneDocument if needed); Bind and Csv carry only name, ttl, type and data. Reading is enough, so it works on a suspended zone too.

GET /api/v1/zones/:ref/export?format=

§Errors

ErrorCode::NotFound if there is no such zone.

§Examples
use dinio_sdk::models::ZoneFileFormat;

let zone_file = client.zones().export("example.com", ZoneFileFormat::Bind).await?;
std::fs::write("example.com.zone", zone_file).expect("write");
Source

pub async fn import( &self, zone: &str, format: ZoneFileFormat, file: String, dry_run: bool, ) -> Result<ImportReport>

Merges a zone file into the zone: adds what the zone lacks, never changes or deletes anything. SOA and apex NS in the file are skipped. Records are written in one transaction (all or none); redirects of a dinio-zone document afterwards, each on its own. With dry_run Core checks everything and writes nothing.

POST /api/v1/zones/:ref/import?format=&dry_run=

§Errors
§Examples
use dinio_sdk::models::ZoneFileFormat;

let file = std::fs::read_to_string("example.com.zone").expect("read");
let zones = client.zones();
let preview = zones.import("example.com", ZoneFileFormat::Bind, file.clone(), true).await?;
if !preview.has_errors() {
    let report = zones.import("example.com", ZoneFileFormat::Bind, file, false).await?;
    println!("{} records created", report.records.created);
}
Source

pub async fn discover( &self, zone: &str, nameservers: &[String], ) -> Result<Discovery>

Asks the zone’s current nameservers (the previous provider’s) about the names a zone usually has and returns a proposal to review, trim and pass to import. Writes nothing. Finds common names only, not every record (AXFR is refused almost everywhere). Takes up to about a minute, so the request waits at least 90 s whatever the client’s timeout.

nameservers (host names or addresses, at most 8) are needed once the delegation already points to Dinio; empty means “ask the delegation”.

POST /api/v1/zones/:ref/discover

§Errors
§Examples
use dinio_sdk::models::ZoneFileFormat;

let found = client.zones().discover("example.com", &[]).await?;
let mut document = found.document;
document.records.retain(|r| r.record_type != "TXT");
let file = serde_json::to_string(&document).expect("serializable");
client.zones().import("example.com", ZoneFileFormat::Json, file, false).await?;

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Zones<'a>

§

impl<'a> !UnwindSafe for Zones<'a>

§

impl<'a> Freeze for Zones<'a>

§

impl<'a> Send for Zones<'a>

§

impl<'a> Sync for Zones<'a>

§

impl<'a> Unpin for Zones<'a>

§

impl<'a> UnsafeUnpin for Zones<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more