Skip to content

Instantly share code, notes, and snippets.

@moyashiki
Created February 18, 2014 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyashiki/9072341 to your computer and use it in GitHub Desktop.
Save moyashiki/9072341 to your computer and use it in GitHub Desktop.
namedotcom_update
require 'name_dot_com_api'
require 'pp'
api_token = "honoka"
api_token_ = "umi"
username = "umichankawaii-ote"
username_ = "umichankawaii"
record_id = ""
#
# Get global ip address
#
client = NameDotComApi::Client.new(username_,api_token_)
res = client.hello
current_ip = res['client_ip']
#
# Get dns records
#
res = client.list_dns_records('umichankawaii.org')
res['records'].each do | record |
record_id = record['record_id'] if record['name'] == "umi.umichankawaii.org" && record['type'] == "A"
end
#
# Delete a dns record
#
res = client.delete_dns_record("umichankawaii.org",record_id.to_i)
#
# Add a dns record
#
res = client.add_dns_record("umichankawaii.org","umi","A",current_ip,300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment