-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the wiki of the Official Zerigo DNS Gem.
You can no longer use password
in the configuration to set the API key.
ActiveResource
is no longer used; these things have changed:
-
#find(:all, ...)
becomes#all(...)
-
#save
becomes#update(field: "new_value")
. - Any status code not 200-299 or 302 will raise an exception (e.g.
422
errors returned by posting bad data or404
errors). -
update
/destroy
methods called on the class return aFaraday::Response
, and will throw exceptions when the operation fails.
In your gemfile, put:
gem 'zerigodns', version: '~> 1.1.0'
Before using the gem, you will need to configure it with your account's e-mail address and API key:
require 'zerigodns'
ZerigoDNS.configure do |config|
config.user = '[email protected]'
config.api_key = 'yourtokengoeshere'
end
domain = ZerigoDNS::Zone.create(domain: 'yourdomain.com', ns_type: 'pri_sec')
domain.destroy
Additionally, you can delete a zone by id
:
ZerigoDNS::Zone.destroy(zone_id)
Assuming domain
is a zone
host = ZerigoDNS::Host.create(zone_id: domain.id, hostname: 'www', host_type: 'A', ttl: 86400, data: '10.10.10.10')
Assuming host
is a host record.
# hostname type ttl data
Host.update_or_create(domain, 'www', 'A', 86400, '10.10.10.10')
caveat: The host record updated will be the first host record found by its fully qualified domain name. If multiple records exist, only one will be updated.
If you have mulitple host records with the same hostname, you can narrow them down by locating a specific record by IP address.
hosts = Host.find_all_by_hostname(zone, 'www')
host = hosts.detect{|h| h.data == '10.10.10.10'}
host.update data: '10.10.10.11'
Assuming domain
is a zone
@hosts = Host.find_all_by_hostname(domain, 'www')
You can then search through @hosts
to find the desired host record.
host.destroy
Also, you can delete a host by id:
ZerigoDNS::Host.destroy(host_id)
You can use zone templates to manage similar configurations on different domains.
template = ZerigoDNS::ZoneTemplate.create(custom_ns: false, default_ttl: 900, ns_type: 'pri_sec', name: 'my-template')
This will create an ALIAS
record which points to the domain's www
record. Any @
symbol in the data will be replaced with the actual domain name.
host_template = template.create_host_template(data: 'www.@', hostname: nil, host_type: 'ALIAS')
zone = template.create_zone(domain: 'mydomain.com')
This will create a zone which will automatically sync with changes to the zone template.
It's easy, just fork the repository, create a feature branch, then when you are ready, create a pull request. If you are proposing a new feature, feel free to create an issue first so we can give you feedback.
You can find the full documentation on RubyDoc.info.