cloudflare / node-cloudflare

Node.js API for Client API
https://cloudflare.github.io/node-cloudflare/
Other
335 stars 92 forks source link

Fetching a zone in bind config format #39

Closed mikehardenize closed 5 years ago

mikehardenize commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Not heard anything, so submitting as a PR

terinjokes commented 6 years ago

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

mikehardenize commented 6 years ago

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 commented 6 years ago

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

terinjokes commented 5 years ago

Released in v2.6.0.