Class: Bunny::Zone

Inherits:
Object
  • Object
show all
Defined in:
lib/bunny/models/zone.rb

Class Method Summary collapse

Methods inherited from Object

#camel_to_snake, #initialize, #to_ostruct

Constructor Details

This class inherits a constructor from Bunny::Object

Class Method Details

.check_availability(name:) ⇒ Object



38
39
40
41
# File 'lib/bunny/models/zone.rb', line 38

def check_availability(name:)
  response = Client.post_request("dnszone/checkavailability", body: { Domain: name })
  response.body["Available"]
end

.create(name:) ⇒ Object



9
10
11
12
# File 'lib/bunny/models/zone.rb', line 9

def create(name:)
  response = Client.post_request("dnszone", body: { Domain: name })
  Zone.new(response.body)
end

.create_record(zone:, type:, value:, **attributes) ⇒ Object



43
44
45
46
# File 'lib/bunny/models/zone.rb', line 43

def create_record(zone:, type:, value:, **attributes)
  response = Client.put_request("dnszone/#{zone}/records", body: attributes.merge(type: type, value: value))
  Record.new(response.body)
end

.delete(id:) ⇒ Object



24
25
26
# File 'lib/bunny/models/zone.rb', line 24

def delete(id:)
  Client.delete_request("dnszone/#{id}")
end

.delete_record(zone:, record:) ⇒ Object



52
53
54
# File 'lib/bunny/models/zone.rb', line 52

def delete_record(zone:, record:)
  Client.delete_request("dnszone/#{zone}/records/#{record}")
end

.export(id:) ⇒ Object



28
29
30
31
# File 'lib/bunny/models/zone.rb', line 28

def export(id:)
  response = Client.get_request("dnszone/#{id}/export")
  response.body
end

.listObject



4
5
6
7
# File 'lib/bunny/models/zone.rb', line 4

def list
  response = Client.get_request("dnszone")
  Collection.from_response(response, type: Zone, key: "Items")
end

.retrieve(id:) ⇒ Object



14
15
16
17
# File 'lib/bunny/models/zone.rb', line 14

def retrieve(id:)
  response = Client.get_request("dnszone/#{id}")
  Zone.new(response.body)
end

.stats(id:) ⇒ Object



33
34
35
36
# File 'lib/bunny/models/zone.rb', line 33

def stats(id:)
  response = Client.get_request("dnszone/#{id}/statistics")
  ZoneStatistic.new(response.body)
end

.update(id:, **attributes) ⇒ Object



19
20
21
22
# File 'lib/bunny/models/zone.rb', line 19

def update(id:, **attributes)
  response = Client.post_request("dnszone/#{id}", body: attributes)
  Zone.new(response.body)
end

.update_record(zone:, record:, **attributes) ⇒ Object



48
49
50
# File 'lib/bunny/models/zone.rb', line 48

def update_record(zone:, record:, **attributes)
  Client.post_request("dnszone/#{zone}/records/#{record}", body: attributes)
end