agentmail/types/domains.rs
1use serde::{Deserialize, Serialize};
2
3/// A sending domain, as the API returns it.
4#[derive(Clone, Debug, Deserialize)]
5pub struct Domain {
6 /// Unique domain id.
7 pub domain_id: String,
8 /// The domain name, e.g. `mail.example.com`.
9 #[serde(default)]
10 pub domain: Option<String>,
11 /// Owning pod, when the account uses pods.
12 #[serde(default)]
13 pub pod_id: Option<String>,
14 /// Verification status (e.g. `pending`, `verified`).
15 #[serde(default)]
16 pub status: Option<String>,
17 /// Whether bounce/complaint feedback is enabled.
18 #[serde(default)]
19 pub feedback_enabled: Option<bool>,
20 /// Whether subdomains of this domain may be used for inboxes.
21 #[serde(default)]
22 pub subdomains_enabled: Option<bool>,
23 /// The DNS records to add for verification and sending.
24 #[serde(default)]
25 pub records: Vec<VerificationRecord>,
26 /// Your reference id from creation, when set.
27 #[serde(default)]
28 pub client_id: Option<String>,
29 /// Timestamp the domain was last updated (RFC 3339).
30 #[serde(default)]
31 pub updated_at: Option<String>,
32 /// Timestamp the domain was created (RFC 3339).
33 #[serde(default)]
34 pub created_at: Option<String>,
35}
36
37/// A single DNS record to publish for a domain.
38#[derive(Clone, Debug, Deserialize)]
39pub struct VerificationRecord {
40 /// DNS record type, e.g. `TXT`, `MX`, `CNAME`.
41 #[serde(rename = "type")]
42 pub record_type: String,
43 /// The record name (host).
44 pub name: String,
45 /// The record value.
46 pub value: String,
47 /// Verification status of this record.
48 #[serde(default)]
49 pub status: Option<String>,
50 /// Priority, for records that need one (e.g. `MX`).
51 #[serde(default)]
52 pub priority: Option<i64>,
53}
54
55/// Request body for [`Client::create_domain`](crate::Client::create_domain).
56#[derive(Clone, Debug, Default, Serialize)]
57pub struct CreateDomain {
58 /// The domain name to add.
59 pub domain: String,
60 /// Enable bounce/complaint feedback.
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub feedback_enabled: Option<bool>,
63 /// Allow subdomains of this domain to be used for inboxes.
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub subdomains_enabled: Option<bool>,
66}
67
68/// Request body for [`Client::update_domain`](crate::Client::update_domain). Fields left `None` stay unchanged.
69#[derive(Clone, Debug, Default, Serialize)]
70pub struct UpdateDomain {
71 /// Enable or disable bounce/complaint feedback.
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub feedback_enabled: Option<bool>,
74 /// Enable or disable subdomains for inbox use.
75 #[serde(skip_serializing_if = "Option::is_none")]
76 pub subdomains_enabled: Option<bool>,
77}
78
79/// One page of domains from [`Client::list_domains_page`](crate::Client::list_domains_page).
80#[derive(Clone, Debug, Deserialize)]
81pub struct DomainList {
82 /// Total domains in the account (not just this page).
83 pub count: u64,
84 /// This page of domains.
85 #[serde(default)]
86 pub domains: Vec<Domain>,
87 /// Cursor for the next page; `None` on the last page.
88 #[serde(default)]
89 pub next_page_token: Option<String>,
90}