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 authored and poscat0x04 committed Feb 15, 2023
1 parent fd8827a commit f1a26e8
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 @@ -136,7 +136,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 @@ -169,6 +169,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 f1a26e8

Please sign in to comment.