Skip to main content

dinio_sdk/models/
zone.rs

1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4/// A DNS zone (`example.com`).
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Zone {
7    /// Zone id.
8    pub uuid: Uuid,
9    /// Zone name, lowercase, without trailing dot.
10    pub name: String,
11    /// Whether the zone has a zone-scoped API key. The key itself is shown only once, by
12    /// [`Zones::create_api_key`](crate::api::Zones::create_api_key).
13    #[serde(default)]
14    pub has_api_key: bool,
15    /// Suspended by an Admin. Reads keep working; writes answer
16    /// [`ErrorCode::Suspended`](crate::ErrorCode::Suspended), except deleting the zone,
17    /// removing a member and revoking the zone key.
18    #[serde(default)]
19    pub suspended: bool,
20    /// The zone's Owner is suspended; the zone then behaves as suspended too.
21    #[serde(default)]
22    pub owner_suspended: bool,
23    /// Unix seconds.
24    pub created_at: i64,
25    /// Unix seconds.
26    pub updated_at: i64,
27}
28
29impl Zone {
30    /// Whether Core refuses writes to the zone: suspended itself or through its Owner.
31    pub fn is_suspended(&self) -> bool {
32        self.suspended || self.owner_suspended
33    }
34}