Created
February 18, 2014 14:47
-
-
Save moyashiki/9072341 to your computer and use it in GitHub Desktop.
namedotcom_update
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 '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