aws-sdk-ec2 1.0.0.rc1

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aws-sdk-ec2.rb +70 -0
  3. data/lib/aws-sdk-ec2/classic_address.rb +227 -0
  4. data/lib/aws-sdk-ec2/client.rb +14254 -0
  5. data/lib/aws-sdk-ec2/client_api.rb +6182 -0
  6. data/lib/aws-sdk-ec2/customizations.rb +21 -0
  7. data/lib/aws-sdk-ec2/customizations/instance.rb +29 -0
  8. data/lib/aws-sdk-ec2/customizations/resource.rb +18 -0
  9. data/lib/aws-sdk-ec2/dhcp_options.rb +183 -0
  10. data/lib/aws-sdk-ec2/errors.rb +23 -0
  11. data/lib/aws-sdk-ec2/image.rb +462 -0
  12. data/lib/aws-sdk-ec2/instance.rb +1570 -0
  13. data/lib/aws-sdk-ec2/internet_gateway.rb +204 -0
  14. data/lib/aws-sdk-ec2/key_pair.rb +120 -0
  15. data/lib/aws-sdk-ec2/key_pair_info.rb +122 -0
  16. data/lib/aws-sdk-ec2/network_acl.rb +341 -0
  17. data/lib/aws-sdk-ec2/network_interface.rb +474 -0
  18. data/lib/aws-sdk-ec2/network_interface_association.rb +151 -0
  19. data/lib/aws-sdk-ec2/placement_group.rb +426 -0
  20. data/lib/aws-sdk-ec2/plugins/copy_encrypted_snapshot.rb +59 -0
  21. data/lib/aws-sdk-ec2/plugins/region_validation.rb +19 -0
  22. data/lib/aws-sdk-ec2/resource.rb +2684 -0
  23. data/lib/aws-sdk-ec2/route.rb +243 -0
  24. data/lib/aws-sdk-ec2/route_table.rb +277 -0
  25. data/lib/aws-sdk-ec2/route_table_association.rb +177 -0
  26. data/lib/aws-sdk-ec2/security_group.rb +530 -0
  27. data/lib/aws-sdk-ec2/snapshot.rb +478 -0
  28. data/lib/aws-sdk-ec2/subnet.rb +972 -0
  29. data/lib/aws-sdk-ec2/tag.rb +223 -0
  30. data/lib/aws-sdk-ec2/types.rb +20124 -0
  31. data/lib/aws-sdk-ec2/volume.rb +555 -0
  32. data/lib/aws-sdk-ec2/vpc.rb +1698 -0
  33. data/lib/aws-sdk-ec2/vpc_address.rb +219 -0
  34. data/lib/aws-sdk-ec2/vpc_peering_connection.rb +265 -0
  35. data/lib/aws-sdk-ec2/waiters.rb +1334 -0
  36. metadata +107 -0
