aws-sdk-core 2.0.0.rc1 → 2.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +6 -3
  4. data/Rakefile +2 -0
  5. data/apis/AutoScaling-2011-01-01.json +1 -0
  6. data/apis/CloudFormation-2010-05-15.json +75 -0
  7. data/apis/CloudFront-2012-05-05.json +1 -0
  8. data/apis/CloudFront-2013-05-12.json +1 -0
  9. data/apis/CloudFront-2013-08-26.json +1 -0
  10. data/apis/CloudSearch-2011-02-01.json +1 -0
  11. data/apis/CloudWatch-2010-08-01.json +1 -0
  12. data/apis/DataPipeline-2012-10-29.json +1 -0
  13. data/apis/DirectConnect-2012-10-25.json +1 -0
  14. data/apis/DynamoDB-2011-12-05.json +1 -0
  15. data/apis/DynamoDB-2012-08-10.json +1 -0
  16. data/apis/EC2-2013-06-15.json +1 -0
  17. data/apis/EC2-2013-10-01.json +1 -0
  18. data/apis/EMR-2009-03-31.json +1 -0
  19. data/apis/ElastiCache-2012-11-15.json +1 -0
  20. data/apis/ElastiCache-2013-06-15.json +1 -0
  21. data/apis/ElasticBeanstalk-2010-12-01.json +1 -0
  22. data/apis/ElasticLoadBalancing-2012-06-01.json +73 -0
  23. data/apis/ElasticTranscoder-2012-09-25.json +231 -0
  24. data/apis/Glacier-2012-06-01.json +2 -0
  25. data/apis/IAM-2010-05-08.json +1 -0
  26. data/apis/ImportExport-2010-06-01.json +1 -0
  27. data/apis/OpsWorks-2013-02-18.json +1 -0
  28. data/apis/RDS-2013-01-10.json +1 -0
  29. data/apis/RDS-2013-02-12.json +1 -0
  30. data/apis/RDS-2013-05-15.json +1 -0
  31. data/apis/Redshift-2012-12-01.json +1 -0
  32. data/apis/Route53-2012-12-12.json +1 -0
  33. data/apis/S3-2006-03-01.json +5 -0
  34. data/apis/SDB-2009-04-15.json +1 -0
  35. data/apis/SES-2010-12-01.json +1 -0
  36. data/apis/SNS-2010-03-31.json +1 -0
  37. data/apis/SQS-2012-11-05.json +1 -0
  38. data/apis/STS-2011-06-15.json +1 -0
  39. data/apis/SWF-2012-01-25.json +1 -0
  40. data/apis/StorageGateway-2012-06-30.json +1 -0
  41. data/apis/StorageGateway-2013-06-30.json +2018 -0
  42. data/apis/Support-2013-04-15.json +1 -0
  43. data/apis/source/cloudformation-2010-05-15.json +118 -12
  44. data/apis/source/elasticloadbalancing-2012-06-01.json +347 -220
  45. data/apis/source/elastictranscoder-2012-09-25.json +315 -5
  46. data/apis/source/s3-2006-03-01.json +3 -0
  47. data/apis/source/storagegateway-2013-06-30.json +12560 -0
  48. data/apis/source/storagegateway-2013-06-30.paginators.json +28 -0
  49. data/doc-src/plugins/apis.rb +44 -1
  50. data/doc-src/templates/default/fulldoc/html/setup.rb +1 -1
  51. data/features/common/step_definitions.rb +3 -5
  52. data/features/env.rb +2 -0
  53. data/features/glacier/client.feature +8 -0
  54. data/features/glacier/step_definitions.rb +7 -7
  55. data/features/s3/step_definitions.rb +2 -3
  56. data/lib/aws.rb +75 -69
  57. data/lib/aws/api/service_translators/glacier.rb +1 -0
  58. data/lib/aws/api/translator.rb +13 -8
  59. data/lib/aws/credentials.rb +5 -5
  60. data/lib/aws/instance_profile_credentials.rb +113 -0
  61. data/lib/aws/plugins/credentials.rb +2 -1
  62. data/lib/aws/plugins/glacier_account_id.rb +11 -0
  63. data/lib/aws/plugins/glacier_checksums.rb +7 -3
  64. data/lib/aws/plugins/instance_profile_credentials.rb +14 -0
  65. data/lib/aws/plugins/s3_bucket_dns.rb +17 -14
  66. data/lib/aws/plugins/s3_md5s.rb +3 -3
  67. data/lib/aws/service.rb +10 -9
  68. data/lib/aws/signers/s3.rb +2 -2
  69. data/lib/aws/signers/v2.rb +1 -1
  70. data/lib/aws/signers/v4.rb +2 -2
  71. data/lib/aws/version.rb +1 -1
  72. data/lib/aws/xml/serializer.rb +1 -1
  73. data/spec/aws/instance_profile_credentials_spec.rb +94 -0
  74. data/spec/aws/operations_spec.rb +1 -1
  75. data/spec/aws/plugins/credentials_spec.rb +2 -2
  76. data/spec/fixtures/operations/glacier/account_id_param.yml +13 -0
  77. data/spec/fixtures/operations/glacier/custom_account_id.yml +11 -0
  78. data/spec/fixtures/operations/glacier/default_account_id.yml +10 -0
  79. data/spec/fixtures/operations/s3/content_type_header.yml +12 -0
  80. data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +1 -1
  81. data/tasks/apis.rake +2 -2
  82. data/tasks/docs.rake +2 -1
  83. data/tasks/handlers.rake +30 -0
  84. data/vendor/seahorse/lib/seahorse/client.rb +1 -0
  85. data/vendor/seahorse/lib/seahorse/client/base.rb +0 -18
  86. data/vendor/seahorse/lib/seahorse/client/block_io.rb +0 -7
  87. data/vendor/seahorse/lib/seahorse/client/configuration.rb +57 -37
  88. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +115 -78
  89. data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +19 -15
  90. data/vendor/seahorse/lib/seahorse/client/http/request.rb +0 -15
  91. data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +0 -7
  92. data/vendor/seahorse/lib/seahorse/client/managed_file.rb +14 -0
  93. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +1 -3
  94. data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +1 -1
  95. data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +81 -10
  96. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +1 -71
  97. data/vendor/seahorse/lib/seahorse/client/request.rb +26 -3
  98. data/vendor/seahorse/spec/seahorse/client/base_spec.rb +1 -5
  99. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +1 -10
  100. data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +10 -10
  101. data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +46 -14
  102. data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +1 -42
  103. data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +1 -6
  104. data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +1 -1
  105. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +5 -4
  106. data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +1 -0
  107. data/vendor/seahorse/spec/seahorse/client/plugins/{restful_bindings/uri_path_builder_spec.rb → endpoint/request_uri_builder_spec.rb} +3 -3
  108. data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +1 -11
  109. data/vendor/seahorse/spec/seahorse/client/request_spec.rb +63 -13
  110. metadata +21 -3
