simple_aws 0.0.1a → 0.0.1b
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +115 -38
- data/lib/aws/auto_scaling.rb +24 -0
- data/lib/aws/call_types/action_param.rb +10 -35
- data/lib/aws/cloud_formation.rb +25 -0
- data/lib/aws/cloud_watch.rb +25 -0
- data/lib/aws/core/connection.rb +2 -1
- data/lib/aws/core/request.rb +16 -7
- data/lib/aws/core/util.rb +2 -0
- data/lib/aws/ec2.rb +2 -0
- data/lib/aws/elasti_cache.rb +25 -0
- data/lib/aws/elastic_beanstalk.rb +25 -0
- data/lib/aws/elb.rb +2 -0
- data/lib/aws/iam.rb +2 -0
- data/lib/aws/import_export.rb +28 -0
- data/lib/aws/map_reduce.rb +24 -0
- data/lib/aws/mechanical_turk.rb +57 -0
- data/lib/aws/rds.rb +24 -0
- data/lib/aws/ses.rb +29 -0
- data/lib/aws/signing/version2.rb +49 -0
- data/lib/aws/signing/version3.rb +38 -0
- data/lib/aws/sns.rb +25 -0
- data/lib/aws/sqs.rb +56 -0
- data/samples/sqs.rb +35 -0
- data/samples/turk.rb +14 -0
- data/simple_aws.gemspec +1 -1
- data/test/aws/auto_scaling_test.rb +36 -0
- data/test/aws/call_types/action_param_test.rb +6 -13
- data/test/aws/cloud_formation_test.rb +36 -0
- data/test/aws/cloud_watch_test.rb +36 -0
- data/test/aws/core/connection_test.rb +12 -0
- data/test/aws/core/request_test.rb +15 -3
- data/test/aws/ec2_test.rb +1 -1
- data/test/aws/elasti_cache_test.rb +36 -0
- data/test/aws/elastic_beanstalk_test.rb +36 -0
- data/test/aws/elb_test.rb +1 -1
- data/test/aws/iam_test.rb +1 -1
- data/test/aws/import_export_test.rb +42 -0
- data/test/aws/map_reduce_test.rb +36 -0
- data/test/aws/mechanical_turk_test.rb +44 -0
- data/test/aws/rds_test.rb +36 -0
- data/test/aws/ses.rb +42 -0
- data/test/aws/signing/version2_test.rb +37 -0
- data/test/aws/signing/version3.rb +40 -0
- data/test/aws/sns_test.rb +36 -0
- data/test/aws/sqs.rb +54 -0
- metadata +50 -6
data/README.md
CHANGED
@@ -1,64 +1,141 @@
|
|
1
1
|
SimpleAWS
|
2
2
|
=========
|
3
3
|
|
4
|
-
A thin, simple, forward compatible Ruby wrapper around the various Amazon AWS API.
|
4
|
+
A thin, simple, forward compatible Ruby wrapper around the various Amazon AWS APIs. Unless otherwise mentioned below, this library will wrap every API available service listed on this page: http://aws.amazon.com/documentation/
|
5
5
|
|
6
|
-
What
|
6
|
+
What?! Why?
|
7
7
|
-----------
|
8
8
|
|
9
|
-
|
10
|
-
or aws or aws-sdk or right_aws or any of the myriad of others already in existence?
|
11
|
-
Why are you creating yet another one?
|
9
|
+
Do we really need another Ruby library to talk to Amazon Web Services? Aren't there enough libraries out there that could just use some more help to make them better? What about [fog](http://fog.io), or [aws-sdk](http://rubygems.org/gems/aws-sdk), or [aws](http://rubygems.org/gems/aws), or [right_aws](http://rubygems.org/gems/right_aws)?
|
12
10
|
|
13
|
-
|
11
|
+
While there are a number of well used libraries, I feel they have all fallen prey to the same two problems, problems that SimpleAWS will not have: complexity and forward incompatibility.
|
14
12
|
|
15
13
|
### Complexity
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
and
|
20
|
-
|
21
|
-
|
22
|
-
run into the other problem these libraries have.
|
15
|
+
Every Ruby AWS library in use today is simply too complex. Every library I've tried to use has ended up hurting my productivity as I often have to dive into the code to find out what the parameter list is, what object I need to work with, or what hash keys map to the actual AWS API parameters. Every library that tries to build an Object Abstraction wrapper on top of AWS's APIs suffers from leaky abstractions, which results in yet more time lost trying to figure out what needs to be called, with what, and what gets returned. Software is supposed to be simple, it's supposed to make your life easier as a developer. I've yet to find an AWS library that does this.
|
16
|
+
|
17
|
+
The name SimpleAWS isn't a wish or hope, it's the core philosophy. This library focuses on being a very thin communication layer between your Ruby code and Amazon's AWS APIs. Let SimpleAWS handle the messy communication details so your code can do what it needs to do and you can be more productive doing what you need to do. An AWS library should facilitate using AWS, not abstract it.
|
18
|
+
|
19
|
+
It's the Unix philosophy, SimpleAWS does one thing and does it well and nothing else.
|
23
20
|
|
24
21
|
### Forward Compatibility
|
25
22
|
|
26
|
-
|
27
|
-
any changes AWS makes to it's various APIs. It's well known that Amazon's AWS
|
28
|
-
is constantly changing, constantly being updated and added to. Unfortunately, there isn't
|
29
|
-
a library out there that lives this truth. Either parameters are hard coded, or response
|
30
|
-
values are hard coded, and for all of them the requests themselves are hard built into
|
31
|
-
the libraries, making it very hard to work with new API requests.
|
23
|
+
Ignoring the complexity argument above, what finally drove me to create this library is the complete lack of forward compatibility in all existing Ruby AWS libraries. Any time I wanted to use a new parameter, new action, or new API, I would need to jump into the library itself and implement the missing pieces. In general, this doesn't sound that bad, and in many cases expected, but not for an API wrapper library.
|
32
24
|
|
33
|
-
|
34
|
-
get in your way. AWS's API is extremely well documented, consistent, and clean. The libraries
|
35
|
-
we use to interact with the API should match these truths as well.
|
25
|
+
Amazon constantly updates AWS APIs, adding parameters and actions, and at times entire new APIs. An AWS library should work *with* the API in question not fight against it. The only thing a hard-coded parameter list to a method does is add confusion and more mental disconnects. SimpleAWS simply says no, it won't force anything on the user. Use the names of the API params and them alone. If a new parameter is added to the API you're using, just use it, SimpleAWS doesn't care, it will just work.
|
36
26
|
|
37
|
-
|
38
|
-
|
27
|
+
SimpleAWS is the first and (from what I've found) only Ruby AWS library that is forward compatible with nigh any change Amazon could make to their APIs.
|
28
|
+
|
29
|
+
Surely SimpleAWS isn't just `curl`?
|
30
|
+
-----------------------------------
|
31
|
+
|
32
|
+
It's well know that AWS has its share of warts and wtfs. SimpleAWS doesn't try to fix these, as that's the path towards being yet another over-complicated and rigid library that SimpleAWS is trying to solve.
|
39
33
|
|
40
|
-
|
34
|
+
What SimpleAWS does do is add some logic to ensure it follows the Principle of Least Surprise.
|
35
|
+
|
36
|
+
### Calling
|
37
|
+
|
38
|
+
First of all, calling actions are implemented as ruby methods, handled through method_missing. You can call the AWS actions by AWSName or by ruby_name, they both work:
|
41
39
|
|
42
40
|
```ruby
|
43
|
-
ec2 = AWS::EC2.new
|
44
|
-
|
41
|
+
ec2 = AWS::EC2.new key, secret
|
42
|
+
ec2.describe_instances
|
45
43
|
```
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
or
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
ec2 = AWS::EC2.new key, secret
|
49
|
+
ec2.DescribeInstances
|
50
|
+
```
|
51
|
+
|
52
|
+
### Parameters
|
53
|
+
|
54
|
+
With that in mind, here's what SimpleAWS allows. The following three are equivalent:
|
55
|
+
|
56
|
+
#### Just Call It
|
57
|
+
|
58
|
+
You can't get simpler than just using the names of the parameters as defined in the AWS docs:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
ec2 = AWS::EC2.new key, secret
|
62
|
+
ec2.describe_instances({
|
63
|
+
"Filter.1.Name" => "instance-state-name",
|
64
|
+
"Filter.1.Value.1" => "running"
|
65
|
+
"Filter.1.Value.2" => "pending"
|
66
|
+
})
|
67
|
+
```
|
68
|
+
|
69
|
+
#### Use Ruby Arrays
|
70
|
+
|
71
|
+
Ruby Arrays will automatically be built into the "Key.n" format you see in the AWS docs:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
ec2 = AWS::EC2.new key, secret
|
75
|
+
ec2.describe_instances({
|
76
|
+
"Filter.1.Name" => "instance-state-name",
|
77
|
+
"Filter.1.Value" => ["running", "pending"]
|
78
|
+
})
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Use Ruby Hashes even!
|
82
|
+
|
83
|
+
You can take this the next step and use a Ruby Hash to make this even cleaner:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
ec2 = AWS::EC2.new key, secret
|
87
|
+
ec2.describe_instances({
|
88
|
+
"Filter" => [
|
89
|
+
{"Name" => "instance-state-name", "Value" => ["running", "pending"]}
|
90
|
+
]
|
91
|
+
})
|
92
|
+
```
|
93
|
+
|
94
|
+
### Response Parsing
|
95
|
+
|
96
|
+
All requests return an AWS::Response which does a few cleanup tasks on the resulting XML to make it easier to query and to hide some of the worst warts an XML body tends to have.
|
97
|
+
|
98
|
+
First of all, whereever AWS returns a list of items, they almost always get wrapped up in an <item> or <member> wrapper tag. Response gets rid of those tags and gives you a flat array to work with.
|
99
|
+
|
100
|
+
Second, the resulting XML can have one or two wrapper objects that do nothing but encapsulate the information you're interested in. Response also jumps past these wrapper objects so you have direct access to the data in the response.
|
101
|
+
|
102
|
+
All response objects are infinitely deep queryable via methods or Hash access. See the samples, tests, and AWS::Response for more details and examples of usage. At all times you can easily inspect the current Response object for the entire response body, or just the rest of the body at the current depth level.
|
103
|
+
|
104
|
+
Implemented APIs
|
105
|
+
----------------
|
106
|
+
|
107
|
+
These are the following Amazon APIs that SimpleAWS currently handles:
|
108
|
+
|
109
|
+
* EC2
|
110
|
+
* ELB
|
111
|
+
* IAM
|
112
|
+
* MapReduce
|
113
|
+
* Auto Scaling
|
114
|
+
* RDS
|
115
|
+
* ElastiCache
|
116
|
+
* Elastic Beanstalk
|
117
|
+
* CloudFormation
|
118
|
+
* SNS
|
119
|
+
* CloudWatch
|
120
|
+
* Import / Export
|
121
|
+
* Mechanical Turk
|
122
|
+
* SQS (Simple Queue Service)
|
123
|
+
* SES (Simple Email Service)
|
124
|
+
|
125
|
+
Yet to be Implemented
|
126
|
+
---------------------
|
127
|
+
|
128
|
+
* S3
|
129
|
+
* CloudFront
|
50
130
|
|
51
|
-
|
52
|
-
|
53
|
-
API says you get.
|
131
|
+
Currently Out-Of-Scope
|
132
|
+
----------------------
|
54
133
|
|
55
|
-
|
56
|
-
if you want to use it, some of the odd parameter systems AWS uses (PublicIp.n and the like).
|
57
|
-
On top of this, SimpleAWS works to ensure everything possible is as Ruby as possible. Methods
|
58
|
-
are underscore, the Response object can be queried using methods or a hash structure, and
|
59
|
-
parameter keys are converted to CamelCase strings as needed.
|
134
|
+
The following API endpoints will not currently be handled in SimpleAWS. These libraries are much more complicated than just a query-and-response API and are related to systems that will most likely need a lot more work than SimpleAWS wants to give. That said if you need these APIs implemented in this library, open an Issue or a Pull Request and we'll work from there.
|
60
135
|
|
61
|
-
|
136
|
+
* FWS (Fulfillment Web Service)
|
137
|
+
* FPS & ASP (Flexible Payments Service)
|
138
|
+
* Route53
|
62
139
|
|
63
140
|
Project Info
|
64
141
|
------------
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon Auto Scaling
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AutoScaling/latest/APIReference/Welcome.html
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class AutoScaling < API
|
16
|
+
endpoint "autoscaling"
|
17
|
+
use_https true
|
18
|
+
version "2011-01-01"
|
19
|
+
|
20
|
+
include CallTypes::ActionParam
|
21
|
+
include Signing::Version2
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -7,7 +7,7 @@ module AWS
|
|
7
7
|
|
8
8
|
##
|
9
9
|
# Implement call handling to work with the ?Action param, signing the message
|
10
|
-
# according to
|
10
|
+
# according to whatever Signing module is included along side this module
|
11
11
|
##
|
12
12
|
module ActionParam
|
13
13
|
##
|
@@ -19,50 +19,25 @@ module AWS
|
|
19
19
|
request.params["Action"] = AWS::Util.camelcase(name.to_s)
|
20
20
|
|
21
21
|
if args.any? && args.first.is_a?(Hash)
|
22
|
-
args.first
|
23
|
-
request.params[key] = value
|
24
|
-
end
|
22
|
+
insert_params_from request, args.first
|
25
23
|
end
|
26
24
|
|
27
|
-
|
28
|
-
connection.call finish_and_sign_request(request)
|
25
|
+
send_request request
|
29
26
|
end
|
30
27
|
|
31
28
|
protected
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
##
|
37
|
-
def finish_and_sign_request(request)
|
38
|
-
request.params.merge!({
|
39
|
-
"AWSAccessKeyId" => self.access_key,
|
40
|
-
"SignatureMethod" => "HmacSHA256",
|
41
|
-
"SignatureVersion" => "2",
|
42
|
-
"Timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
43
|
-
"Version" => self.version
|
44
|
-
})
|
45
|
-
|
46
|
-
request.params["Signature"] = Base64.encode64(sign_request(request.params.clone)).chomp
|
47
|
-
|
48
|
-
request
|
30
|
+
def send_request(request)
|
31
|
+
connection = AWS::Connection.new
|
32
|
+
connection.call finish_and_sign_request(request)
|
49
33
|
end
|
50
34
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
if a[0] == "AWSAccessKeyId"
|
55
|
-
-1
|
56
|
-
else
|
57
|
-
a[0] <=> b[0]
|
58
|
-
end
|
35
|
+
def insert_params_from(request, args = {})
|
36
|
+
args.each do |key, value|
|
37
|
+
request.params[key] = value
|
59
38
|
end
|
60
|
-
|
61
|
-
host = self.uri.gsub(/^http[s]:\/\//,'')
|
62
|
-
|
63
|
-
to_sign = "POST\n#{host}\n/\n#{list.map {|p| p.join("=") }.join("&")}"
|
64
|
-
OpenSSL::HMAC.digest("sha256", self.secret_key, to_sign)
|
65
39
|
end
|
40
|
+
|
66
41
|
end
|
67
42
|
end
|
68
43
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's CloudFormation
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class CloudFormation < API
|
16
|
+
endpoint "cloudformation"
|
17
|
+
use_https true
|
18
|
+
version "2010-05-15"
|
19
|
+
default_region "us-east-1"
|
20
|
+
|
21
|
+
include CallTypes::ActionParam
|
22
|
+
include Signing::Version2
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Cloud Watch
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/Welcome.html
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class CloudWatch < API
|
16
|
+
endpoint "monitoring"
|
17
|
+
use_https true
|
18
|
+
version "2010-08-01"
|
19
|
+
default_region "us-east-1"
|
20
|
+
|
21
|
+
include CallTypes::ActionParam
|
22
|
+
include Signing::Version2
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/aws/core/connection.rb
CHANGED
data/lib/aws/core/request.rb
CHANGED
@@ -35,11 +35,6 @@ module AWS
|
|
35
35
|
# {"Name" => "ids", "Value" => ["i-1234", "i-8902"]}
|
36
36
|
# ]
|
37
37
|
#
|
38
|
-
# If you have just a single Filter, you don't need to wrap it in an array,
|
39
|
-
# Request will do that for you:
|
40
|
-
#
|
41
|
-
# request.params["Filter"] = {"Name" => "domain", "Value" => "vpc"}
|
42
|
-
#
|
43
38
|
# Straight arrays are handled as well:
|
44
39
|
#
|
45
40
|
# request.params["InstanceId"] = ["i-1234", "i-8970"]
|
@@ -61,7 +56,7 @@ module AWS
|
|
61
56
|
when Array
|
62
57
|
process_array key, value
|
63
58
|
when Hash
|
64
|
-
|
59
|
+
process_hash key, value
|
65
60
|
else
|
66
61
|
super
|
67
62
|
end
|
@@ -111,6 +106,11 @@ module AWS
|
|
111
106
|
##
|
112
107
|
attr_reader :params
|
113
108
|
|
109
|
+
##
|
110
|
+
# Hash of headers to send with the request
|
111
|
+
##
|
112
|
+
attr_reader :headers
|
113
|
+
|
114
114
|
##
|
115
115
|
# Set up a new Request for the given +host+ and +path+ using the given
|
116
116
|
# http +method+ (:get, :post, :put, :delete).
|
@@ -118,8 +118,9 @@ module AWS
|
|
118
118
|
def initialize(method, host, path)
|
119
119
|
@method = method
|
120
120
|
@host = host
|
121
|
-
|
121
|
+
self.path = path
|
122
122
|
@params = Params.new
|
123
|
+
@headers = {}
|
123
124
|
end
|
124
125
|
|
125
126
|
##
|
@@ -129,5 +130,13 @@ module AWS
|
|
129
130
|
"#{host}#{path}"
|
130
131
|
end
|
131
132
|
|
133
|
+
##
|
134
|
+
# Set path, makes sure that the path is never
|
135
|
+
# nil or an empty string
|
136
|
+
##
|
137
|
+
def path=(value)
|
138
|
+
@path = (value.nil? || value == "") ? "/" : value
|
139
|
+
end
|
140
|
+
|
132
141
|
end
|
133
142
|
end
|
data/lib/aws/core/util.rb
CHANGED
data/lib/aws/ec2.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's ElastiCache
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AmazonElastiCache/latest/APIReference/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class ElastiCache < API
|
16
|
+
endpoint "elasticache"
|
17
|
+
use_https true
|
18
|
+
version "2011-07-15"
|
19
|
+
default_region "us-east-1"
|
20
|
+
|
21
|
+
include CallTypes::ActionParam
|
22
|
+
include Signing::Version2
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Elastic Beanstalk
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/elasticbeanstalk/latest/api/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class ElasticBeanstalk < API
|
16
|
+
endpoint "elasticbeanstalk"
|
17
|
+
use_https true
|
18
|
+
version "2010-12-01"
|
19
|
+
default_region "us-east-1"
|
20
|
+
|
21
|
+
include CallTypes::ActionParam
|
22
|
+
include Signing::Version2
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/aws/elb.rb
CHANGED
data/lib/aws/iam.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Import / Export
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AWSImportExport/latest/API/Welcome.html
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS.
|
13
|
+
# This API does not support region specifiers
|
14
|
+
##
|
15
|
+
class ImportExport < API
|
16
|
+
endpoint "importexport"
|
17
|
+
use_https true
|
18
|
+
version "2010-06-03"
|
19
|
+
|
20
|
+
def initialize(key, secret)
|
21
|
+
super(key, secret)
|
22
|
+
end
|
23
|
+
|
24
|
+
include CallTypes::ActionParam
|
25
|
+
include Signing::Version2
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Elastic MapReduce
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/ElasticMapReduce/latest/API/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class MapReduce < API
|
16
|
+
endpoint "elasticmapreduce"
|
17
|
+
use_https true
|
18
|
+
version "2009-03-31"
|
19
|
+
|
20
|
+
include CallTypes::ActionParam
|
21
|
+
include Signing::Version2
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
|
4
|
+
module AWS
|
5
|
+
|
6
|
+
##
|
7
|
+
# Amazon's Mechanical Turk
|
8
|
+
#
|
9
|
+
# http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html
|
10
|
+
#
|
11
|
+
# All requests are POST and always through HTTPS.
|
12
|
+
# Instead of regions, this API supports normal and sandbox mode. Use the third
|
13
|
+
# parameter of #initialize to specify sandbox mode.
|
14
|
+
#
|
15
|
+
# For a more fleshed out object API for interacting with MechanicalTurk, you should
|
16
|
+
# give rturk a try here: https://github.com/mdp/rturk
|
17
|
+
##
|
18
|
+
class MechanicalTurk < API
|
19
|
+
endpoint "mechanicalturk"
|
20
|
+
use_https true
|
21
|
+
version "2011-10-01"
|
22
|
+
|
23
|
+
def initialize(key, secret, sandbox = false)
|
24
|
+
super(key, secret, sandbox ? "sandbox" : nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
include CallTypes::ActionParam
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
# Sign the Turk request according to SignatureVersion 0 rules.
|
32
|
+
#
|
33
|
+
# As this is coming from CallTypes::ActionParam we need to fix
|
34
|
+
# the Action param first thing.
|
35
|
+
def finish_and_sign_request(request)
|
36
|
+
request.params["Operation"] = request.params.delete("Action")
|
37
|
+
|
38
|
+
request.params.merge!({
|
39
|
+
"Service" => "AWSMechanicalTurkRequester",
|
40
|
+
"AWSAccessKeyId" => self.access_key,
|
41
|
+
"Timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
42
|
+
"Version" => self.version
|
43
|
+
})
|
44
|
+
|
45
|
+
request.params["Signature"] = Base64.encode64(sign_request(request.params.clone)).chomp
|
46
|
+
|
47
|
+
request
|
48
|
+
end
|
49
|
+
|
50
|
+
def sign_request(params)
|
51
|
+
to_sign = [params["Service"], params["Operation"], params["Timestamp"]].join ""
|
52
|
+
OpenSSL::HMAC.digest("sha1", self.secret_key, to_sign)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/lib/aws/rds.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version2'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Relational Database Service
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
|
+
# #initialize if you need to talk to a region other than us-east-1.
|
14
|
+
##
|
15
|
+
class RDS < API
|
16
|
+
endpoint "rds"
|
17
|
+
use_https true
|
18
|
+
version "2011-04-01"
|
19
|
+
|
20
|
+
include CallTypes::ActionParam
|
21
|
+
include Signing::Version2
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/aws/ses.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'aws/api'
|
2
|
+
require 'aws/call_types/action_param'
|
3
|
+
require 'aws/signing/version3'
|
4
|
+
|
5
|
+
module AWS
|
6
|
+
|
7
|
+
##
|
8
|
+
# Amazon's Simple Email Service
|
9
|
+
#
|
10
|
+
# http://docs.amazonwebservices.com/ses/latest/APIReference/
|
11
|
+
#
|
12
|
+
# All requests are POST and always through HTTPS.
|
13
|
+
##
|
14
|
+
class SES < API
|
15
|
+
endpoint "email"
|
16
|
+
use_https true
|
17
|
+
version "2010-12-01"
|
18
|
+
default_region "us-east-1"
|
19
|
+
|
20
|
+
# SES only has one HTTP endpoint
|
21
|
+
def initialize(key, secret)
|
22
|
+
super(key, secret)
|
23
|
+
end
|
24
|
+
|
25
|
+
include CallTypes::ActionParam
|
26
|
+
include Signing::Version3
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|