Module: JokerDMAPI::Host

Included in:
Client
Defined in:
lib/joker-dmapi/host.rb

Instance Method Summary collapse

Instance Method Details

#host_create(host, fields) ⇒ Object



33
34
35
# File 'lib/joker-dmapi/host.rb', line 33

def host_create(host, fields)
  host_request :ns_create, host, fields
end

#host_info(host) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/joker-dmapi/host.rb', line 6

def host_info(host)
  response = query_no_raise :query_whois, { host: host }
  case response[:headers][:status_code]
    when '2303' then nil
    when '0' then
      result = {}
      response[:body].split("\n").each do |line|
        line.slice! /^host\./
        line_parsed = parse_line(line)
        next if line_parsed.is_a? String
        key, value = line_parsed.first
        case key
          when :fqdn then result[:host] = value
          when :ip_address then result[:ipv4] = value
          when :ip_address_v6 then result[:ipv6] = value
          when :created_date, :modified_date then
            result[key] = DateTime.parse value
          else
            result.merge! line_parsed
        end
      end
      result
    else
      raise_response response
  end
end

#host_update(host, fields) ⇒ Object



37
38
39
# File 'lib/joker-dmapi/host.rb', line 37

def host_update(host, fields)
  host_request :ns_modify, host, fields
end