Last active
December 1, 2016 02:44
-
-
Save kirkelifson/acc4af058393158c0a4d9cd9c9549774 to your computer and use it in GitHub Desktop.
Quick update to signalflare using API v4 wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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