aws-sdk-resources 2.1.36 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0202a7a060f88f8495dee3858023812366c4dd15
4
- data.tar.gz: 400a1bb204530aaacd07e6a4680cadf30de52f2a
3
+ metadata.gz: 3d315374401e1f267e514406a412303fdb76c538
4
+ data.tar.gz: b1f51b8fd3529973df0b457a7edf55b0d38a22c6
5
5
  SHA512:
6
- metadata.gz: e2c124d79e8ecedc0a948cdc813f9620c35f460d0b41db334fc0be8989f082eb31c7d895b52a43e752c4c82e1ad721ceddc75d6fe82d183ae1ca5acf596f4908
7
- data.tar.gz: 5ef9405ec02223c0c74744a39f8088cb4ed3dfa660cd4ddc8aed607d725b7a7aacbd2060cb70295e6bac11f7680db466673f720a77e7dd864cfe4bbb17083dc1
6
+ metadata.gz: 7f9255eeb9734022304514aa6165b39c61a90cde7c63a24b06beb0bb0d63f2621fe9c98246f011695e575566a3aafbc7e1dcd93e3ffd45b0ce54ef8c164dc6ba
7
+ data.tar.gz: 46fd4b7838da1c9fcd745e3f5df791eabcd731ec5dfa764a886cabee61d80ac13cab981cebd09ad38eb9449613869367cf4af0b95da6e561b925d9b8b633ad49
@@ -41,4 +41,51 @@ module Aws
41
41
  require(svc) if File.exist?(svc)
42
42
  end
43
43
 
44
+ # In version 2.2, all batch resource operations were renamed:
45
+ #
46
+ # * All operations are now prefixed with `batch_`, e.g. `#start`
47
+ # became `#batch_start`.
48
+ #
49
+ # * All batch operations with "delete" or "terminate" in the name
50
+ # are now suffixed with `!`, e.g. `#delete` is now `#batch_delete!`
51
+ #
52
+ # For backwards compatibility, existing batch methods must still respond
53
+ # to their old names. This callback registers these methods with their
54
+ # old names.
55
+ service_added do |name, svc_module, options|
56
+ unless ENV['DOCSTRINGS']
57
+ case name
58
+ when 'EC2'
59
+ {
60
+ 'create_tags' => 'batch_create_tags',
61
+ 'monitor' => 'batch_create_tags',
62
+ 'reboot' => 'batch_reboot',
63
+ 'start' => 'batch_start',
64
+ 'stop' => 'batch_stop',
65
+ 'terminate' => 'batch_terminate!',
66
+ 'unmonitor' => 'batch_unmonitor',
67
+ }.each do |deprecated_name, name|
68
+ Resources::Operations::DeprecatedOperation.define({
69
+ resource_class: EC2::Instance,
70
+ deprecated_name: deprecated_name,
71
+ name: name,
72
+ })
73
+ end
74
+ Resources::Operations::DeprecatedOperation.define({
75
+ resource_class: EC2::Tag,
76
+ deprecated_name: 'delete',
77
+ name: 'batch_delete!',
78
+ })
79
+ when 'S3'
80
+ [S3::Object, S3::ObjectSummary, S3::ObjectVersion].each do |klass|
81
+ Resources::Operations::DeprecatedOperation.define({
82
+ resource_class: klass,
83
+ deprecated_name: 'delete',
84
+ name: 'batch_delete!',
85
+ })
86
+ end
87
+ end
88
+ end
89
+ end
90
+
44
91
  end
@@ -117,10 +117,27 @@ module Aws
117
117
  private
118
118
 
119
119
  def invoke_batch_operation(method_name, args, block)
120
+ self.class.validate_batch_args!(args)
120
121
  operation = @resource_class.batch_operation(method_name)
121
122
  operation.call(resource:self, args:args, block:block)
122
123
  end
123
124
 
125
+ class << self
126
+
127
+ # @api private
128
+ def validate_batch_args!(args)
129
+ case args.count
130
+ when 0
131
+ when 1
132
+ unless Hash === args.first
133
+ raise ArgumentError, "expected options to be a hash"
134
+ end
135
+ else
136
+ raise ArgumentError, "wrong number of arguments, expected 0 or 1"
137
+ end
138
+ end
139
+
140
+ end
124
141
  end
125
142
  end
126
143
  end
@@ -72,6 +72,7 @@ module Aws
72
72
  # @api private
73
73
  def method_missing(method_name, *args, &block)
74
74
  if respond_to?(method_name)
75
+ Batch.validate_batch_args!(args)
75
76
  batches.each do |batch|
76
77
  batch.send(method_name, *args, &block)
77
78
  end
@@ -51,12 +51,26 @@ module Aws
51
51
 
52
52
  def define_batch_actions(namespace, resource, batch_actions)
53
53
  batch_actions.each do |name, definition|
54
- method_name = underscore(name)
54
+ method_name = "batch_" + underscore(name)
55
+ method_name += '!' if dangerous?(name, definition)
55
56
  operation = build_operation(namespace, resource, definition)
56
57
  resource.add_batch_operation(method_name, operation)
57
58
  end
58
59
  end
59
60
 
61
+ def dangerous?(name, definition)
62
+ if
63
+ name.match(/delete/i) ||
64
+ name.match(/terminate/i) ||
65
+ definition['request']['operation'].match(/delete/i) ||
66
+ definition['request']['operation'].match(/terminate/i)
67
+ then
68
+ true
69
+ else
70
+ false
71
+ end
72
+ end
73
+
60
74
  def define_data_attributes(namespace, resource, definition)
61
75
  if shape_name = definition['shape']
62
76
  shape = resource.client_class.api.metadata['shapes'][shape_name]
@@ -231,6 +231,43 @@ module Aws
231
231
 
232
232
  end
233
233
 
234
+ # @api private
235
+ class DeprecatedOperation
236
+
237
+ def initialize(options = {})
238
+ @name = options[:name]
239
+ @deprecated_name = options[:deprecated_name]
240
+ @resource_class = options[:resource_class]
241
+ @operation = @resource_class.batch_operation(@name)
242
+ @warned = false
243
+ end
244
+
245
+ def call(*args)
246
+ unless @warned
247
+ @warned = true
248
+ warn(deprecation_warning)
249
+ end
250
+ @operation.call(*args)
251
+ end
252
+
253
+ private
254
+
255
+ def deprecation_warning
256
+ "DEPRECATION WARNING: called deprecated batch method " +
257
+ "`##{@deprecated_name}` on a batch of `#{@resource_class.name}` " +
258
+ "objects; use `##{@name}` instead"
259
+ end
260
+
261
+ class << self
262
+
263
+ def define(options = {})
264
+ klass = options[:resource_class]
265
+ deprecated_name = options[:deprecated_name]
266
+ klass.add_batch_operation(deprecated_name, new(options))
267
+ end
268
+
269
+ end
270
+ end
234
271
  end
235
272
  end
236
273
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.36
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.36
19
+ version: 2.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.36
26
+ version: 2.2.0
27
27
  description: Provides resource oriented interfaces and other higher-level abstractions
28
28
  for many AWS services. This gem is part of the official AWS SDK for Ruby.
29
29
  email: