Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Fetching a zone in bind config format #39

Closed
mikehardenize opened this issue Aug 21, 2018 · 7 comments
Closed

Fetching a zone in bind config format #39

mikehardenize opened this issue Aug 21, 2018 · 7 comments

Comments

@mikehardenize
Copy link
Contributor

You can fetch a cloudflare zone by calling:

GET zones/$zone_id/dns_records

This is possible with node-cloudflare. However, you can fetch it in bind configuration syntax if you append /export:

GET zones/$zone_id/dns_records/export

This does not appear to be possible with node-cloudflare. Please consider adding this functionality.

@mikehardenize
Copy link
Contributor Author

FWIW, I added the following to DNSRecords.js:

bindConfig: method({
  method: 'GET',
  path: 'export',
  json: false,
}),

Allowing me to call:

cf.dnsRecords.bindConfig(zone_id);

This worked fine. I haven't submitted it as a PR as I suspect you would maybe want to expand "browse" instead, or give the function a different name?

I'm happy to submit as a PR, with or without changes. Let me know...

@mikehardenize
Copy link
Contributor Author

Additionally, I know this feature isn't in the current set of cloudflare API documentation, but I believe that is an oversight. I have reached out to cloudflare support regarding the issue and they responded:

Thank you for bringing this to our attention, I believe this should be documented,
as we do document /import. I have reached out to the team who owns the
documentation to see if we can get this updated to include /export.

In the meantime, I have confirmed that it is just a GET request with the endpoint
being /export, if you do need/want to use the endpoint.

As another data point, they use this API end-point themselves on their own frontend to allow users to export zones in this format.

@mikehardenize
Copy link
Contributor Author

Not heard anything, so submitting as a PR

@terinjokes
Copy link
Contributor

In general, I prefer not to add functionality that isn't documented.

@mikehardenize
Copy link
Contributor Author

FWIW, I got another response from Cloudflare this morning, to say:

We appreciate your patience here. We've heard back that our API documentation should
be updated to include this information toward the latter half of the month.

We're happy to update you again with a more concrete date when the documentation is
updated - just let us know.

So I don't think we'll have to wait too long.

@mikehardenize
Copy link
Contributor Author

This feature is now documented. You can see it at https://api.cloudflare.com/#dns-records-for-a-zone-export-dns-records

@terinjokes
Copy link
Contributor

Released in v2.6.0.

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

Successfully merging a pull request may close this issue.

2 participants