module Myra::DnsRecords

Constants

PATH

Public Class Methods

create(record, domain) click to toggle source
# File lib/myra/actions/dns_records.rb, line 13
def self.create(record, domain)
  record = normalize_domain_name(record, domain)
  request = Request.new(path: path(domain), type: :put)
  request.payload = Oj.dump(record.to_hash)
  value = handle request
  DnsRecord.from_hash(value['targetObject'].first)
end
delete(domain, record) click to toggle source
# File lib/myra/actions/dns_records.rb, line 29
def self.delete(domain, record)
  r = normalize_domain_name(record, domain)
  request = Request.new(path: path(domain), type: :delete)
  keys = %w(modified id)
  request.payload = Oj.dump(r.to_hash.select { |k, _| keys.include? k })
  value = handle request
  deleted_record = DnsRecord.from_hash(value['targetObject'].first)
  deleted_record.deleted = true
  deleted_record
end
list(domain, page = 1) click to toggle source
# File lib/myra/actions/dns_records.rb, line 8
def self.list(domain, page = 1)
  values = handle Request.new(path: "#{path(domain)}/#{page}")
  values['list'].map { |record| DnsRecord.from_hash(record) }
end
update(domain, record) click to toggle source
# File lib/myra/actions/dns_records.rb, line 21
def self.update(domain, record)
  record = normalize_domain_name(record, domain)
  request = Request.new(path: path(domain), type: :post)
  request.payload = Oj.dump(record.to_hash)
  value = handle request
  DnsRecord.from_hash(value['targetObject'].first)
end