Class: Fabulous::Resources::DNS

Inherits:
Base
  • Object
show all
Defined in:
lib/fabulous/resources/dns.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Fabulous::Resources::Base

Instance Method Details

#a_records(domain_name) ⇒ Object

A Records



83
84
85
86
# File 'lib/fabulous/resources/dns.rb', line 83

def a_records(domain_name)
  response = request("getARecords", domain: domain_name)
  response.data[:a_records] || []
end

#aaaa_records(domain_name) ⇒ Object

AAAA Records (IPv6)



151
152
153
154
# File 'lib/fabulous/resources/dns.rb', line 151

def aaaa_records(domain_name)
  response = request("getAAAARecords", domain: domain_name)
  response.data[:aaaa_records] || []
end

#add_a_record(domain_name, hostname:, ip_address:, ttl: 3600) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/fabulous/resources/dns.rb', line 88

def add_a_record(domain_name, hostname:, ip_address:, ttl: 3600)
  response = request("addARecord", {
    domain: domain_name,
    hostname: hostname,
    ipAddress: ip_address,
    ttl: ttl
  })
  response.success?
end

#add_aaaa_record(domain_name, hostname:, ipv6_address:, ttl: 3600) ⇒ Object



156
157
158
159
160
161
162
163
164
# File 'lib/fabulous/resources/dns.rb', line 156

def add_aaaa_record(domain_name, hostname:, ipv6_address:, ttl: 3600)
  response = request("addAAAARecord", {
    domain: domain_name,
    hostname: hostname,
    ipv6Address: ipv6_address,
    ttl: ttl
  })
  response.success?
end

#add_cname_record(domain_name, alias_name:, target:, ttl: 3600) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/fabulous/resources/dns.rb', line 54

def add_cname_record(domain_name, alias_name:, target:, ttl: 3600)
  response = request("addCNAMERecord", {
    domain: domain_name,
    alias: alias_name,
    target: target,
    ttl: ttl
  })
  response.success?
end

#add_mx_record(domain_name, hostname:, priority:, ttl: 3600) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/fabulous/resources/dns.rb', line 20

def add_mx_record(domain_name, hostname:, priority:, ttl: 3600)
  response = request("addMXRecord", {
    domain: domain_name,
    hostname: hostname,
    priority: priority,
    ttl: ttl
  })
  response.success?
end

#add_txt_record(domain_name, hostname:, text:, ttl: 3600) ⇒ Object



122
123
124
125
126
127
128
129
130
# File 'lib/fabulous/resources/dns.rb', line 122

def add_txt_record(domain_name, hostname:, text:, ttl: 3600)
  response = request("addTXTRecord", {
    domain: domain_name,
    hostname: hostname,
    text: text,
    ttl: ttl
  })
  response.success?
end

#cname_records(domain_name) ⇒ Object

CNAME Records



49
50
51
52
# File 'lib/fabulous/resources/dns.rb', line 49

def cname_records(domain_name)
  response = request("getCNAMERecords", domain: domain_name)
  response.data[:cname_records] || []
end

#delete_a_record(domain_name, record_id) ⇒ Object



111
112
113
114
# File 'lib/fabulous/resources/dns.rb', line 111

def delete_a_record(domain_name, record_id)
  response = request("deleteARecord", domain: domain_name, recordId: record_id)
  response.success?
end

#delete_aaaa_record(domain_name, record_id) ⇒ Object



179
180
181
182
# File 'lib/fabulous/resources/dns.rb', line 179

def delete_aaaa_record(domain_name, record_id)
  response = request("deleteAAAARecord", domain: domain_name, recordId: record_id)
  response.success?
end

#delete_cname_record(domain_name, record_id) ⇒ Object



77
78
79
80
# File 'lib/fabulous/resources/dns.rb', line 77

def delete_cname_record(domain_name, record_id)
  response = request("deleteCNAMERecord", domain: domain_name, recordId: record_id)
  response.success?
end