@@ -0,0 +1,30 @@
1
+ namespace :handlers do
2
+ Aws.service_classes.each do |svc_name, svc_class|
3
+
4
+ # create a task for each service, e.g. handlers:s3
5
+ desc "Displays handlers for #{svc_class.name}"
6
+ task(svc_name) do
7
+ svc = svc_class.new
8
+ if operation_name = ENV['OPERATION']
9
+ print_handlers(svc.build_request(operation_name).handlers)
10
+ else
11
+ puts ""
12
+ puts "Diplaying handlers applied to all #{svc_class.name} operations,"
13
+ puts " use OPERATION=name to include operation specific handlers"
14
+ puts ""
15
+ print_handlers(svc.handlers)
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+
22
+ def print_handlers(handlers)
23
+ row = '%-6s %-11s %-9s %s'
24
+ puts row % ['Order', 'Step', 'Priority', 'Handler Class']
25
+ puts '---------------------------------------------------------'
26
+ entries = handlers.entries.sort.reverse.select{ |e| e.operations.empty? }
27
+ entries.each_with_index do |entry, n|
28
+ puts row % [n + 1, entry.step, entry.priority, entry.handler_class]
29
+ end
30
+ end
@@ -7,6 +7,7 @@ module Seahorse
7
7
  autoload :Handler, 'seahorse/client/handler'
8
8
  autoload :HandlerBuilder, 'seahorse/client/handler_builder'
9
9
  autoload :HandlerList, 'seahorse/client/handler_list'
10
+ autoload :ManagedFile, 'seahorse/client/managed_file'
10
11
  autoload :ParamConverter, 'seahorse/client/param_converter'
11
12
  autoload :ParamValidator, 'seahorse/client/param_validator'
12
13
  autoload :Plugin, 'seahorse/client/plugin'
@@ -97,24 +97,6 @@ module Seahorse
97
97
 
98
98
  class << self
99
99
 
