Class: Zonesync::Cloudflare
Instance Attribute Summary
Attributes inherited from Provider
#credentials
Instance Method Summary
collapse
Methods inherited from Provider
#diffable_records, from, #write
Instance Method Details
#add(record) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/zonesync/cloudflare.rb', line 26
def add record
http.post(nil, {
name: record[:name],
type: record[:type],
ttl: record[:ttl],
content: record[:rdata],
comment: record[:comment],
})
end
|
#change(old_record, new_record) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/zonesync/cloudflare.rb', line 15
def change old_record, new_record
id = records.fetch(old_record)
http.patch("/#{id}", {
name: new_record[:name],
type: new_record[:type],
ttl: new_record[:ttl],
content: new_record[:rdata],
comment: new_record[:comment],
})
end
|
#read ⇒ Object
6
7
8
|
# File 'lib/zonesync/cloudflare.rb', line 6
def read
http.get("/export")
end
|
#records ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/zonesync/cloudflare.rb', line 36
def records
@records ||= begin
response = http.get(nil)
response["result"].reduce({}) do |map, attrs|
map.merge to_record(attrs) => attrs["id"]
end
end
end
|
#remove(record) ⇒ Object
10
11
12
13
|
# File 'lib/zonesync/cloudflare.rb', line 10
def remove record
id = records.fetch(record)
http.delete("/#{id}")
end
|