feat: ListDnsRecords support different matches on name#290
Open
augustoccesar wants to merge 1 commit into
Open
feat: ListDnsRecords support different matches on name#290augustoccesar wants to merge 1 commit into
augustoccesar wants to merge 1 commit into
Conversation
### Description Currently the `ListDnsRecordsParams` send `name` as a string. This works I'm guessing because of backwards compatibility, but it seems like this is [not a documented way anymore](https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/list/#(resource)%20dns.records%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20name%20%3E%20(schema)). The documentation expects `name` to contain: - contains: Substring of the DNS record name. - endswith: Suffix of the DNS record name. - exact: Exact value of the DNS record name. - startswith: Prefix of the DNS record name. With the current implementation, the only supported is `exact`, as it seems like that is the behavior if `name` is sent as a string. ### Why flatten? [`serde_urlencoded`](https://github.com/nox/serde_urlencoded) does not seem to support nested objects. Also seems like they are not really maintained anymore. Could be interesting to change to https://docs.rs/serde_qs/latest/serde_qs as a separate effort. > This crate is a Rust library for serialising to and deserialising from querystrings using serde. This crate is designed to extend serde_urlencoded when using nested parameters ### References: - https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/list/#(resource)%20dns.records%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20name%20%3E%20(schema)
augustoccesar
added a commit
to augustoccesar/cloudflare-rs
that referenced
this pull request
Apr 13, 2026
### Description While working on cloudflare#290 I faced the issue of serializing nested structs with `serde_urlencoded`. It is not supported by it, and iself seems to be unmaintained. It seems like the "modern" one for serializing query parameters is `serde_qs`. So this PR proposes the change to it. ### References - https://github.com/nox/serde_urlencoded - nox/serde_urlencoded#121 - https://github.com/samscott89/serde_qs
Contributor
Author
|
If #291 gets merged, we can change this to: #[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug, Default)]
pub struct ListDnsRecordsParams {
#[serde(flatten)]
pub record_type: Option<DnsContent>,
pub name: Option<String>,
- #[serde(flatten)]
pub name: Option<ListDnsRecordsParamsName>,
pub page: Option<u32>,
pub per_page: Option<u32>,
pub order: Option<ListDnsRecordsOrder>,
pub direction: Option<OrderDirection>,
#[serde(rename = "match")]
pub search_match: Option<SearchMatch>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug, Default)]
pub struct ListDnsRecordsParamsName {
- #[serde(rename = "name.contains")]
pub contains: Option<String>,
- #[serde(rename = "name.startswith")]
+ #[serde(rename = "startswith")]
pub starts_with: Option<String>,
- #[serde(rename = "name.endswith")]
+ #[serde(rename = "endswith")]
pub ends_with: Option<String>,
- #[serde(rename = "name.exact")]
pub exact: Option<String>,
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently the
ListDnsRecordsParamssendnameas a string. This works I'm guessing because of backwards compatibility, but it seems like this is not a documented way anymore.The documentation expects
nameto contain:contains: Substring of the DNS record name.endswith: Suffix of the DNS record name.exact: Exact value of the DNS record name.startswith: Prefix of the DNS record name.With the current implementation, the only supported is
exact, as it seems like that is the behavior ifnameis sent as a string.Why flatten?
serde_urlencodeddoes not seem to support nested objects. Also seems like they are not really maintained anymore. Could be interesting to change to serde_qs as a separate effort.References: