Class: AceClient::Query4
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
Attributes inherited from Base4
#body, #datetime, #headers, #region, #service
Attributes inherited from Base
#access_key_id, #endpoint, #http_method, #http_proxy, #last_response, #last_response_time, #secret_access_key, #use_ssl, #user_agent
Instance Method Summary collapse
- #action(action, params = {}) ⇒ Object
- #execute(params) ⇒ Object
- #execute_get(params) ⇒ Object
- #execute_post(params) ⇒ Object
Methods inherited from Base4
#add_authorization!, #initialize, #querystring
Methods inherited from Base
#endpoint_url, #initialize, #record_response, #set_http_proxy
Constructor Details
This class inherits a constructor from AceClient::Base4
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
3 4 5 |
# File 'lib/ace-client/query4.rb', line 3 def query @query end |
Instance Method Details
#action(action, params = {}) ⇒ Object
7 8 9 10 |
# File 'lib/ace-client/query4.rb', line 7 def action(action, params={}) params.update('Action' => action) execute(params) end |
#execute(params) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ace-client/query4.rb', line 12 def execute(params) @datetime = Time.now.utc.strftime("%Y%m%dT%H%M%SZ") if http_method == :get execute_get(params) else http_method == :post execute_post(params) end end |
#execute_get(params) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ace-client/query4.rb', line 21 def execute_get(params) @headers = {} @headers['host'] = @endpoint @params = params @params['Version'] = @version if @version @params.update( 'X-Amz-Algorithm' => 'AWS4-HMAC-SHA256', 'X-Amz-Credential' => access_key_id + '/' + credential_string(datetime), 'X-Amz-Date' => datetime, 'X-Amz-SignedHeaders' => signed_headers ) = self.class..dup [:query] = @params request = HTTParty::Request.new(Net::HTTP::Get, endpoint_url + @path, ) @query = request.send(:normalize_query, [:query]) @params.update('X-Amz-Signature' => signature(datetime)) @body = '' request = HTTParty::Request.new(Net::HTTP::Get, endpoint_url + @path, ) request.perform end |
#execute_post(params) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ace-client/query4.rb', line 46 def execute_post(params) @params = params = {} = self.class..dup [:body] = @params request = HTTParty::Request.new(Net::HTTP::Post, endpoint_url + @path, ) @body = request.send(:normalize_query, [:body]) @headers = {} [:headers] = headers request = HTTParty::Request.new(Net::HTTP::Post, endpoint_url + @path, ) request.perform end |