Class: SimpleAWS::API
- Inherits:
-
Object
- Object
- SimpleAWS::API
- Defined in:
- lib/simple_aws/api.rb
Overview
Base class for all AWS API wrappers.
See the list of AWS Endpoints for the values to use when implementing various APIs:
http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html
Direct Known Subclasses
AutoScaling, CloudFormation, CloudFront, CloudWatch, DynamoDB, EC2, ELB, ElastiCache, ElasticBeanstalk, IAM, ImportExport, MapReduce, MechanicalTurk, RDS, S3, SES, SNS, SQS, STS, SimpleDB
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.default_region(region) ⇒ Object
Specify a default region for all requests for this API.
-
.endpoint(endpoint) ⇒ Object
Define the AWS endpoint for the API being wrapped.
-
.use_https(value) ⇒ Object
Specify whether this API uses HTTPS for requests.
-
.version(version) ⇒ Object
Specify the AWS version of the API in question.
Instance Method Summary collapse
-
#initialize(access_key, secret_key, region = nil) ⇒ API
constructor
Construct a new access object for the API in question.
-
#uri ⇒ String
Get the full host name for the current API.
Constructor Details
#initialize(access_key, secret_key, region = nil) ⇒ API
Construct a new access object for the API in question.
68 69 70 71 72 73 74 75 76 |
# File 'lib/simple_aws/api.rb', line 68 def initialize(access_key, secret_key, region = nil) @access_key = access_key @secret_key = secret_key @region = region || self.class.instance_variable_get("@default_region") @endpoint = self.class.instance_variable_get("@endpoint") @use_https = self.class.instance_variable_get("@use_https") @version = self.class.instance_variable_get("@version") end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
59 60 61 |
# File 'lib/simple_aws/api.rb', line 59 def access_key @access_key end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
59 60 61 |
# File 'lib/simple_aws/api.rb', line 59 def region @region end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
59 60 61 |
# File 'lib/simple_aws/api.rb', line 59 def secret_key @secret_key end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
59 60 61 |
# File 'lib/simple_aws/api.rb', line 59 def version @version end |
Class Method Details
.default_region(region) ⇒ Object
Specify a default region for all requests for this API.
33 34 35 |
# File 'lib/simple_aws/api.rb', line 33 def default_region(region) @default_region = region end |
.endpoint(endpoint) ⇒ Object
Define the AWS endpoint for the API being wrapped.
24 25 26 |
# File 'lib/simple_aws/api.rb', line 24 def endpoint(endpoint) @endpoint = endpoint end |
.use_https(value) ⇒ Object
Specify whether this API uses HTTPS for requests. If not set, the system will use HTTP. Some API endpoints are not available under HTTP and some are only HTTP.
44 45 46 |
# File 'lib/simple_aws/api.rb', line 44 def use_https(value) @use_https = value end |
.version(version) ⇒ Object
Specify the AWS version of the API in question.
53 54 55 |
# File 'lib/simple_aws/api.rb', line 53 def version(version) @version = version end |
Instance Method Details
#uri ⇒ String
Get the full host name for the current API
83 84 85 86 87 88 89 90 91 |
# File 'lib/simple_aws/api.rb', line 83 def uri return @uri if @uri @uri = @use_https ? "https" : "http" @uri += "://#{@endpoint}" @uri += ".#{@region}" if @region @uri += ".amazonaws.com" @uri end |