Skip to content

Commit

Permalink
fix: allow dns record types to be specified without the corresponding…
Browse files Browse the repository at this point in the history
… value when listing dns records
  • Loading branch information
Poscat committed Aug 25, 2021
1 parent 288dce6 commit 1d83928
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cloudflare/src/endpoints/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub enum ListDnsRecordsOrder {
#[derive(Serialize, Clone, Debug, Default)]
pub struct ListDnsRecordsParams {
#[serde(flatten)]
pub record_type: Option<DnsContent>,
pub record_type: Option<DnsRecordTypeWithOptionalContent>,
pub name: Option<String>,
pub page: Option<u32>,
pub per_page: Option<u32>,
Expand Down Expand Up @@ -167,6 +167,21 @@ pub enum DnsContent {
SRV { content: String },
}

/// Type of the DNS record, along with a optional value
/// Similar to [`DnsContent`], but is only used in [`ListDnsRecordsParams`]
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
#[serde(tag = "type")]
pub enum DnsRecordTypeWithOptionalContent {
A { content: Option<Ipv4Addr> },
AAAA { content: Option<Ipv6Addr> },
CNAME { content: Option<String> },
NS { content: Option<String> },
MX { content: Option<String> },
TXT { content: Option<String> },
SRV { content: Option<String> },
}

#[derive(Deserialize, Debug)]
pub struct DeleteDnsRecordResponse {
/// DNS record identifier tag
Expand Down

0 comments on commit 1d83928

Please sign in to comment.