#delete_mx_record(domain_name, record_id) ⇒ Object



43
44
45
46
# File 'lib/fabulous/resources/dns.rb', line 43

def delete_mx_record(domain_name, record_id)
  response = request("deleteMXRecord", domain: domain_name, recordId: record_id)
  response.success?
end

#delete_txt_record(domain_name, record_id) ⇒ Object



145
146
147
148
# File 'lib/fabulous/resources/dns.rb', line 145

def delete_txt_record(domain_name, record_id)
  response = request("deleteTXTRecord", domain: domain_name, recordId: record_id)
  response.success?
end

#list_records(domain_name, type: nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fabulous/resources/dns.rb', line 6

def list_records(domain_name, type: nil)
  params = { domain: domain_name }
  params[:type] = type if type
  
  response = request("listDNSrecords", params)
  response.data[:dns_records] || []
end

#mx_records(domain_name) ⇒ Object

MX Records



15
16
17
18
# File 'lib/fabulous/resources/dns.rb', line 15

def mx_records(domain_name)
  response = request("getMXRecords", domain: domain_name)
  response.data[:mx_records] || []
end

#txt_records(domain_name) ⇒ Object

TXT Records



117
118
119
120
# File 'lib/fabulous/resources/dns.rb', line 117

def txt_records(domain_name)
  response = request("getTXTRecords", domain: domain_name)
  response.data[:txt_records] || []
end

#update_a_record(domain_name, record_id:, hostname: nil, ip_address: nil, ttl: nil) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fabulous/resources/dns.rb', line 98

def update_a_record(domain_name, record_id:, hostname: nil, ip_address: nil, ttl: nil)
  params = {
    domain: domain_name,
    recordId: record_id
  }
  params[:hostname] = hostname if hostname
  params[:ipAddress] = ip_address if ip_address
  params[:ttl] = ttl if ttl
  
  response = request("updateARecord", params)
  response.success?
end

#update_aaaa_record(domain_name, record_id:, hostname: nil, ipv6_address: nil, ttl: nil) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/fabulous/resources/dns.rb', line 166

def update_aaaa_record(domain_name, record_id:, hostname: nil, ipv6_address: nil, ttl: nil)
  params = {
    domain: domain_name,
    recordId: record_id
  }
  params[:hostname] = hostname if hostname
  params[:ipv6Address] = ipv6_address if ipv6_address
  params[:ttl] = ttl if ttl
  
  response = request("updateAAAARecord", params)
  response.success?
end

#update_cname_record(domain_name, record_id:, alias_name: nil, target: nil, ttl: nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fabulous/resources/dns.rb', line 64

def update_cname_record(domain_name, record_id:, alias_name: nil, target: nil, ttl: nil)
  params = {
    domain: domain_name,
    recordId: record_id
  }
  params[:alias] = alias_name if alias_name
  params[:target] = target if target
  params[:ttl] = ttl if ttl
  
  response = request("updateCNAMERecord", params)
  response.success?
end

#update_mx_record(domain_name, record_id:, hostname: nil, priority: nil, ttl: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fabulous/resources/dns.rb', line 30

def update_mx_record(domain_name, record_id:, hostname: nil, priority: nil, ttl: nil)
  params = {
    domain: domain_name,
    recordId: record_id
  }
  params[:hostname] = hostname if hostname
  params[:priority] = priority if priority
  params[:ttl] = ttl if ttl
  
  response = request("updateMXRecord", params)
  response.success?
end

#update_txt_record(domain_name, record_id:, hostname: nil, text: nil, ttl: nil) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/fabulous/resources/dns.rb', line 132

def update_txt_record(domain_name, record_id:, hostname: nil, text: nil, ttl: nil)
  params = {
    domain: domain_name,
    recordId: record_id
  }
  params[:hostname] = hostname if hostname
  params[:text] = text if text
  params[:ttl] = ttl if ttl
  
  response = request("updateTXTRecord", params)
  response.success?
end