Class: Sunzi::Vps::DNS::DigitalOcean
- Inherits:
-
Base
- Object
- Base
- Sunzi::Vps::DNS::DigitalOcean
show all
- Defined in:
- lib/sunzi/vps/dns/digital_ocean.rb
Instance Attribute Summary
Attributes inherited from Base
#api
Instance Method Summary
collapse
Methods inherited from Base
#client, #initialize
Instance Method Details
#add(fqdn, ip) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/sunzi/vps/dns/digital_ocean.rb', line 13
def add(fqdn, ip)
say 'adding the public IP to DigitalOcean DNS...'
client.domain_records.create(
DropletKit::DomainRecord.new(
type: 'A',
name: fqdn.sub('.' + @domain.name, ''),
data: ip,
),
for_domain: @domain.name
)
end
|
#delete(ip) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/sunzi/vps/dns/digital_ocean.rb', line 25
def delete(ip)
say 'deleting the public IP from DigitalOcean DNS...'
domain_record = client.domain_records.all(for_domain: @domain.name).find{|i| i.type == 'A' && i.data == ip }
abort_with "ip address #{ip} was not found on DigitalOcean DNS!" unless domain_record
client.domain_records.delete(id: domain_record.id, for_domain: @domain.name)
end
|
#verify ⇒ Object
6
7
8
9
10
11
|
# File 'lib/sunzi/vps/dns/digital_ocean.rb', line 6
def verify
@domain = client.domains.find(name: @zone)
rescue DropletKit::Error => e
abort_with "zone for #{@zone} was not found on DigitalOcean DNS!" if e.message =~ /not_found/
raise
end
|