Class: VagrantPlugins::DnsUpdater::Registrar::Ovh
- Defined in:
- lib/vagrant-dns-updater/registrar/ovh.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Ovh
constructor
A new instance of Ovh.
- #remove_dns_record ⇒ Object
- #set_dns_record(ip) ⇒ Object
Methods inherited from Registrar
Constructor Details
#initialize(config) ⇒ Ovh
Returns a new instance of Ovh.
10 11 12 13 14 15 |
# File 'lib/vagrant-dns-updater/registrar/ovh.rb', line 10 def initialize(config) @zone = config.zone @subdomain = config.subdomain @ttl = config.ttl @api = OVH::REST.new config.appkey, config.appsecret, config.consumerkey end |
Instance Method Details
#remove_dns_record ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/vagrant-dns-updater/registrar/ovh.rb', line 39 def remove_dns_record begin record_id = get_record_id @api.delete("/domain/zone/#{@zone}/record/#{record_id}") unless record_id.nil? rescue OVH::RESTError => error raise Vagrant::Errors::VagrantError.new, "DnsUpdater: #{error}" end end |
#set_dns_record(ip) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-dns-updater/registrar/ovh.rb', line 17 def set_dns_record(ip) begin record_id = get_record_id if record_id.nil? @api.post("/domain/zone/#{@zone}/record", { 'fieldType' => 'A', 'target' => ip, 'subDomain' => @subdomain, 'ttl' => @ttl}) else @api.put("/domain/zone/#{@zone}/record/#{record_id}", { 'target' => ip, 'subDomain' => @subdomain, 'ttl' => @ttl}) end @api.post("/domain/zone/#{@zone}/refresh") rescue OVH::RESTError => error raise Vagrant::Errors::VagrantError.new, "DnsUpdater: #{error}" end end |