100
- # @option options [String] :endpoint
101
- # Endpoints specify the http scheme, hostname and port to connect
102
- # to. You must specify at a minimum the hostname. Endpoints without
103
- # a uri scheme will default to https on port 443.
104
- #
105
- # # defaults to https on port 443
106
- # hostname: 'domain.com'
107
- #
108
- # # defaults to http on port 80
109
- # hostname: 'domain.com', ssl_default: false
110
- #
111
- # # defaults are ignored, as scheme and port are present
112
- # hostname: 'http://domain.com:123'
113
- #
114
- # @option options [Boolean] :ssl_default (true) Specifies the default
115
- # scheme for the #endpoint when not specified. Defaults to `true`
116
- # which creates https endpoints.
117
- #
118
100
  def new(options = {})
119
101
  plugins = build_plugins
120
102
  options = options.dup
@@ -27,13 +27,6 @@ module Seahorse
27
27
  @size
28
28
  end
29
29
 
30
- # It is not possible to rewind a {BlockIO} object as the data has
31
- # already been yielded.
32
- # @return [NotImplementedError]
33
- def rewind
34
- raise NotImplementedError
35
- end
36
-
37
30
  end
38
31
  end
39
32
  end
@@ -51,9 +51,23 @@ module Seahorse
51
51
  #
52
52
  class Configuration
53
53
 
54
+ # @api private
55
+ Defaults = Class.new(Array) do
56
+ def each(&block)
57
+ reverse.each(&block)
58
+ end
59
+ end
60
+
61
+ # @api private
62
+ DynamicDefault = Struct.new(:block) do
63
+ def call(*args)
64
+ block.call(*args)
65
+ end
66
+ end
67
+
54
68
  # @api private
55
69
  def initialize
56
- @defaults = {}
70
+ @defaults = Hash.new { |h,k| h[k] = Defaults.new }
57
71
  end
58
72
 
59
73
  # Adds a getter method that returns the named option or a default
@@ -84,9 +98,8 @@ module Seahorse
84
98
  #
85
99
  # @return [self]
86
100
  def add_option(name, default = nil, &block)
87
- @defaults[name.to_sym] = block_given? ?
88
- UnresolvedOption.new(Proc.new) :
89
- default
101
+ default = DynamicDefault.new(Proc.new) if block_given?
102
+ @defaults[name.to_sym] << default
90
103
  self
91
104
  end
92
105
 
@@ -126,7 +139,19 @@ module Seahorse
126
139
  # @param [Hash] options ({}) A hash of configuration options.
127
140
  # @return [Struct] Returns a frozen configuration `Struct`.
128
141
  def build!(options = {})
129
- struct = default_struct
142
+ struct = empty_struct
143
+ apply_options(struct, options)
144
+ apply_defaults(struct, options)
145
+ struct
146
+ end
147
+
148
+ private
149
+
150
+ def empty_struct
151
+ Struct.new(*@defaults.keys.sort).new
152
+ end
153
+
154
+ def apply_options(struct, options)
130
155
  options.each do |opt, value|
131
156
  begin
132
157
  struct[opt] = value
@@ -135,62 +160,57 @@ module Seahorse
135
160
  raise ArgumentError, msg
136
161
  end
137
162
  end
138
- OptionBlockResolver.new(struct).struct.freeze
139
163
  end
140
164
 
141
- private
142
-
143
- def default_struct
144
- Struct.new(*@defaults.keys).new(*@defaults.values_at(*@defaults.keys))
145
- end
146
-
147
- # @api private
148
- class UnresolvedOption
149
-
150
- def initialize(block)
151
- @block = block
165
+ def apply_defaults(struct, options)
166
+ @defaults.each do |opt_name, defaults|
167
+ unless options.key?(opt_name)
168
+ struct[opt_name] = defaults
169
+ end
152
170
  end
153
-
154
- attr_reader :block
155
-
171
+ DefaultResolver.new(struct).resolve
156
172
  end
157
173
 
158
174
  # @api private
159
- class OptionBlockResolver
175
+ class DefaultResolver
160
176
 
161
177
  def initialize(struct)
162
178
  @struct = struct
163
179
  @members = Set.new(@struct.members)
164
- @struct.members.each do |opt|
165
- if struct[opt].is_a?(UnresolvedOption)
166
- struct[opt] = struct[opt].block.call(self)
167
- end
168
- end
169
180
  end
170
181
 
171
- attr_reader :struct
182
+ def resolve
183
+ @members.each { |opt_name| value_at(opt_name) }
184
+ end
172
185
 
173
- def respond_to?(method_name)
174
- @members.include?(method_name.to_sym) || super
186
+ def respond_to?(method_name, *args)
187
+ @members.include?(method_name) or super
175
188
  end
