Skip to content

Instantly share code, notes, and snippets.

@kirkelifson
Last active December 1, 2016 02:44
Show Gist options
  • Save kirkelifson/acc4af058393158c0a4d9cd9c9549774 to your computer and use it in GitHub Desktop.
Save kirkelifson/acc4af058393158c0a4d9cd9c9549774 to your computer and use it in GitHub Desktop.
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