Class: CloudQuery::Request
- Inherits:
-
Object
- Object
- CloudQuery::Request
- Defined in:
- lib/cloud_query/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #request_uri(account = @account, secret = @secret) ⇒ Object
- #url(account = @account, secret = @secret) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cloud_query/request.rb', line 5 def initialize(={}) @method = [:method] || 'POST' @headers = [:headers] || {} @scheme = [:scheme] || SCHEME @host = [:host] || HOST @port = [:port] || (@scheme == 'https' ? URI::HTTPS::DEFAULT_PORT : URI::HTTP::DEFAULT_PORT) @path = [:path] || PATH @params = [:params] || {} if ['PUT', 'DELETE'].include?(@method) @params['_method'] = @method @method = 'POST' end @body = [:body] @account = [:account] @secret = [:secret] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme.
3 4 5 |
# File 'lib/cloud_query/request.rb', line 3 def scheme @scheme end |
Instance Method Details
#request_uri(account = @account, secret = @secret) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cloud_query/request.rb', line 23 def request_uri(account=@account, secret=@secret) query = query_str(signature_params(account)) 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
34 35 36 |
# File 'lib/cloud_query/request.rb', line 34 def url(account=@account, secret=@secret) base_uri.merge(request_uri(account, secret)).to_s end |