Skip to content

Commit

Permalink
feat(endpoints): add dns update
Browse files Browse the repository at this point in the history
  • Loading branch information
markpritchard authored and adamchalmers committed Jan 31, 2020
1 parent ce6a15f commit c70b3a6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cloudflare/src/endpoints/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,40 @@ impl<'a> Endpoint<DeleteDnsRecordResponse> 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<DnsRecord, (), UpdateDnsRecordParams<'a>> 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<UpdateDnsRecordParams<'a>> {
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<u32>,
/// Whether the record is receiving the performance and security benefits of Cloudflare
pub proxied: Option<bool>,
/// 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 {
Expand Down

0 comments on commit c70b3a6

Please sign in to comment.