Skip to content

Instantly share code, notes, and snippets.

Last active December 1, 2016 02:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Quick update to signalflare using API v4 wrapper
require 'rubyflare'
ip = { content: `curl -s`.chomp }
zone_name = ""
hostnames = ['', '', '']
email = 'EMAIL-HERE'
api_key = 'API-KEY-HERE'
cloudflare = Rubyflare.connect_with(email, api_key)
zone_id = cloudflare.get('zones'){ |z| z[:name] == zone_name }.first[:id]
records = cloudflare.get("zones/#{zone_id}/dns_records") { |r| hostnames.include? r[:name] }
records.each do |record|
dns_record = cloudflare.put("zones/#{zone_id}/dns_records/#{record[:id]}", record.merge(ip))
p dns_record.result
rescue => e
p e.response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment