Class: Designate::Client
- Inherits:
-
Object
- Object
- Designate::Client
- Defined in:
- lib/designate/client.rb
Constant Summary collapse
- API_VERSION =
"1.1"
- DOMAIN =
"ns.zerigo.com"
Instance Method Summary collapse
- #create_zone(domain, options = {}) ⇒ Object
- #find_or_create_zone(domain) ⇒ Object
- #find_template_by_id(id) ⇒ Object
- #find_zone_by_domain(domain) ⇒ Object
- #find_zone_by_id(id) ⇒ Object
-
#initialize(email, key) ⇒ Client
constructor
A new instance of Client.
- #templates ⇒ Object
- #zones ⇒ Object
Constructor Details
#initialize(email, key) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/designate/client.rb', line 9 def initialize(email, key) @@auth_string = CGI.escape(email) + ':' + CGI.escape(key) end |
Instance Method Details
#create_zone(domain, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/designate/client.rb', line 31 def create_zone(domain, = {}) [:domain] = domain [:default_ttl] ||= 14400 [:nx_ttl] ||= 900 if [:zone_template_id] [:follow_template] ||= 'no' end if zone = post("zones.xml", { :zone => })['zone'] Zone.new(zone) end end |
#find_or_create_zone(domain) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/designate/client.rb', line 43 def find_or_create_zone(domain) if zone = find_zone_by_domain(domain) return zone else create_zone(domain) end end |
#find_template_by_id(id) ⇒ Object
57 58 59 60 61 |
# File 'lib/designate/client.rb', line 57 def find_template_by_id(id) if template = get("zone_templates/#{id}.xml")['zone_template'] Template.new(template) end end |
#find_zone_by_domain(domain) ⇒ Object
25 26 27 28 29 |
# File 'lib/designate/client.rb', line 25 def find_zone_by_domain(domain) if zone = get("zones/#{domain}.xml")['zone'] Zone.new(zone) end end |
#find_zone_by_id(id) ⇒ Object
19 20 21 22 23 |
# File 'lib/designate/client.rb', line 19 def find_zone_by_id(id) if zone = get("zones/#{id}.xml")['zone'] Zone.new(zone) end end |