Thanks to slicehost for giving me an API for managing my DNS zones and records via ActiveResource becauase it saved me lots of time and tedious work. I needed to update my TTL settings in all my domains and rather than having to edit all 61 entries I simply made a ruby script to do it for me:
require 'rubygems'
require 'activeresource'
API_PASSWORD = "MY_SECRET_PASSWORD"
DEFAULT_TTL = 86400
class Record < ActiveResource::Base
self.site = "https://#{API_PASSWORD}@api.slicehost.com/"
end
records = Record.find(:all)
for record in records
record.ttl = DEFAULT_TTL
record.save
end
and while we are at it lets output all of our info:
require 'rubygems'
require 'activeresource'
API_PASSWORD = "MY_SECRET_PASSWORD"
class Zone < ActiveResource::Base
self.site = "https://#{API_PASSWORD}@api.slicehost.com/"
end
class Record < ActiveResource::Base
self.site = "https://#{API_PASSWORD}@api.slicehost.com/"
end
zones = Zone.find(:all)
records = Record.find(:all)
for zone in zones
puts "zone: #{zone.origin}"
for record in records.find_all{|record| record.zone_id == zone.id}
puts " #{record.record_type}: #{record.name} - #{record.data}"
end
end
There, that was easy.