Class: ProxyAPI::DNS

Inherits:
Resource show all
Defined in:
lib/proxy_api/dns.rb

Instance Attribute Summary

Attributes inherited from Resource

#url

Instance Method Summary collapse

Methods included from Foreman::TelemetryHelper

#telemetry_duration_histogram, #telemetry_increment_counter, #telemetry_observe_histogram, #telemetry_set_gauge

Constructor Details

#initialize(args) ⇒ DNS

Returns a new instance of DNS.


3
4
5
6
# File 'lib/proxy_api/dns.rb', line 3

def initialize(args)
  @url = args[:url] + "/dns"
  super args
end

Instance Method Details

#delete(key) ⇒ Object

Deletes a DNS entry

key

: String containing either a FQDN or a dotted quad plus .in-addr.arpa.

Returns : Boolean status


21
22
23
24
25
26
27
28
# File 'lib/proxy_api/dns.rb', line 21

def delete(key)
  parse(super(key.to_s))
rescue RestClient::ResourceNotFound
  # entry doesn't exists anyway
  true
rescue => e
  raise ProxyException.new(url, e, N_("Unable to delete DNS entry"))
end

#set(args) ⇒ Object

Sets a DNS entry

fqdn

: String containing the FQDN of the host

args

: Hash containing :value and :type: The :fqdn key is taken from the fqdn parameter

Returns : Boolean status


12
13
14
15
16
# File 'lib/proxy_api/dns.rb', line 12

def set(args)
  parse post(args, "")
rescue => e
  raise ProxyException.new(url, e, N_("Unable to set DNS entry"))
end