agentmail/client/
domains.rs1use crate::client::NoBody;
2use crate::{Client, Error, Page, types::*, util::urlish};
3
4impl Client {
5 pub async fn create_domain(&self, domain: CreateDomain) -> Result<Domain, Error> {
8 self.request(reqwest::Method::POST, "/v0/domains", &[], Some(&domain))
9 .await
10 }
11
12 pub async fn list_domains(&self) -> Result<DomainList, Error> {
14 self.list_domains_page(Page::default()).await
15 }
16
17 pub async fn list_domains_page(&self, page: Page) -> Result<DomainList, Error> {
20 self.request(
21 reqwest::Method::GET,
22 "/v0/domains",
23 &page.query(),
24 None::<&NoBody>,
25 )
26 .await
27 }
28
29 pub async fn get_domain(&self, domain_id: &str) -> Result<Domain, Error> {
31 self.request(
32 reqwest::Method::GET,
33 &format!("/v0/domains/{}", urlish(domain_id)),
34 &[],
35 None::<&NoBody>,
36 )
37 .await
38 }
39
40 pub async fn update_domain(
42 &self,
43 domain_id: &str,
44 update: UpdateDomain,
45 ) -> Result<Domain, Error> {
46 self.request(
47 reqwest::Method::PATCH,
48 &format!("/v0/domains/{}", urlish(domain_id)),
49 &[],
50 Some(&update),
51 )
52 .await
53 }
54
55 pub async fn delete_domain(&self, domain_id: &str) -> Result<(), Error> {
57 self.request(
58 reqwest::Method::DELETE,
59 &format!("/v0/domains/{}", urlish(domain_id)),
60 &[],
61 None::<&NoBody>,
62 )
63 .await
64 }
65
66 pub async fn verify_domain(&self, domain_id: &str) -> Result<(), Error> {
70 self.request(
71 reqwest::Method::POST,
72 &format!("/v0/domains/{}/verify", urlish(domain_id)),
73 &[],
74 None::<&NoBody>,
75 )
76 .await
77 }
78
79 pub async fn get_domain_zone_file(&self, domain_id: &str) -> Result<String, Error> {
82 self.request_text(
83 reqwest::Method::GET,
84 &format!("/v0/domains/{}/zone-file", urlish(domain_id)),
85 )
86 .await
87 }
88}