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 = @domain, options = {}) ⇒ Object
- #find_or_create_zone(domain = @domain) ⇒ Object
- #find_template_by_id(id) ⇒ Object
- #find_zone_by_domain(domain = @domain) ⇒ Object
- #find_zone_by_id(id) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #templates ⇒ Object
- #zerigo_config ⇒ Object
- #zones ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/designate/client.rb', line 9 def initialize() @@auth_string = CGI.escape(zerigo_config[:username]) + ':' + CGI.escape(zerigo_config[:key]) @domain = zerigo_config[:domain] end |
Instance Method Details
#create_zone(domain = @domain, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/designate/client.rb', line 36 def create_zone(domain = @domain, = {}) [:domain] = domain [:default_ttl] ||= 14400 [:nx_ttl] ||= 300 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 = @domain) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/designate/client.rb', line 48 def find_or_create_zone(domain = @domain) if zone = find_zone_by_domain(domain) return zone else create_zone(domain) end end |
#find_template_by_id(id) ⇒ Object
62 63 64 65 66 |
# File 'lib/designate/client.rb', line 62 def find_template_by_id(id) if template = get("zone_templates/#{id}.xml")['zone_template'] rescue false Template.new(template) end end |
#find_zone_by_domain(domain = @domain) ⇒ Object
30 31 32 33 34 |
# File 'lib/designate/client.rb', line 30 def find_zone_by_domain(domain = @domain) if zone = get("zones/#{domain}.xml")['zone'] rescue false Zone.new(zone) end end |
#find_zone_by_id(id) ⇒ Object
24 25 26 27 28 |
# File 'lib/designate/client.rb', line 24 def find_zone_by_id(id) if zone = get("zones/#{id}.xml")['zone'] rescue false Zone.new(zone) end end |
#templates ⇒ Object
56 57 58 59 60 |
# File 'lib/designate/client.rb', line 56 def templates templates = [] get('zone_templates.xml')['zone_templates'].each { |template| templates << Template.new(template) } return templates end |
#zerigo_config ⇒ Object
14 15 16 |
# File 'lib/designate/client.rb', line 14 def zerigo_config() YAML.load(File.new("config/zerigo.yml")) end |