From bd252030d0c1cfb575892e60180c6450e84c3d1c Mon Sep 17 00:00:00 2001 From: Cowboylaserkittenjetshark <82691052+Cowboylaserkittenjetshark@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:17:58 -0400 Subject: [PATCH 1/3] Add missing fields to DnsRecord & UpdateDnsRecordParams --- cloudflare/src/endpoints/dns.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cloudflare/src/endpoints/dns.rs b/cloudflare/src/endpoints/dns.rs index 871945ff..92e85a21 100644 --- a/cloudflare/src/endpoints/dns.rs +++ b/cloudflare/src/endpoints/dns.rs @@ -125,6 +125,10 @@ pub struct UpdateDnsRecordParams<'a> { /// Type of the DNS record that also holds the record value #[serde(flatten)] pub content: DnsContent, + /// Comments or notes about the DNS record + pub comment: Option<&'a str>, + /// Custom tags for the DNS record. This field has no effect on DNS responses + pub tags: &'a Vec, } #[derive(Serialize, Clone, Debug)] @@ -207,6 +211,10 @@ pub struct DnsRecord { pub proxied: bool, /// The domain of the record pub zone_name: String, + /// Comments or notes about the DNS record + pub comment: Option, + /// Custom tags for the DNS record. This field has no effect on DNS responses + pub tags: Vec, } impl ApiResult for DnsRecord {} From a71b310037670de4e00cc27cee235127d2d1d9ac Mon Sep 17 00:00:00 2001 From: Cowboylaserkittenjetshark <82691052+Cowboylaserkittenjetshark@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:52:27 -0500 Subject: [PATCH 2/3] Fix: tags is not required, make optional --- cloudflare/src/endpoints/dns.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudflare/src/endpoints/dns.rs b/cloudflare/src/endpoints/dns.rs index 92e85a21..d48f42d9 100644 --- a/cloudflare/src/endpoints/dns.rs +++ b/cloudflare/src/endpoints/dns.rs @@ -128,7 +128,7 @@ pub struct UpdateDnsRecordParams<'a> { /// Comments or notes about the DNS record pub comment: Option<&'a str>, /// Custom tags for the DNS record. This field has no effect on DNS responses - pub tags: &'a Vec, + pub tags: Option<&'a Vec>, } #[derive(Serialize, Clone, Debug)] From f9278fa99c7b7b81d51d9e819d680af664429db8 Mon Sep 17 00:00:00 2001 From: Cowboylaserkittenjetshark <82691052+Cowboylaserkittenjetshark@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:03:02 -0500 Subject: [PATCH 3/3] Add PatchDnsRecord endpoint --- cloudflare/src/endpoints/dns.rs | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/cloudflare/src/endpoints/dns.rs b/cloudflare/src/endpoints/dns.rs index d48f42d9..9450d4ec 100644 --- a/cloudflare/src/endpoints/dns.rs +++ b/cloudflare/src/endpoints/dns.rs @@ -131,6 +131,50 @@ pub struct UpdateDnsRecordParams<'a> { pub tags: Option<&'a Vec>, } +/// Patch DNS Record +/// +#[derive(Debug)] +pub struct PatchDnsRecord<'a> { + pub zone_identifier: &'a str, + pub identifier: &'a str, + pub params: PatchDnsRecordParams<'a>, +} + +impl<'a> EndpointSpec for PatchDnsRecord<'a> { + fn method(&self) -> Method { + Method::PATCH + } + fn path(&self) -> String { + format!( + "zones/{}/dns_records/{}", + self.zone_identifier, self.identifier + ) + } + #[inline] + fn body(&self) -> Option { + let body = serde_json::to_string(&self.params).unwrap(); + Some(body) + } +} + +#[serde_with::skip_serializing_none] +#[derive(Serialize, Clone, Debug)] +pub struct PatchDnsRecordParams<'a> { + /// Time to live for DNS record. Value of 1 is 'automatic' + pub ttl: Option, + /// Whether the record is receiving the performance and security benefits of Cloudflare + pub proxied: Option, + /// DNS record name + pub name: &'a str, + /// Type of the DNS record that also holds the record value + #[serde(flatten)] + pub content: DnsContent, + /// Comments or notes about the DNS record + pub comment: Option<&'a str>, + /// Custom tags for the DNS record. This field has no effect on DNS responses + pub tags: Option<&'a Vec>, +} + #[derive(Serialize, Clone, Debug)] #[serde(rename_all = "lowercase")] pub enum ListDnsRecordsOrder {