Method: PDNS::HTTP#api_version

Defined in:
lib/pdns_api/http.rb

#api_versionInteger

Get the version of the API.

Returns:

  • (Integer)

    version of the PowerDNS API.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/pdns_api/http.rb', line 57

def api_version
  # Do a request for the API endpoints
  net = Net::HTTP::Get.new('/api', @headers)
  res = http(net)

  # APIv0 does not play nice.
  return 0 unless res.is_a? Array

  # Return the highest API version.
  res.map { |a| a[:version] }.max.to_i
end