176
189
 
177
190
  private
178
191
 
192
+ def value_at(opt_name)
193
+ value = @struct[opt_name]
194
+ value.is_a?(Defaults) ? resolve_defaults(opt_name, value) : value
195
+ end
196
+
197
+ def resolve_defaults(opt_name, defaults)
198
+ defaults.each do |default|
199
+ default = default.call(self) if default.is_a?(DynamicDefault)
200
+ @struct[opt_name] = default
201
+ break if !default.nil?
202
+ end
203
+ @struct[opt_name]
204
+ end
205
+
179
206
  def method_missing(method_name, *args)
180
207
  if @members.include?(method_name)
181
- resolve_blocks(method_name)
208
+ value_at(method_name)
182
209
  else
183
210
  super
184
211
  end
185
212
  end
186
213
 
187
- def resolve_blocks(member)
188
- if @struct[member].is_a?(UnresolvedOption)
189
- @struct[member] = @struct[member].block.call(self)
190
- end
191
- @struct[member]
192
- end
193
-
194
214
  end
195
215
  end
196
216
  end
@@ -20,33 +20,109 @@ module Seahorse
20
20
  end
21
21
  end
22
22
 
23
- # @api private
24
- Entry = Struct.new(:klass, :options, :operations, :priority, :inserted) do
23
+ class Entry
24
+
25
+ # @api private
26
+ STEPS = {
27
+ initialize: 400,
28
+ validate: 300,
29
+ build: 200,
30
+ sign: 100,
31
+ send: 0,
32
+ }
33
+
34
+ def initialize(handler, inserted, options)
35
+ @handler = handler
36
+ @inserted = inserted
37
+ @operations = Set.new((options[:operations] || []).map(&:to_s))
38
+ @step = :build
39
+ @priority = 50
40
+ self.step = options[:step] if options[:step]
41
+ self.priority = options[:priority] if options[:priority]
42
+ compute_weight unless @weight
43
+ end
44
+
45
+ # @return [Handler, Class<Handler>] Returns the handler. This may
46
+ # be a constructed handler object or a handler class.
47
+ attr_accessor :handler
48
+
49
+ # @return [Integer] The insertion order/position. This is used to
50
+ # determine sort order when two entries have the same priority.
51
+ # Entries inserted later (with a higher inserted value) have a
52
+ # lower priority.
53
+ attr_accessor :inserted
54
+
55
+ # @return [Symbol]
56
+ attr_accessor :step
57
+
58
+ # @return [Integer]
59
+ attr_accessor :priority
60
+
61
+ # @return [Set<String>]
62
+ attr_accessor :operations
63
+
64
+ # @return [Integer]
65
+ attr_accessor :weight
66
+
67
+ # @return [Class]
68
+ def handler_class
69
+ handler.is_a?(Class) ? handler : handler.class
70
+ end
71
+
72
+ # @param [Symbol] step
73
+ def step=(step)
74
+ raise InvalidStepError, step unless STEPS.key?(step)
75
+ @step = step
76
+ compute_weight
77
+ end
78
+
79
+ # @param [Integer<0..99>] priority
80
+ def priority=(priority)
81
+ raise InvalidPriorityError, priority unless (0..99).include?(priority)
82
+ @priority = priority
83
+ compute_weight
84
+ end
85
+
86
+ # @api private
87
+ def dup
88
+ duplicate = super
89
+ duplicate.operations = operations.dup
90
+ duplicate
91
+ end
92
+
93
+ # @api private
25
94
  def <=>(other)
26
- if priority == other.priority
27
- inserted <=> other.inserted
95
+ if weight == other.weight
96
+ other.inserted <=> inserted
28
97
  else
29
- priority <=> other.priority
98
+ weight <=> other.weight
30
99
  end
31
100
  end
32
- end
33
101
 
34
- # @api private
35
- STEPS = {
36
- initialize: 300,
37
- validate: 200,
38
- build: 100,
39
- sign: 0,
40
- }
102
+ private
103
+
104
+ def compute_weight
105
+ @weight = STEPS[@step] + @priority
106
+ end
107
+
108
+ end
41
109
 
42
110
  include Enumerable
43
111
 
44
112
  # @api private
45
113
  def initialize(options = {})
46
114
  @index = options[:index] || 0
47
- @send = options[:send]
48
- @handlers = options[:handlers] || []
115
+ @entries = {}
49
116
  @mutex = Mutex.new
