Class: Nifcloud::Client

Inherits:
Auth
  • Object
show all
Defined in:
lib/nifcloud/client.rb

Overview

Client for nifcloud dns

Direct Known Subclasses

DNS::Record, DNS::Zone

Constant Summary collapse

ENDPOINT =
'https://dns.api.nifcloud.com/'
VERSION =
'2012-12-12N2013-12-16'
AUTHORIZATION_HEADER =
'X-Nifty-Authorization'
DATE_HEADER =
'X-Nifty-Date'
NAMESPACE =
'https://route53.amazonaws.com/doc/2012-12-12/'

Constants inherited from Auth

Auth::ALGORITHM

Instance Attribute Summary

Attributes inherited from Auth

#time

Instance Method Summary collapse

Methods inherited from Auth

#signature_header

Constructor Details

#initialize(access_key, secret_key) ⇒ Client

Returns a new instance of Client.



16
17
18
19
# File 'lib/nifcloud/client.rb', line 16

def initialize(access_key, secret_key)
  super(access_key, secret_key)
  @http, @req, @uri = nil
end

Instance Method Details

#delete(path) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/nifcloud/client.rb', line 39

def delete(path)
  init path
  @req = Net::HTTP::Delete.new @uri.request_uri
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end

#get(path) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/nifcloud/client.rb', line 21

def get(path)
  init path
  @req = Net::HTTP::Get.new @uri.request_uri
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end

#post(path, body) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/nifcloud/client.rb', line 29

def post(path, body)
  init path
  @req = Net::HTTP::Post.new @uri.request_uri
  @req.body = body
  @req.content_type = 'text/xml'
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end