Skip to content

Commit 4c8ad65

Browse files
committed
work on records
1 parent a9b7c4b commit 4c8ad65

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

lib/hetzner_dns.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ def self.config
2323
end
2424

2525
autoload :Zone, "hetzner_dns/models/zone"
26+
autoload :Record, "hetzner_dns/models/record"
2627

2728
end

lib/hetzner_dns/models/record.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module HetznerDNS
2+
class Record < Object
3+
end
4+
end

lib/hetzner_dns/models/zone.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ def delete(id:)
2828
response.success?
2929
end
3030

31+
def records(id:)
32+
response = Client.get_request("records", params: { zone_id: id })
33+
Collection.from_response(response, type: Record, key: "records")
34+
end
35+
36+
def create_record(zone:, name:, type:, value:, ttl: nil)
37+
response = Client.post_request("records", body: { zone_id: zone, name: name, type: type, value: value, ttl: ttl })
38+
Record.new(response.body["record"])
39+
end
40+
41+
def update_record(zone:, record:, name:, type:, value:, ttl: nil)
42+
response = Client.put_request("records/#{record}", body: { zone_id: zone, name: name, type: type, value: value, ttl: ttl })
43+
Record.new(response.body["record"])
44+
end
45+
3146
end
3247

3348
end

0 commit comments

Comments
 (0)