elasticity 0.0.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.mediawiki CHANGED
@@ -1,9 +1,9 @@
1
- = Elasticity =
2
-
3
1
  Elasticity provides programmatic access to Amazon's Elastic Map Reduce service.
4
2
 
5
3
  There are five API actions in the [http://docs.amazonwebservices.com/ElasticMapReduce/latest/DeveloperGuide/index.html EMR API], described below. Please see the Amazon guide for details on these operations because the default values aren't obvious (e.g. the meaning of DescribeJobFlows without parameters).
6
4
 
5
+ Alternatively, you may opt for "direct" access to the API where you specify the params and Elasticity takes care of the signing for you. Direct access is described below the API catalog.
6
+
7
7
  '''NOTE''': The AWS plumbing (especially signing/authentication) was used from [http://www.rightscale.com/ RightScale's] amazing [https://github.com/rightscale/right_aws right_aws gem] which works extraordinarily well!
8
8
 
9
9
  == AddInstanceGroups ==
@@ -49,5 +49,16 @@ When the job flow '''doesn't exist''':
49
49
  ArgumentError: Job flow 'no-flow' does not exist.
50
50
  </pre>
51
51
 
52
+ = Direct Access =
53
+
54
+ If you're chomping at the bit to get at some EMR functionality that isn't wrapped (or isn't wrapped in a way you prefer :) feel free to access the AWS EMR API directly by using <code>EMR.direct()</code>. You can find the allowed values in Amazon's EMR API [http://docs.amazonwebservices.com/ElasticMapReduce/latest/DeveloperGuide/index.html developer documentation].
55
+
56
+ <pre>
57
+ > emr = Elasticity::EMR.new(ENV["aws_access_key_id"], ENV["aws_secret_key"])
58
+ > params = {"Operation" => "DescribeJobFlows"}
59
+ > result_xml = emr.direct(params)
60
+ > result_xml[0..42]
61
+ <DescribeJobFlowsResponse xmlns=\"http://ela"
62
+ </pre>
52
63
 
53
64
  <!-- __NOTOC__ -->
data/lib/elasticity.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'base64'
2
+
1
3
  require 'rest_client'
2
4
  require 'nokogiri'
3
5
 
@@ -1,5 +1,3 @@
1
- require "base64"
2
-
3
1
  module Elasticity
4
2
 
5
3
  class EMR
@@ -31,5 +29,13 @@ module Elasticity
31
29
  end
32
30
  end
33
31
 
32
+ # Pass the specified params hash directly through to the AWS request
33
+ # URL. Use this if you want to perform an operation that hasn't yet
34
+ # been wrapped by Elasticity or you just want to see the response
35
+ # XML for yourself :)
36
+ def direct(params)
37
+ @aws_request.aws_emr_request(params)
38
+ end
39
+
34
40
  end
35
41
  end
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = "0.0.1"
2
+ VERSION = "0.3"
3
3
  end
@@ -0,0 +1,32 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: !ruby/regexp /^http:\/\/elasticmapreduce.amazonaws.com:80\/\?AWSAccessKeyId=AKIAI7HEMMNKGT6VFFSA&JobFlowIds.member.1=j-1MZ5TVWFJRSKN&Operation=TerminateJobFlows/
6
+ body:
7
+ headers:
8
+ accept:
9
+ - "*/*; q=0.5, application/xml"
10
+ accept-encoding:
11
+ - gzip, deflate
12
+ response: !ruby/struct:VCR::Response
13
+ status: !ruby/struct:VCR::ResponseStatus
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ x-amzn-requestid:
18
+ - 54a92156-63dc-11e0-a11b-4b625b21bf04
19
+ content-type:
20
+ - text/xml
21
+ date:
22
+ - Mon, 11 Apr 2011 01:37:58 GMT
23
+ content-length:
24
+ - "225"
25
+ body: |
26
+ <TerminateJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
27
+ <ResponseMetadata>
28
+ <RequestId>54a92156-63dc-11e0-a11b-4b625b21bf04</RequestId>
29
+ </ResponseMetadata>
30
+ </TerminateJobFlowsResponse>
31
+
32
+ http_version: "1.1"
@@ -103,4 +103,45 @@ describe Elasticity::EMR do
103
103
  end
104
104
  end
105
105
 
106
+ describe "#direct" do
107
+
108
+ describe "integration happy path" do
109
+ use_vcr_cassette "direct/terminate_jobflow", :record => :none
110
+ it "should terminate the specified jobflow" do
111
+ emr = Elasticity::EMR.new(ENV["aws_access_key_id"], ENV["aws_secret_key"])
112
+ params = {
113
+ "Operation" => "TerminateJobFlows",
114
+ "JobFlowIds.member.1" => "j-1MZ5TVWFJRSKN"
115
+ }
116
+ emr.direct(params)
117
+ end
118
+ end
119
+
120
+ describe "unit tests" do
121
+ before do
122
+ @terminate_jobflows_xml = <<-RESPONSE
123
+ <TerminateJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
124
+ <ResponseMetadata>
125
+ <RequestId>2690d7eb-ed86-11dd-9877-6fad448a8419</RequestId>
126
+ </ResponseMetadata>
127
+ </TerminateJobFlowsResponse>
128
+ RESPONSE
129
+ end
130
+ it "should pass through directly to the request" do
131
+ aws_request = Elasticity::AwsRequest.new("aws_access_key_id", "aws_secret_key")
132
+ aws_request.should_receive(:aws_emr_request).with({
133
+ "Operation" => "TerminateJobFlows",
134
+ "JobFlowIds.member.1" => "j-1"
135
+ }).and_return(@terminate_jobflows_xml)
136
+ Elasticity::AwsRequest.should_receive(:new).and_return(aws_request)
137
+ emr = Elasticity::EMR.new("aws_access_key_id", "aws_secret_key")
138
+ params = {
139
+ "Operation" => "TerminateJobFlows",
140
+ "JobFlowIds.member.1" => "j-1"
141
+ }
142
+ emr.direct(params).should == @terminate_jobflows_xml
143
+ end
144
+ end
145
+ end
146
+
106
147
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticity
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
8
+ - 3
9
+ version: "0.3"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Robert Slifka
@@ -130,6 +129,7 @@ files:
130
129
  - lib/elasticity/job_flow.rb
131
130
  - lib/elasticity/version.rb
132
131
  - spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml
132
+ - spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml
133
133
  - spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml
134
134
  - spec/lib/elasticity/aws_request_spec.rb
135
135
  - spec/lib/elasticity/emr_spec.rb
@@ -171,6 +171,7 @@ specification_version: 3
171
171
  summary: Programmatic access to Amazon's Elastic Map Reduce service.
172
172
  test_files:
173
173
  - spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml
174
+ - spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml
174
175
  - spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml
175
176
  - spec/lib/elasticity/aws_request_spec.rb
176
177
  - spec/lib/elasticity/emr_spec.rb