Class: Cloudflare::API::Zone

Inherits:
BaseAPI
  • Object
show all
Defined in:
lib/cloudflare/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, zone_id) ⇒ Zone

Returns a new instance of Zone.



47
48
49
50
# File 'lib/cloudflare/api.rb', line 47

def initialize(options, zone_id)
  @options = options
  self.class.base_uri "https://api.cloudflare.com/client/v4/zones/#{zone_id}"
end

Instance Method Details

#patch_record(id, updates) ⇒ Object



63
64
65
# File 'lib/cloudflare/api.rb', line 63

def patch_record(id, updates)
  self.class.patch("/dns_records/#{id}", @options.merge(body: updates.to_json))
end

#record(name) ⇒ Object



57
58
59
60
61
# File 'lib/cloudflare/api.rb', line 57

def record(name)
  records = records(name: name)
  raise "#{name} not found" if records.empty?
  records.first
end

#records(query = {}) ⇒ Object



52
53
54
55
# File 'lib/cloudflare/api.rb', line 52

def records(query = {})
  options = @options.merge(query: query)
  self.class.get('/dns_records', options).parsed_response
end