117
+ entries = options[:entries] || []
118
+ add_entries(entries) unless entries.empty?
119
+ end
120
+
121
+ # @return [Array<Entry>]
122
+ def entries
123
+ @mutex.synchronize do
124
+ @entries.values
125
+ end
50
126
  end
51
127
 
52
128
  # Registers a handler. Handlers are used to build a handler stack.
@@ -126,36 +202,23 @@ module Seahorse
126
202
  #
127
203
  # @return [Class<Handler>] Returns the handler class that was added.
128
204
  #
129
- def add(handler_class, options = {})
205
+ def add(handler, options = {})
130
206
  @mutex.synchronize do
131
- if options[:step] == :send
132
- @send = handler_class
133
- else
134
- @handlers << Entry.new(
135
- handler_class,
136
- options,
137
- operations(options),
138
- priority(options),
139
- next_index,
140
- )
141
- end
207
+ add_entry(Entry.new(handler, next_index, options))
142
208
  end
143
- handler_class
209
+ handler
144
210
  end
145
211
 
146
212
  # Copies handlers from the `source_list` onto the current handler list.
147
213
  # @param [HandlerList] source_list
148
214
  # @return [void]
149
215
  def copy_from(source_list)
150
- @mutex.synchronize do
151
- send, handlers = source_list.send(:handlers)
152
- @send = send if send
153
- handlers.each do |handler|
154
- new_handler = handler.dup
155
- new_handler.inserted = next_index
156
- @handlers << new_handler
157
- end
216
+ entries = source_list.entries.collect do |entry|
217
+ new_entry = entry.dup
218
+ new_entry.inserted = next_index
219
+ new_entry
158
220
  end
221
+ add_entries(entries)
159
222
  end
160
223
 
161
224
  # Returns a handler list for the given operation. The returned
@@ -164,22 +227,13 @@ module Seahorse
164
227
  # @param [String] operation The name of an operation.
165
228
  # @return [HandlerList]
166
229
  def for(operation)
167
- @mutex.synchronize do
168
- HandlerList.new(
169
- index: @index,
170
- send: @send,
171
- handlers: filter(operation.to_s),
172
- )
173
- end
230
+ HandlerList.new(index: @index, entries: filter(operation.to_s))
174
231
  end
175
232
 
176
233
  # Yields the handlers in stack order, which is reverse priority.
177
234
  def each(&block)
178
- @mutex.synchronize do
179
- yield(@send) if @send
180
- @handlers.sort.each do |handler|
181
- yield(handler.klass) if handler.operations.nil?
182
- end
235
+ entries.sort.each do |entry|
236
+ yield(entry.handler) if entry.operations.empty?
183
237
  end
184
238
  end
185
239
 
@@ -200,51 +254,34 @@ module Seahorse
200
254
 
201
255
  private
202
256
 
203
- def operations(options)
204
- options[:operations] ? Set.new(options[:operations].map(&:to_s)) : nil
257
+ def add_entries(entries)
258
+ @mutex.synchronize do
259
+ entries.each { |entry| add_entry(entry) }
260
+ end
261
+ end
262
+
263
+ def add_entry(entry)
264
+ key = entry.step == :send ? :send : entry.object_id
265
+ @entries[key] = entry
205
266
  end
206
267
 
207
268
  def filter(operation)
208
- filtered = []
209
- @handlers.each do |handler|
210
- if handler.operations.nil?
269
+ entries.inject([]) do |filtered, handler|
270
+ if handler.operations.empty?
211
271
  filtered << handler
212
272
  elsif handler.operations.include?(operation)
213
273
  handler = handler.dup
214
- handler.operations = nil
274
+ handler.operations.clear
215
275
  filtered << handler
216
276
  end
277
+ filtered
217
278
  end
218
- filtered
219
279
  end
220
280
 
221
281
  def next_index
222
282
  @index += 1
223
283
  end
224
284
 
225
- # @return [Integer]
226
- def priority(options)
227
- step_value(options) + priority_value(options)
228
- end
229
-
230
- # @return [Integer]
231
- def step_value(options)
232
- step = options[:step] || :build
233
- raise InvalidStepError, step unless STEPS.key?(step)
234
- STEPS[step]
235
- end
236
-
237
- # @return [Integer]
238
- def priority_value(options)
239
- priority = options[:priority] || 50
240
- raise InvalidPriorityError, priority unless (0..99).include?(priority)
241
- priority
242
- end
243
-
244
- def handlers
245
- [@send, @handlers]
246
- end
247
-
248
285
  end
249
286
  end
250
287
  end