Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick update to signalflare using API v4 wrapper
require 'rubyflare'
ip = { content: `curl -s https://ifconfig.co`.chomp }
zone_name = "parodybit.net"
hostnames = ['host1.parodybit.net', 'host2.parodybit.net', 'host3.parodybit.net']
email = 'EMAIL-HERE'
api_key = 'API-KEY-HERE'
cloudflare = Rubyflare.connect_with(email, api_key)
zone_id = cloudflare.get('zones').results.select{ |z| z[:name] == zone_name }.first[:id]
records = cloudflare.get("zones/#{zone_id}/dns_records").results.select { |r| hostnames.include? r[:name] }
records.each do |record|
begin
dns_record = cloudflare.put("zones/#{zone_id}/dns_records/#{record[:id]}", record.merge(ip))
p dns_record.result
rescue => e
p e.response
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.