class NiftycloudRestfulReadApi::NiftyCloud::Dns

Constants

VERSION

Public Class Methods

new(options) click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 145
def initialize(options)
  @access_key_id = options[:access_key_id]
  @secret_access_key = options[:secret_access_key]
end

Public Instance Methods

headers() click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 156
def headers
  {
    'x-nifty-authorization' => "NIFTY3-HTTPS NIFTYAccessKeyId=#{@access_key_id},ALgorithm=HmacSHA256,Signature=#{signature}", 
    'x-nifty-date' => @date
  }
end
signature() click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 163
def signature
  signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), @secret_access_key, @date)).strip
end
zones() click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 150
def zones
  @date = Time.now.rfc2822.gsub(/(\-|\+)\d{4}$/, 'GMT')
  response = self.class.get("/#{Dns::VERSION}/hostedzone", :headers => headers)
  [response['ListHostedZonesResponse']['HostedZones']['HostedZone']].flatten rescue []
end