zone-update 0.11.0

A library of CRUD-like operations on DNS zones for multiple providers
Documentation
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::RecordType;


// {
//   "data": [
//     {
//       "id": 2602,
//       "email": "tarkasteve+dnsimple.sandbox@gmail.com",
//       "plan_identifier": "solo-v2-monthly",
//       "created_at": "2025-09-14T01:53:43Z",
//       "updated_at": "2025-09-14T01:56:14Z"
//     }
//   ]
// }
/// Represents a DNSimple account returned by the API.
#[derive(Serialize, Deserialize, Debug)]
pub struct Account {
    pub id: u32,
    pub email: String,
    pub plan_identifier: String,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}

/// Container for account list responses from DNSimple.
#[derive(Serialize, Deserialize, Debug)]
pub struct Accounts {
    #[serde(rename = "data")]
    pub accounts: Vec<Account>
}

// {
//   "data": [
//     {
//       "id": 3422640,
//       "zone_id": "testcondition.net",
//       "parent_id": null,
//       "name": "test",
//       "content": "1.2.3.4",
//       "ttl": 60,
//       "priority": null,
//       "type": "A",
//       "regions": [
//         "global"
//       ],
//       "system_record": false,
//       "created_at": "2025-09-20T01:10:32Z",
//       "updated_at": "2025-09-20T01:10:32Z"
//     }
//   ],
//   "pagination": {
//     "current_page": 1,
//     "per_page": 30,
//     "total_entries": 1,
//     "total_pages": 1
//   }
// }
/// A DNS record entry returned by DNSimple.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetRecord<T>
{
    pub id: u64,
    pub zone_id: String,
    pub name: String,
    pub content: T,
    pub ttl: u32,
    #[serde(rename = "type")]
    pub rtype: RecordType,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}


/// Wrapper for record list responses from DNSimple.
#[derive(Serialize, Deserialize, Debug)]
pub struct Records<T>
{
    #[serde(rename = "data")]
    pub records: Vec<GetRecord<T>>
}



// {
//   "name": "",
//   "type": "MX",
//   "content": "mxa.example.com",
//   "ttl": 600,
//   "priority": 10,
//   "regions": ["SV1", "IAD"],
//   "integrated_zones": [1, 2, "dnsimple"]
// }
/// Payload used to create a DNS record on DNSimple.
#[derive(Serialize, Deserialize, Debug)]
pub struct CreateRecord {
    pub name: String,
    #[serde(rename = "type")]
    pub rtype: RecordType,
    pub content: String,
    pub ttl: u32,
    // We can skip the rest; either not needed and/or unsupported on
    // some plans.
}

/// Payload used to update a DNSimple record's content.
#[derive(Serialize, Deserialize, Debug)]
pub struct UpdateRecord {
    pub content: String,
}