Class: RightScale::CloudApi::AWS::ApiManager
- Inherits:
-
CloudApi::ApiManager
- Object
- CloudApi::ApiManager
- RightScale::CloudApi::AWS::ApiManager
- Includes:
- Mixin::QueryApiPatterns
- Defined in:
- lib/cloud/aws/base/manager.rb
Overview
Thread un-safe parent class for almost all the AWS services.
Direct Known Subclasses
RightScale::CloudApi::AWS::AS::ApiManager, CFM::ApiManager, CW::ApiManager, EB::ApiManager, EC2::ApiManager, EC::ApiManager, ELB::ApiManager, EMR::ApiManager, IAM::ApiManager, RDS::ApiManager, SDB::ApiManager, SNS::ApiManager, ECS::PA::ApiManager, MWS::ApiManager
Defined Under Namespace
Classes: Error
Constant Summary collapse
- COMMON_QUERY_PARAMS =
A list of common AWS API params
[ 'Action', 'AWSAccessKeyId', 'Expires', 'SecurityToken', 'Signature', 'SignatureMethod', 'SignatureVersion', 'Timestamp', 'Version', ]
Instance Method Summary collapse
-
#api(action, params = {}, &block) ⇒ Object
Makes a raw API call to AWS compatible service by the method name.
-
#initialize(aws_access_key_id, aws_secret_access_key, endpoint, options = {}) ⇒ ApiManager
constructor
abstract
Constructor.
-
#method_missing(method_name, *args, &block) ⇒ Object
Provides an ability to call methods by their API action names.
-
#parametrize(*args) ⇒ Hash
(also: #p9e)
Parametrize data to the format that Amazon EC2 and compatible services accept.
Constructor Details
#initialize(aws_access_key_id, aws_secret_access_key, endpoint, options = {}) ⇒ ApiManager
Constructor
87 88 89 90 91 |
# File 'lib/cloud/aws/base/manager.rb', line 87 def initialize(aws_access_key_id, aws_secret_access_key, endpoint, ={}) credentials = { :aws_access_key_id => aws_access_key_id, :aws_secret_access_key => aws_secret_access_key } super(credentials, endpoint, ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Provides an ability to call methods by their API action names
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/cloud/aws/base/manager.rb', line 172 def method_missing(method_name, *args, &block) begin invoke_query_api_pattern_method(method_name, *args, &block) rescue PatternNotFoundError if method_name.to_s[/\A[A-Z]/] api(method_name, *args, &block) else super end end end |
Instance Method Details
#api(action, params = {}, &block) ⇒ Object
Makes a raw API call to AWS compatible service by the method name
112 113 114 115 116 117 118 119 120 |
# File 'lib/cloud/aws/base/manager.rb', line 112 def api(action, params={}, &block) params['Action'] ||= action.to_s._snake_case._camelize opts = {} opts[:body] = params.delete(:body) opts[:headers] = params.delete(:headers) || {} opts[:options] = params.delete(:options) || {} opts[:params] = parametrize(params) process_api_request(:post, '', opts, &block) end |
#parametrize(*args) ⇒ Hash Also known as: p9e
Parametrize data to the format that Amazon EC2 and compatible services accept
See Utils::AWS.parametrize for more examples.
149 150 151 |
# File 'lib/cloud/aws/base/manager.rb', line 149 def parametrize(*args) Utils::AWS.parametrize(*args) end |