Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow dns record types to be specified without the corresponding value when listing dns records #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poscat0x04
Copy link

@poscat0x04 poscat0x04 commented Aug 25, 2021

This pull request fixes the problem described in issue #145 where record types must be specified together with a value of that type by adding a type DnsRecordTypeWithOptionalContent (I'm not good at naming things).

closes #145

Relevant API doc: https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records

#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
#[serde(tag = "type")]
pub enum DnsRecordTypeWithOptionalContent {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the "optional value"?
The ListDnsRecordsParams seems to only really need something as:

pub enum DnsRecordType {
    A,
    AAAA,
    CNAME,
    NS,
    MX,
    TXT,
    SRV,
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it (type) is an optional parameter as shown in the documentation?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it (type) is an optional parameter as shown in the documentation?

I believe you mean the content parameter instead of type. If a Some value is used in the content field then it is added in addition to the type parameter when serializing the record_type field of ListDnsRecordsParams due to #[serde(flatten)]. It may be cleaner to instead add a separate content field to ListDnsRecordsParams so it can be specified without also specifying type.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we won't be able to ensure the type of content matches with the type of type.

@nmldiegues
Copy link
Contributor

Thanks for this fix! I've left a comment/question

@poscat0x04 poscat0x04 force-pushed the fix-list-dns-records-endpoint branch from 1d83928 to f1a26e8 Compare February 15, 2023 05:24
@poscat0x04
Copy link
Author

poscat0x04 commented Feb 15, 2023

What can I do to get this merged?

ping @nataliescottdavidson @adamchalmers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Querying for a specific type of DNS record is broken
3 participants