From c70b3a6cac51309fa0c492b2dca74d55f8b9b8d5 Mon Sep 17 00:00:00 2001 From: Mark Pritchard Date: Thu, 30 Jan 2020 22:03:11 +1100 Subject: [PATCH] feat(endpoints): add dns update --- cloudflare/src/endpoints/dns.rs | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cloudflare/src/endpoints/dns.rs b/cloudflare/src/endpoints/dns.rs index a83f7bcd..91066b0b 100644 --- a/cloudflare/src/endpoints/dns.rs +++ b/cloudflare/src/endpoints/dns.rs @@ -80,6 +80,40 @@ impl<'a> Endpoint for DeleteDnsRecord<'a> { } } +/// Update DNS Record +/// https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record +pub struct UpdateDnsRecord<'a> { + pub zone_identifier: &'a str, + pub identifier: &'a str, + pub params: UpdateDnsRecordParams<'a>, +} + +impl<'a> Endpoint> for UpdateDnsRecord<'a> { + fn method(&self) -> Method { + Method::Put + } + fn path(&self) -> String { + format!("zones/{}/dns_records/{}", self.zone_identifier, self.identifier) + } + fn body(&self) -> Option> { + Some(self.params.clone()) + } +} + +#[serde_with::skip_serializing_none] +#[derive(Serialize, Clone, Debug)] +pub struct UpdateDnsRecordParams<'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, +} + #[derive(Serialize, Clone, Debug)] #[serde(rename_all = "lowercase")] pub enum ListDnsRecordsOrder {