socketry / cloudflare

An asynchronous Ruby wrapper for the CloudFlare V4 API.
138 stars 86 forks source link

Deleting a single dns record #54

Closed advir29 closed 5 years ago

advir29 commented 5 years ago

zone.dns_records.find_by_name("ftp.domain.com").delete

as mentioned in issue #35 used the following but still getting Method DELETE not available for that URI.

I am working on automated acme certificate generation for each of my subdomains. for acme challenge verification inserting a txt record was breeze. But after certificate generation I would like to delete that dns record. Its a TXT record like "_acme-challenge.subdomain.domain.tld"

my method goes like this

Cloudflare.connect(key: @key, email: @email) do |connection|

Remove DNS entry

zone = connection.zones.find_by_name("domain.tld")
zone.dns_records.delete.find_by_name("_acme-challenge.subdomain.domain.tld").delete

end

This should have got the job done. Am I missing out something?

ioquatix commented 5 years ago

What you are trying to do seems reasonable.

Can you check the Cloudflare documentation?

Is there a spec for this functionality?

ioquatix commented 5 years ago

zone.dns_records.delete.find_by_name("_acme-challenge.subdomain.domain.tld").delete

There is delete twice - that seems wrong to me.

advir29 commented 5 years ago

Oops, sorry, my bad. I tried many combinations. Many that was left in cruft. Its working now. zone.dns_records.find_by_name("_acme-challenge.subdomain.domain.tld").delete

Maybe having this in readme would be helpful.

Thanks.

ioquatix commented 5 years ago

Feel free to make a PR for anything you think can help new users.