Class: Cloudquery::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudquery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cloudquery.rb', line 35

def initialize(options={})
  @method = options[:method] || 'POST'
  @headers = options[:headers] || {}
  @scheme = options[:scheme] || SCHEME
  @host = options[:host] || HOST
  @port = options[:port] || (@scheme == 'https' ? URI::HTTPS::DEFAULT_PORT : URI::HTTP::DEFAULT_PORT)
  @path = options[:path] || PATH
  @params = options[:params] || {}
  if ['PUT', 'DELETE'].include?(@method)
    @params['_method'] = @method
    @method = 'POST'
  end
  @body = options[:body]
  
  @account = options[:account]
  @secret = options[:secret]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



33
34
35
# File 'lib/cloudquery.rb', line 33

def body
  @body
end

#headersObject

Returns the value of attribute headers.



33
34
35
# File 'lib/cloudquery.rb', line 33

def headers
  @headers
end

#hostObject

Returns the value of attribute host.



33
34
35
# File 'lib/cloudquery.rb', line 33

def host
  @host
end

#methodObject

Returns the value of attribute method.



33
34
35
# File 'lib/cloudquery.rb', line 33

def method
  @method
end

#paramsObject

Returns the value of attribute params.



33
34
35
# File 'lib/cloudquery.rb', line 33

def params
  @params
end

#pathObject

Returns the value of attribute path.



33
34
35
# File 'lib/cloudquery.rb', line 33

def path
  @path
end

#portObject

Returns the value of attribute port.



33
34
35
# File 'lib/cloudquery.rb', line 33

def port
  @port
end

#schemeObject

Returns the value of attribute scheme.



33
34
35
# File 'lib/cloudquery.rb', line 33

def scheme
  @scheme
end

Instance Method Details

#request_uri(account = @account, secret = @secret) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/cloudquery.rb', line 53

def request_uri(=@account, secret=@secret)
  query = query_str(signature_params())
  uri = if query.empty?
    @path.dup
  else
    "#{@path}?#{query}"
  end
  uri = append_signature(uri, secret) if secret
  uri
end

#url(account = @account, secret = @secret) ⇒ Object



64
65
66
# File 'lib/cloudquery.rb', line 64

def url(=@account, secret=@secret)
  base_uri.merge(request_uri(, secret)).to_s
end