aws-sdk 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ca-bundle.crt +54 -444
- data/lib/aws/api_config/EC2-2012-06-01.yml +52 -13
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +53 -0
- data/lib/aws/auto_scaling/request.rb +7 -1
- data/lib/aws/cloud_formation/stack_options.rb +3 -3
- data/lib/aws/core.rb +30 -9
- data/lib/aws/core/client.rb +7 -2
- data/lib/aws/core/configuration.rb +65 -36
- data/lib/aws/core/http/httparty_handler.rb +5 -4
- data/lib/aws/core/http/net_http_handler.rb +30 -14
- data/lib/aws/core/http/request.rb +10 -2
- data/lib/aws/core/inflection.rb +15 -12
- data/lib/aws/core/log_formatter.rb +6 -0
- data/lib/aws/core/resource.rb +7 -3
- data/lib/aws/core/service_interface.rb +3 -3
- data/lib/aws/ec2.rb +7 -0
- data/lib/aws/ec2/client.rb +80 -1
- data/lib/aws/ec2/export_task.rb +120 -0
- data/lib/aws/ec2/export_task_collection.rb +67 -0
- data/lib/aws/ec2/instance.rb +81 -0
- data/lib/aws/ec2/region.rb +1 -0
- data/lib/aws/record/model.rb +1 -1
- data/lib/aws/s3.rb +1 -0
- data/lib/aws/s3/access_control_list.rb +12 -5
- data/lib/aws/s3/acl_options.rb +204 -0
- data/lib/aws/s3/bucket.rb +6 -11
- data/lib/aws/s3/bucket_collection.rb +21 -4
- data/lib/aws/s3/client.rb +280 -96
- data/lib/aws/s3/request.rb +0 -8
- data/lib/aws/s3/s3_object.rb +23 -13
- data/lib/aws/simple_email_service/client.rb +76 -11
- data/lib/aws/simple_email_service/identity.rb +81 -4
- data/lib/net/http/connection_pool.rb +45 -23
- data/lib/net/http/connection_pool/connection.rb +3 -0
- data/lib/net/http/connection_pool/session.rb +2 -2
- metadata +6 -3
@@ -92,12 +92,13 @@ module AWS
|
|
92
92
|
|
93
93
|
begin
|
94
94
|
http_response = self.class.send(method, url, opts)
|
95
|
+
unless http_response.nil?
|
96
|
+
response.body = http_response.body
|
97
|
+
response.status = http_response.code.to_i
|
98
|
+
response.headers = http_response.to_hash
|
99
|
+
end
|
95
100
|
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
96
101
|
response.timeout = true
|
97
|
-
else
|
98
|
-
response.body = http_response.body
|
99
|
-
response.status = http_response.code.to_i
|
100
|
-
response.headers = http_response.to_hash
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
@@ -17,17 +17,28 @@ module AWS
|
|
17
17
|
module Core
|
18
18
|
module Http
|
19
19
|
|
20
|
-
#
|
21
|
-
#
|
20
|
+
# = NetHttpHandler
|
21
|
+
#
|
22
|
+
# This is the default HTTP handler for the aws-sdk gem. It uses
|
23
|
+
# Ruby's Net::HTTP to make requests. It uses persistent connections
|
24
|
+
# and a connection pool.
|
25
|
+
#
|
22
26
|
class NetHttpHandler
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def self.pool
|
28
|
-
@@pool
|
28
|
+
# (see Net::HTTP::ConnectionPool.new)
|
29
|
+
def initialize options = {}
|
30
|
+
@pool = Net::HTTP::ConnectionPool.new(options)
|
29
31
|
end
|
32
|
+
|
33
|
+
# @return [Net::HTTP::ConnectionPool]
|
34
|
+
attr_reader :pool
|
30
35
|
|
36
|
+
# Given a populated request object and an empty response object,
|
37
|
+
# this method will make the request and them populate the
|
38
|
+
# response.
|
39
|
+
# @param [Request] request
|
40
|
+
# @param [Response] response
|
41
|
+
# @return [nil]
|
31
42
|
def handle request, response
|
32
43
|
|
33
44
|
options = {}
|
@@ -38,23 +49,28 @@ module AWS
|
|
38
49
|
options[:ssl_ca_file] = request.ssl_ca_file if request.ssl_ca_file
|
39
50
|
options[:ssl_ca_path] = request.ssl_ca_path if request.ssl_ca_path
|
40
51
|
|
41
|
-
connection =
|
52
|
+
connection = pool.connection_for(request.host, options)
|
42
53
|
connection.read_timeout = request.read_timeout
|
43
54
|
|
44
55
|
begin
|
45
|
-
http_response = connection.request(
|
56
|
+
http_response = connection.request(build_net_http_request(request))
|
46
57
|
response.body = http_response.body
|
47
58
|
response.status = http_response.code.to_i
|
48
59
|
response.headers = http_response.to_hash
|
49
60
|
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
50
61
|
response.timeout = true
|
51
62
|
end
|
63
|
+
nil
|
52
64
|
|
53
65
|
end
|
54
66
|
|
55
|
-
# @private
|
56
67
|
protected
|
57
|
-
|
68
|
+
|
69
|
+
# Given an AWS::Core::HttpRequest, this method translates
|
70
|
+
# it into a Net::HTTPRequest (Get, Put, Post, Head or Delete).
|
71
|
+
# @param [Request]
|
72
|
+
# @return [Net::HTTPRequest]
|
73
|
+
def build_net_http_request request
|
58
74
|
|
59
75
|
# Net::HTTP adds a content-type header automatically unless its set
|
60
76
|
# and this messes with request signature signing. Also, it expects
|
@@ -64,16 +80,16 @@ module AWS
|
|
64
80
|
headers[key] = value.to_s
|
65
81
|
end
|
66
82
|
|
67
|
-
|
83
|
+
request_class = case request.http_method
|
68
84
|
when 'GET' then Net::HTTP::Get
|
69
85
|
when 'PUT' then Net::HTTP::Put
|
70
86
|
when 'POST' then Net::HTTP::Post
|
71
87
|
when 'HEAD' then Net::HTTP::Head
|
72
88
|
when 'DELETE' then Net::HTTP::Delete
|
73
89
|
else raise "unsupported http method: #{request.http_method}"
|
74
|
-
|
90
|
+
end
|
75
91
|
|
76
|
-
net_http_req =
|
92
|
+
net_http_req = request_class.new(request.uri, headers)
|
77
93
|
net_http_req.body = request.body
|
78
94
|
net_http_req
|
79
95
|
|
@@ -30,13 +30,13 @@ module AWS
|
|
30
30
|
@params = []
|
31
31
|
@use_ssl = true
|
32
32
|
@port = nil
|
33
|
-
@
|
33
|
+
@default_read_timeout = 60
|
34
34
|
end
|
35
35
|
|
36
36
|
# @return [Integer] The number of seconds the service has to respond
|
37
37
|
# before a timeout error is raised on the request. Defaults to
|
38
38
|
# 60 seconds.
|
39
|
-
attr_accessor :
|
39
|
+
attr_accessor :default_read_timeout
|
40
40
|
|
41
41
|
# @return [String] The snake-cased ruby name for the service
|
42
42
|
# (e.g. 's3', 'iam', 'dynamo_db', etc).
|
@@ -69,6 +69,14 @@ module AWS
|
|
69
69
|
# @return [String]
|
70
70
|
# @private
|
71
71
|
attr_accessor :access_key_id
|
72
|
+
|
73
|
+
# Some subclasses override this method to obseve requirements
|
74
|
+
# set by the services (e.q. SimpleWorlfow and SQS have special
|
75
|
+
# long-pulling requirements and require special read timeouts).
|
76
|
+
# @private
|
77
|
+
def read_timeout
|
78
|
+
default_read_timeout
|
79
|
+
end
|
72
80
|
|
73
81
|
# @param [Boolean] state If the request should be sent over ssl or not.
|
74
82
|
def use_ssl= state
|
data/lib/aws/core/inflection.rb
CHANGED
@@ -17,21 +17,24 @@ module AWS
|
|
17
17
|
# @private
|
18
18
|
module Inflection
|
19
19
|
|
20
|
-
def ruby_name
|
20
|
+
def ruby_name aws_name
|
21
21
|
|
22
|
-
|
23
|
-
# gsub(/[A-Z]+[a-z]+/){|str| "_#{str.downcase}_" }.
|
24
|
-
# gsub(/(^_|_$)/, '').
|
25
|
-
# gsub(/__/, '_').
|
26
|
-
# downcase
|
22
|
+
inflector = Hash.new do |hash,key|
|
27
23
|
|
28
|
-
|
24
|
+
key.
|
25
|
+
sub(/^.*:/, ''). # strip namespace
|
26
|
+
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms from words
|
27
|
+
scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split remaining words
|
28
|
+
join('_').downcase # join parts _ and downcase
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
# add a few irregular inflections
|
33
|
+
inflector['ETag'] = 'etag'
|
34
|
+
inflector['s3Bucket'] = 's3_bucket'
|
35
|
+
inflector['s3Key'] = 's3_key'
|
36
|
+
|
37
|
+
inflector[aws_name]
|
35
38
|
|
36
39
|
end
|
37
40
|
module_function :ruby_name
|
@@ -171,6 +171,12 @@ module AWS
|
|
171
171
|
pattern.gsub(/:(\w+)/) {|sym| send("_#{sym[1..-1]}", response) }
|
172
172
|
end
|
173
173
|
|
174
|
+
# @private
|
175
|
+
def eql? other
|
176
|
+
other.is_a?(self.class) and other.pattern == self.pattern
|
177
|
+
end
|
178
|
+
alias_method :==, :eql?
|
179
|
+
|
174
180
|
protected
|
175
181
|
|
176
182
|
def method_missing method_name, *args
|
data/lib/aws/core/resource.rb
CHANGED
@@ -390,9 +390,13 @@ module AWS
|
|
390
390
|
|
391
391
|
attr = @klass.attributes[attr_name]
|
392
392
|
|
393
|
-
|
394
|
-
|
395
|
-
v = resp_obj
|
393
|
+
methods = [options[:get_as] || attr.get_as].flatten
|
394
|
+
|
395
|
+
v = resp_obj
|
396
|
+
methods.each do |method|
|
397
|
+
v = v.key?(method) ? v[method] : v[method.to_s]
|
398
|
+
break if v.nil?
|
399
|
+
end
|
396
400
|
v = v[:value] if v and options[:value_wrapped]
|
397
401
|
v = attr.translate_output_value(v)
|
398
402
|
|
@@ -45,10 +45,10 @@ module AWS
|
|
45
45
|
# to AWS.config when not provided.
|
46
46
|
#
|
47
47
|
def initialize options = {}
|
48
|
-
|
49
|
-
@config
|
48
|
+
options = options.dup
|
49
|
+
@config = (options.delete(:config) || AWS.config)
|
50
50
|
@config = @config.with(options)
|
51
|
-
@client = config.send(Inflection.ruby_name(self.class.to_s) + '_client')
|
51
|
+
@client = @config.send(Inflection.ruby_name(self.class.to_s) + '_client')
|
52
52
|
end
|
53
53
|
|
54
54
|
# @return [String]
|
data/lib/aws/ec2.rb
CHANGED
@@ -247,6 +247,8 @@ module AWS
|
|
247
247
|
autoload :ElasticIp, 'elastic_ip'
|
248
248
|
autoload :ElasticIpCollection, 'elastic_ip_collection'
|
249
249
|
autoload :Errors, 'errors'
|
250
|
+
autoload :ExportTask, 'export_task'
|
251
|
+
autoload :ExportTaskCollection, 'export_task_collection'
|
250
252
|
autoload :FilteredCollection, 'filtered_collection'
|
251
253
|
autoload :HasPermissions, 'has_permissions'
|
252
254
|
autoload :Image, 'image'
|
@@ -427,5 +429,10 @@ module AWS
|
|
427
429
|
VPNConnectionCollection.new(:config => config)
|
428
430
|
end
|
429
431
|
|
432
|
+
# @return [ExportTaskCollection]
|
433
|
+
def export_tasks
|
434
|
+
ExportTaskCollection.new(:config => config)
|
435
|
+
end
|
436
|
+
|
430
437
|
end
|
431
438
|
end
|
data/lib/aws/ec2/client.rb
CHANGED
@@ -428,6 +428,21 @@ module AWS
|
|
428
428
|
#
|
429
429
|
define_client_method :cancel_conversion_task, 'CancelConversionTask'
|
430
430
|
|
431
|
+
# Calls the CancelExportTask API operation.
|
432
|
+
# @method cancel_export_task(options = {})
|
433
|
+
#
|
434
|
+
# === Options:
|
435
|
+
#
|
436
|
+
# * +:export_task_id+ - *required* - (String)
|
437
|
+
#
|
438
|
+
# === Response Structure:
|
439
|
+
#
|
440
|
+
# This method returns no response data.
|
441
|
+
#
|
442
|
+
# @return [Core::Response]
|
443
|
+
#
|
444
|
+
define_client_method :cancel_export_task, 'CancelExportTask'
|
445
|
+
|
431
446
|
# Calls the CancelSpotInstanceRequests API operation.
|
432
447
|
# @method cancel_spot_instance_requests(options = {})
|
433
448
|
#
|
@@ -544,6 +559,41 @@ module AWS
|
|
544
559
|
#
|
545
560
|
define_client_method :create_image, 'CreateImage'
|
546
561
|
|
562
|
+
# Calls the CreateInstanceExportTask API operation.
|
563
|
+
# @method create_instance_export_task(options = {})
|
564
|
+
#
|
565
|
+
# === Options:
|
566
|
+
#
|
567
|
+
# * +:description+ - (String)
|
568
|
+
# * +:instance_id+ - *required* - (String)
|
569
|
+
# * +:target_environment+ - *required* - (String)
|
570
|
+
# * +:export_to_s3+ - (Hash)
|
571
|
+
# * +:disk_image_format+ - (String)
|
572
|
+
# * +:container_format+ - (String)
|
573
|
+
# * +:s3_bucket+ - *required* - (String)
|
574
|
+
# * +:s3_prefix+ - (String)
|
575
|
+
#
|
576
|
+
# === Response Structure:
|
577
|
+
#
|
578
|
+
# * +:request_id+ - (String)
|
579
|
+
# * +:export_task+ - (Hash)
|
580
|
+
# * +:export_task_id+ - (String)
|
581
|
+
# * +:description+ - (String)
|
582
|
+
# * +:state+ - (String)
|
583
|
+
# * +:status_message+ - (String)
|
584
|
+
# * +:instance_export+ - (Hash)
|
585
|
+
# * +:instance_id+ - (String)
|
586
|
+
# * +:target_environment+ - (String)
|
587
|
+
# * +:export_to_s3+ - (Hash)
|
588
|
+
# * +:disk_image_format+ - (String)
|
589
|
+
# * +:container_format+ - (String)
|
590
|
+
# * +:s3_bucket+ - (String)
|
591
|
+
# * +:s3_key+ - (String)
|
592
|
+
#
|
593
|
+
# @return [Core::Response]
|
594
|
+
#
|
595
|
+
define_client_method :create_instance_export_task, 'CreateInstanceExportTask'
|
596
|
+
|
547
597
|
# Calls the CreateInternetGateway API operation.
|
548
598
|
# @method create_internet_gateway(options = {})
|
549
599
|
#
|
@@ -1588,6 +1638,34 @@ module AWS
|
|
1588
1638
|
#
|
1589
1639
|
define_client_method :describe_dhcp_options, 'DescribeDhcpOptions'
|
1590
1640
|
|
1641
|
+
# Calls the DescribeExportTasks API operation.
|
1642
|
+
# @method describe_export_tasks(options = {})
|
1643
|
+
#
|
1644
|
+
# === Options:
|
1645
|
+
#
|
1646
|
+
# * +:export_task_ids+ - (Array<String>)
|
1647
|
+
#
|
1648
|
+
# === Response Structure:
|
1649
|
+
#
|
1650
|
+
# * +:request_id+ - (String)
|
1651
|
+
# * +:export_task_set+ - (Array<Hash>)
|
1652
|
+
# * +:export_task_id+ - (String)
|
1653
|
+
# * +:description+ - (String)
|
1654
|
+
# * +:state+ - (String)
|
1655
|
+
# * +:status_message+ - (String)
|
1656
|
+
# * +:instance_export+ - (Hash)
|
1657
|
+
# * +:instance_id+ - (String)
|
1658
|
+
# * +:target_environment+ - (String)
|
1659
|
+
# * +:export_to_s3+ - (Hash)
|
1660
|
+
# * +:disk_image_format+ - (String)
|
1661
|
+
# * +:container_format+ - (String)
|
1662
|
+
# * +:s3_bucket+ - (String)
|
1663
|
+
# * +:s3_key+ - (String)
|
1664
|
+
#
|
1665
|
+
# @return [Core::Response]
|
1666
|
+
#
|
1667
|
+
define_client_method :describe_export_tasks, 'DescribeExportTasks'
|
1668
|
+
|
1591
1669
|
# Calls the DescribeImageAttribute API operation.
|
1592
1670
|
# @method describe_image_attribute(options = {})
|
1593
1671
|
#
|
@@ -2986,7 +3064,8 @@ module AWS
|
|
2986
3064
|
# Amazon EBS volume is deleted on instance termination.
|
2987
3065
|
# * +:no_device+ - (String) Specifies the device name to suppress
|
2988
3066
|
# during instance launch.
|
2989
|
-
# * +:monitoring+ - (
|
3067
|
+
# * +:monitoring+ - (Hash)
|
3068
|
+
# * +:enabled+ - (Boolean)
|
2990
3069
|
# * +:subnet_id+ - (String)
|
2991
3070
|
# * +:disable_api_termination+ - (Boolean)
|
2992
3071
|
# * +:instance_initiated_shutdown_behavior+ - (String)
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class EC2
|
16
|
+
|
17
|
+
# @attr_reader [String] description
|
18
|
+
# Description of the resource being exported.
|
19
|
+
#
|
20
|
+
# @attr_reader [Symbol] state State of the conversion task.
|
21
|
+
# Valid values :active, :cancelling, :cancelled and :completed.
|
22
|
+
#
|
23
|
+
# @attr_reader [String] status_message Status message related to the
|
24
|
+
# export task.
|
25
|
+
#
|
26
|
+
# @attr_reader [String] instance_id ID of instance being exported.
|
27
|
+
#
|
28
|
+
# @attr_reader [String] target_environment The target virtualization
|
29
|
+
# environment.
|
30
|
+
#
|
31
|
+
# @attr_reader [String] disk_image_format The format for the exported
|
32
|
+
# image.
|
33
|
+
#
|
34
|
+
# @attr_reader [String] container_format The container format used to
|
35
|
+
# combine disk images with metadata (such as OVF).
|
36
|
+
#
|
37
|
+
# @attr_reader [String] s3_bucket The name of the Amazon S3 bucket
|
38
|
+
# the image will be exported to.
|
39
|
+
#
|
40
|
+
# @attr_reader [String] s3_key The key of the Amazon S3 object
|
41
|
+
# the image will be exported to.
|
42
|
+
#
|
43
|
+
class ExportTask < Resource
|
44
|
+
|
45
|
+
# @private
|
46
|
+
def initialize export_task_id, options = {}
|
47
|
+
@export_task_id = export_task_id
|
48
|
+
super
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String]
|
52
|
+
attr_reader :export_task_id
|
53
|
+
|
54
|
+
alias_method :id, :export_task_id
|
55
|
+
|
56
|
+
attribute :description, :static => true
|
57
|
+
|
58
|
+
attribute :state, :to_sym => true
|
59
|
+
|
60
|
+
attribute :status_message
|
61
|
+
|
62
|
+
attribute :instance_id,
|
63
|
+
:as => [:instance_export, :instance_id],
|
64
|
+
:static => true
|
65
|
+
|
66
|
+
attribute :target_environment,
|
67
|
+
:as => [:instance_export, :target_environment],
|
68
|
+
:static => true
|
69
|
+
|
70
|
+
attribute :disk_image_format,
|
71
|
+
:as => [:export_to_s3, :disk_image_format],
|
72
|
+
:static => true
|
73
|
+
|
74
|
+
attribute :container_format,
|
75
|
+
:as => [:export_to_s3, :container_format],
|
76
|
+
:static => true
|
77
|
+
|
78
|
+
attribute :s3_bucket_name,
|
79
|
+
:as => [:export_to_s3, :s3_bucket],
|
80
|
+
:static => true
|
81
|
+
|
82
|
+
attribute :s3_key,
|
83
|
+
:as => [:export_to_s3, :s3_key],
|
84
|
+
:static => true
|
85
|
+
|
86
|
+
populates_from(:create_instance_export_task) do |resp|
|
87
|
+
resp[:export_task] if resp[:export_task][:export_task_id] == id
|
88
|
+
end
|
89
|
+
|
90
|
+
populates_from(:describe_export_tasks) do |resp|
|
91
|
+
resp[:export_task_set].find do |task|
|
92
|
+
task[:export_task_id] == id
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [Instance]
|
97
|
+
def instance
|
98
|
+
Instance.new(instance_id, :config => config)
|
99
|
+
end
|
100
|
+
|
101
|
+
# @return [S3::Bucket]
|
102
|
+
def s3_bucket
|
103
|
+
S3::Bucket.new(s3_bucket_name, :config => config)
|
104
|
+
end
|
105
|
+
|
106
|
+
# @return [S3::S3Object]
|
107
|
+
def s3_object
|
108
|
+
s3_bucket.objects[s3_key]
|
109
|
+
end
|
110
|
+
|
111
|
+
# Cancels the export task.
|
112
|
+
# @return [nil]
|
113
|
+
def cancel
|
114
|
+
client.cancel_export_task(:export_task_id => export_task_id)
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|