@@ -0,0 +1,21 @@
1
+ # customizations to generated classes
2
+ require 'aws-sdk-ec2/customizations/resource'
3
+ require 'aws-sdk-ec2/customizations/instance'
4
+
5
+ Aws::EC2::Instance::Collection.send(:extend, Aws::Deprecations)
6
+ {
7
+ create_tags: :batch_create_tags,
8
+ monitor: :batch_create_tags,
9
+ reboot: :batch_reboot,
10
+ start: :batch_start,
11
+ stop: :batch_stop,
12
+ terminate: :batch_terminate!,
13
+ unmonitor: :batch_unmonitor,
14
+ }.each do |old, new|
15
+ Aws::EC2::Instance::Collection.send(:alias_method, old, new)
16
+ Aws::EC2::Instance::Collection.send(:deprecated, old, use: new)
17
+ end
18
+
19
+ Aws::EC2::Tag::Collection.send(:alias_method, :delete, :batch_delete!)
20
+ Aws::EC2::Tag::Collection.send(:extend, Aws::Deprecations)
21
+ Aws::EC2::Tag::Collection.send(:deprecated, :delete, use: :batch_delete!)
@@ -0,0 +1,29 @@
1
+ require 'openssl'
2
+
3
+ module Aws
4
+ module EC2
5
+ class Instance
6
+
7
+ # @param [String, Pathname] key_pair_path
8
+ # @return [String]
9
+ def decrypt_windows_password(key_pair_path)
10
+ decoded = Base64.decode64(encrypted_password)
11
+ pem_bytes = File.open(key_pair_path, 'rb') { |f| f.read }
12
+ private_key = OpenSSL::PKey::RSA.new(pem_bytes)
13
+ private_key.private_decrypt(decoded)
14
+ end
15
+
16
+ private
17
+
18
+ def encrypted_password
19
+ bytes = client.get_password_data(instance_id: id).password_data
20
+ if bytes == ''
21
+ raise 'password not available yet'
22
+ else
23
+ bytes
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ module Aws
2
+ module EC2
3
+ class Resource
4
+
5
+ def create_tags(options)
6
+ resp = @client.create_tags(options)
7
+ tags = []
8
+ options[:resources].each do |resource_id|
9
+ options[:tags].each do |tag|
10
+ tags << Tag.new(resource_id, tag[:key], tag[:value], client: @client)
11
+ end
12
+ end
13
+ Tag::Collection.new([tags], size: tags.size)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,183 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module EC2
10
+ class DhcpOptions
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(id, options = {})
15
+ # @param [String] id
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :id
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @id = extract_id(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def id
31
+ @id
32
+ end
33
+ alias :dhcp_options_id :id
34
+
35
+ # One or more DHCP options in the set.
36
+ # @return [Array<Types::DhcpConfiguration>]
37
+ def dhcp_configurations
38
+ data.dhcp_configurations
39
+ end
40
+
41
+ # Any tags assigned to the DHCP options set.
42
+ # @return [Array<Types::Tag>]
43
+ def tags
44
+ data.tags
45
+ end
46
+
47
+ # @!endgroup
48
+
49
+ # @return [Client]
50
+ def client
51
+ @client
52
+ end
53
+
54
+ # Loads, or reloads {#data} for the current {DhcpOptions}.
55
+ # Returns `self` making it possible to chain methods.
56
+ #
57
+ # dhcp_options.reload.data
58
+ #
59
+ # @return [self]
60
+ def load
61
+ resp = @client.describe_dhcp_options(dhcp_options_ids: [@id])
62
+ @data = resp.dhcpoptions[0]
63
+ self
64
+ end
65
+ alias :reload :load
66
+
67
+ # @return [Types::DhcpOptions]
68
+ # Returns the data for this {DhcpOptions}. Calls
69
+ # {Client#describe_dhcp_options} if {#data_loaded?} is `false`.
70
+ def data
71
+ load unless @data
72
+ @data
73
+ end
74
+
75
+ # @return [Boolean]
76
+ # Returns `true` if this resource is loaded. Accessing attributes or
77
+ # {#data} on an unloaded resource will trigger a call to {#load}.
78
+ def data_loaded?
79
+ !!@data
80
+ end
81
+
82
+ # @!group Actions
83
+
84
+ # @example Request syntax with placeholder values
85
+ #
86
+ # dhcp_options.associate_with_vpc({
87
+ # dry_run: false,
88
+ # vpc_id: "String", # required
89
+ # })
90
+ # @param [Hash] options ({})
91
+ # @option options [Boolean] :dry_run
92
+ # Checks whether you have the required permissions for the action,
93
+ # without actually making the request, and provides an error response.
94
+ # If you have the required permissions, the error response is
95
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
96
+ # @option options [required, String] :vpc_id
97
+ # The ID of the VPC.
98
+ # @return [EmptyStructure]
99
+ def associate_with_vpc(options = {})
100
+ options = options.merge(dhcp_options_id: @id)
101
+ resp = @client.associate_dhcp_options(options)
102
+ resp.data
103
+ end
104
+
105
+ # @example Request syntax with placeholder values
106
+ #
107
+ # tag = dhcp_options.create_tags({
108
+ # dry_run: false,
109
+ # tags: [ # required
110
+ # {
111
+ # key: "String",
112
+ # value: "String",
113
+ # },
114
+ # ],
115
+ # })
116
+ # @param [Hash] options ({})
117
+ # @option options [Boolean] :dry_run
118
+ # Checks whether you have the required permissions for the action,
119
+ # without actually making the request, and provides an error response.
120
+ # If you have the required permissions, the error response is
121
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
122
+ # @option options [required, Array<Types::Tag>] :tags
123
+ # One or more tags. The `value` parameter is required, but if you don't
124
+ # want the tag to have a value, specify the parameter with no value, and
125
+ # we set the value to an empty string.
126
+ # @return [Tag::Collection]
127
+ def create_tags(options = {})
128
+ batch = []
129
+ options = Aws::Util.deep_merge(options, resources: [@id])
130
+ resp = @client.create_tags(options)
131
+ options[:tags].each do |t|
132
+ batch << Tag.new(
133
+ resource_id: @id,
134
+ key: t[:key],
135
+ value: t[:value],
136
+ client: @client
137
+ )
138
+ end
139
+ Tag::Collection.new([batch], size: batch.size)
140
+ end
141
+
142
+ # @example Request syntax with placeholder values
143
+ #
144
+ # dhcp_options.delete({
145
+ # dry_run: false,
146
+ # })
147
+ # @param [Hash] options ({})
148
+ # @option options [Boolean] :dry_run
149
+ # Checks whether you have the required permissions for the action,
150
+ # without actually making the request, and provides an error response.
151
+ # If you have the required permissions, the error response is
152
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
153
+ # @return [EmptyStructure]
154
+ def delete(options = {})
155
+ options = options.merge(dhcp_options_id: @id)
156
+ resp = @client.delete_dhcp_options(options)
157
+ resp.data
158
+ end
159
+
160
+ # @deprecated
161
+ # @api private
162
+ def identifiers
163
+ { id: @id }
164
+ end
165
+ deprecated(:identifiers)
166
+
167
+ private
168
+
169
+ def extract_id(args, options)
170
+ value = args[0] || options.delete(:id)
171
+ case value
172
+ when String then value
173
+ when nil then raise ArgumentError, "missing required option :id"
174
+ else
175
+ msg = "expected :id to be a String, got #{value.class}"
176
+ raise ArgumentError, msg
177
+ end
178
+ end
179
+
180
+ class Collection < Aws::Resources::Collection; end
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,23 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module EC2
10
+ module Errors
11
+
12
+ extend Aws::Errors::DynamicErrors
13
+
14
+ # Raised when calling #load or #data on a resource class that can not be
15
+ # loaded. This can happen when:
16
+ #
17
+ # * A resource class has identifiers, but no data attributes.
18
+ # * Resource data is only available when making an API call that
19
+ # enumerates all resources of that type.
20
+ class ResourceNotLoadable < RuntimeError; end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,462 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module EC2
10
+ class Image
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(id, options = {})
15
+ # @param [String] id
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :id
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @id = extract_id(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def id
31
+ @id
32
+ end
33
+ alias :image_id :id
34
+
35
+ # The location of the AMI.
36
+ # @return [String]
37
+ def image_location
38
+ data.image_location
39
+ end
40
+
41
+ # The current state of the AMI. If the state is `available`, the image
42
+ # is successfully registered and can be used to launch an instance.
43
+ # @return [String]
44
+ def state
45
+ data.state
46
+ end
47
+
48
+ # The AWS account ID of the image owner.
49
+ # @return [String]
50
+ def owner_id
51
+ data.owner_id
52
+ end
53
+
54
+ # The date and time the image was created.
55
+ # @return [String]
56
+ def creation_date
57
+ data.creation_date
58
+ end
59
+
60
+ # Indicates whether the image has public launch permissions. The value
61
+ # is `true` if this image has public launch permissions or `false` if it
62
+ # has only implicit and explicit launch permissions.
63
+ # @return [Boolean]
64
+ def public
65
+ data.public
66
+ end
67
+
68
+ # Any product codes associated with the AMI.
69
+ # @return [Array<Types::ProductCode>]
70
+ def product_codes
71
+ data.product_codes
72
+ end
73
+
74
+ # The architecture of the image.
75
+ # @return [String]
76
+ def architecture
77
+ data.architecture
78
+ end
79
+
80
+ # The type of image.
81
+ # @return [String]
82
+ def image_type
83
+ data.image_type
84
+ end
85
+
86
+ # The kernel associated with the image, if any. Only applicable for
87
+ # machine images.
88
+ # @return [String]
89
+ def kernel_id
90
+ data.kernel_id
91
+ end
92
+
93
+ # The RAM disk associated with the image, if any. Only applicable for
94
+ # machine images.
95
+ # @return [String]
96
+ def ramdisk_id
97
+ data.ramdisk_id
98
+ end
99
+
100
+ # The value is `Windows` for Windows AMIs; otherwise blank.
101
+ # @return [String]
102
+ def platform
103
+ data.platform
104
+ end
105
+
106
+ # Specifies whether enhanced networking with the Intel 82599 Virtual
107
+ # Function interface is enabled.
108
+ # @return [String]
109
+ def sriov_net_support
110
+ data.sriov_net_support
111
+ end
112
+
113
+ # Specifies whether enhanced networking with ENA is enabled.
114
+ # @return [Boolean]
115
+ def ena_support
116
+ data.ena_support
117
+ end
118
+
119
+ # The reason for the state change.
120
+ # @return [Types::StateReason]
121
+ def state_reason
122
+ data.state_reason
123
+ end
124
+
125
+ # The AWS account alias (for example, `amazon`, `self`) or the AWS
126
+ # account ID of the AMI owner.
127
+ # @return [String]
128
+ def image_owner_alias
129
+ data.image_owner_alias
130
+ end
131
+
132
+ # The name of the AMI that was provided during image creation.
133
+ # @return [String]
134
+ def name
135
+ data.name
136
+ end
137
+
138
+ # The description of the AMI that was provided during image creation.
139
+ # @return [String]
140
+ def description
141
+ data.description
142
+ end
143
+
144
+ # The type of root device used by the AMI. The AMI can use an EBS volume
145
+ # or an instance store volume.
146
+ # @return [String]
147
+ def root_device_type
148
+ data.root_device_type
149
+ end
150
+
151
+ # The device name of the root device (for example, `/dev/sda1` or
152
+ # `/dev/xvda`).
153
+ # @return [String]
154
+ def root_device_name
155
+ data.root_device_name
156
+ end
157
+
158
+ # Any block device mapping entries.
159
+ # @return [Array<Types::BlockDeviceMapping>]
160
+ def block_device_mappings
161
+ data.block_device_mappings
162
+ end
163
+
164
+ # The type of virtualization of the AMI.
165
+ # @return [String]
166
+ def virtualization_type
167
+ data.virtualization_type
168
+ end
169
+
170
+ # Any tags assigned to the image.
171
+ # @return [Array<Types::Tag>]
172
+ def tags
173
+ data.tags
174
+ end
175
+
176
+ # The hypervisor type of the image.
177
+ # @return [String]
178
+ def hypervisor
179
+ data.hypervisor
180
+ end
181
+
182
+ # @!endgroup
183
+
184
+ # @return [Client]
185
+ def client
186
+ @client
187
+ end
188
+
189
+ # Loads, or reloads {#data} for the current {Image}.
190
+ # Returns `self` making it possible to chain methods.
191
+ #
192
+ # image.reload.data
193
+ #
194
+ # @return [self]
195
+ def load
196
+ resp = @client.describe_images(image_ids: [@id])
197
+ @data = resp.images[0]
198
+ self
199
+ end
200
+ alias :reload :load
201
+
202
+ # @return [Types::Image]
203
+ # Returns the data for this {Image}. Calls
204
+ # {Client#describe_images} if {#data_loaded?} is `false`.
205
+ def data
206
+ load unless @data
207
+ @data
208
+ end
209
+
210
+ # @return [Boolean]
211
+ # Returns `true` if this resource is loaded. Accessing attributes or
212
+ # {#data} on an unloaded resource will trigger a call to {#load}.
213
+ def data_loaded?
214
+ !!@data
215
+ end
216
+
217
+ # @param [Hash] options ({})
218
+ # @return [Boolean]
219
+ # Returns `true` if the Image exists.
220
+ def exists?(options = {})
221
+ begin
222
+ wait_until_exists(options.merge(max_attempts: 1))
223
+ true
224
+ rescue Aws::Waiters::Errors::UnexpectedError => e
225
+ raise e.error
226
+ rescue Aws::Waiters::Errors::WaiterFailed
227
+ false
228
+ end
229
+ end
230
+
231
+ # @param [Hash] options ({})
232
+ # @option options [Integer] :max_attempts (40)
233
+ # @option options [Float] :delay (15)
234
+ # @option options [Proc] :before_attempt
235
+ # @option options [Proc] :before_wait
236
+ # @return [Image]
237
+ def wait_until_exists(options = {})
238
+ options, params = separate_params_and_options(options)
239
+ waiter = Waiters::ImageExists.new(options)
240
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
241
+ resp = waiter.wait(params.merge(image_ids: [@id]))
242
+ Image.new({
243
+ id: @id,
244
+ data: resp.data.images[0],
245
+ client: @client
246
+ })
247
+ end
248
+
249
+ # @!group Actions
250
+
251
+ # @example Request syntax with placeholder values
252
+ #
253
+ # tag = image.create_tags({
254
+ # dry_run: false,
255
+ # tags: [ # required
256
+ # {
257
+ # key: "String",
258
+ # value: "String",
259
+ # },
260
+ # ],
261
+ # })
262
+ # @param [Hash] options ({})
263
+ # @option options [Boolean] :dry_run
264
+ # Checks whether you have the required permissions for the action,
265
+ # without actually making the request, and provides an error response.
266
+ # If you have the required permissions, the error response is
267
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
268
+ # @option options [required, Array<Types::Tag>] :tags
269
+ # One or more tags. The `value` parameter is required, but if you don't
270
+ # want the tag to have a value, specify the parameter with no value, and
271
+ # we set the value to an empty string.
272
+ # @return [Tag::Collection]
273
+ def create_tags(options = {})
274
+ batch = []
275
+ options = Aws::Util.deep_merge(options, resources: [@id])
276
+ resp = @client.create_tags(options)
277
+ options[:tags].each do |t|
278
+ batch << Tag.new(
279
+ resource_id: @id,
280
+ key: t[:key],
281
+ value: t[:value],
282
+ client: @client
283
+ )
284
+ end
285
+ Tag::Collection.new([batch], size: batch.size)
286
+ end
287
+
288
+ # @example Request syntax with placeholder values
289
+ #
290
+ # image.deregister({
291
+ # dry_run: false,
292
+ # })
293
+ # @param [Hash] options ({})
294
+ # @option options [Boolean] :dry_run
295
+ # Checks whether you have the required permissions for the action,
296
+ # without actually making the request, and provides an error response.
297
+ # If you have the required permissions, the error response is
298
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
299
+ # @return [EmptyStructure]
300
+ def deregister(options = {})
301
+ options = options.merge(image_id: @id)
302
+ resp = @client.deregister_image(options)
303
+ resp.data
304
+ end
305
+
306
+ # @example Request syntax with placeholder values
307
+ #
308
+ # image.describe_attribute({
309
+ # dry_run: false,
310
+ # attribute: "description", # required, accepts description, kernel, ramdisk, launchPermission, productCodes, blockDeviceMapping, sriovNetSupport
311
+ # })
312
+ # @param [Hash] options ({})
313
+ # @option options [Boolean] :dry_run
314
+ # Checks whether you have the required permissions for the action,
315
+ # without actually making the request, and provides an error response.
316
+ # If you have the required permissions, the error response is
317
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
318
+ # @option options [required, String] :attribute
319
+ # The AMI attribute.
320
+ #
321
+ # **Note**\: Depending on your account privileges, the
322
+ # `blockDeviceMapping` attribute may return a `Client.AuthFailure`
323
+ # error. If this happens, use DescribeImages to get information about
324
+ # the block device mapping for the AMI.
325
+ # @return [Types::ImageAttribute]
326
+ def describe_attribute(options = {})
327
+ options = options.merge(image_id: @id)
328
+ resp = @client.describe_image_attribute(options)
329
+ resp.data
330
+ end
331
+
332
+ # @example Request syntax with placeholder values
333
+ #
334
+ # image.modify_attribute({
335
+ # dry_run: false,
336
+ # attribute: "String",
337
+ # operation_type: "add", # accepts add, remove
338
+ # user_ids: ["String"],
339
+ # user_groups: ["String"],
340
+ # product_codes: ["String"],
341
+ # value: "String",
342
+ # launch_permission: {
343
+ # add: [
344
+ # {
345
+ # user_id: "String",
346
+ # group: "all", # accepts all
347
+ # },
348
+ # ],
349
+ # remove: [
350
+ # {
351
+ # user_id: "String",
352
+ # group: "all", # accepts all
353
+ # },
354
+ # ],
355
+ # },
356
+ # description: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
357
+ # })
358
+ # @param [Hash] options ({})
359
+ # @option options [Boolean] :dry_run
360
+ # Checks whether you have the required permissions for the action,
361
+ # without actually making the request, and provides an error response.
362
+ # If you have the required permissions, the error response is
363
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
364
+ # @option options [String] :attribute
365
+ # The name of the attribute to modify.
366
+ # @option options [String] :operation_type
367
+ # The operation type.
368
+ # @option options [Array<String>] :user_ids
369
+ # One or more AWS account IDs. This is only valid when modifying the
370
+ # `launchPermission` attribute.
371
+ # @option options [Array<String>] :user_groups
372
+ # One or more user groups. This is only valid when modifying the
373
+ # `launchPermission` attribute.
374
+ # @option options [Array<String>] :product_codes
375
+ # One or more product codes. After you add a product code to an AMI, it
376
+ # can't be removed. This is only valid when modifying the
377
+ # `productCodes` attribute.
378
+ # @option options [String] :value
379
+ # The value of the attribute being modified. This is only valid when
380
+ # modifying the `description` attribute.
381
+ # @option options [Types::LaunchPermissionModifications] :launch_permission
382
+ # A launch permission modification.
383
+ # @option options [Types::AttributeValue] :description
384
+ # A description for the AMI.
385
+ # @return [EmptyStructure]
386
+ def modify_attribute(options = {})
387
+ options = options.merge(image_id: @id)
388
+ resp = @client.modify_image_attribute(options)
389
+ resp.data
390
+ end
391
+
392
+ # @example Request syntax with placeholder values
393
+ #
394
+ # image.reset_attribute({
395
+ # dry_run: false,
396
+ # attribute: "launchPermission", # required, accepts launchPermission
397
+ # })
398
+ # @param [Hash] options ({})
399
+ # @option options [Boolean] :dry_run
400
+ # Checks whether you have the required permissions for the action,
401
+ # without actually making the request, and provides an error response.
402
+ # If you have the required permissions, the error response is
403
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
404
+ # @option options [required, String] :attribute
405
+ # The attribute to reset (currently you can only reset the launch
406
+ # permission attribute).
407
+ # @return [EmptyStructure]
408
+ def reset_attribute(options = {})
409
+ options = options.merge(image_id: @id)
410
+ resp = @client.reset_image_attribute(options)
411
+ resp.data
412
+ end
413
+
414
+ # @deprecated
415
+ # @api private
416
+ def identifiers
417
+ { id: @id }
418
+ end
419
+ deprecated(:identifiers)
420
+
421
+ private
422
+
423
+ def extract_id(args, options)
424
+ value = args[0] || options.delete(:id)
425
+ case value
426
+ when String then value
427
+ when nil then raise ArgumentError, "missing required option :id"
428
+ else
429
+ msg = "expected :id to be a String, got #{value.class}"
430
+ raise ArgumentError, msg
431
+ end
432
+ end
433
+
434
+ def yield_waiter_and_warn(waiter, &block)
435
+ if !@waiter_block_warned
436
+ msg = "pass options to configure the waiter; "
437
+ msg << "yielding the waiter is deprecated"
438
+ warn(msg)
439
+ @waiter_block_warned = true
440
+ end
441
+ yield(waiter.waiter)
442
+ end
443
+
444
+ def separate_params_and_options(options)
445
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
446
+ waiter_opts = {}
447
+ waiter_params = {}
448
+ options.each_pair do |key, value|
449
+ if opts.include?(key)
450
+ waiter_opts[key] = value
451
+ else
452
+ waiter_params[key] = value
453
+ end
454
+ end
455
+ waiter_opts[:client] ||= @client
456
+ [waiter_opts, waiter_params]
457
+ end
458
+
459
+ class Collection < Aws::Resources::Collection; end
460
+ end
461
+ end
462
+ end