aws-sdk-ec2 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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,555 @@
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 Volume
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 :volume_id :id
34
+
35
+ # The size of the volume, in GiBs.
36
+ # @return [Integer]
37
+ def size
38
+ data.size
39
+ end
40
+
41
+ # The snapshot from which the volume was created, if applicable.
42
+ # @return [String]
43
+ def snapshot_id
44
+ data.snapshot_id
45
+ end
46
+
47
+ # The Availability Zone for the volume.
48
+ # @return [String]
49
+ def availability_zone
50
+ data.availability_zone
51
+ end
52
+
53
+ # The volume state.
54
+ # @return [String]
55
+ def state
56
+ data.state
57
+ end
58
+
59
+ # The time stamp when volume creation was initiated.
60
+ # @return [Time]
61
+ def create_time
62
+ data.create_time
63
+ end
64
+
65
+ # Information about the volume attachments.
66
+ # @return [Array<Types::VolumeAttachment>]
67
+ def attachments
68
+ data.attachments
69
+ end
70
+
71
+ # Any tags assigned to the volume.
72
+ # @return [Array<Types::Tag>]
73
+ def tags
74
+ data.tags
75
+ end
76
+
77
+ # The volume type. This can be `gp2` for General Purpose SSD, `io1` for
78
+ # Provisioned IOPS SSD, `st1` for Throughput Optimized HDD, `sc1` for
79
+ # Cold HDD, or `standard` for Magnetic volumes.
80
+ # @return [String]
81
+ def volume_type
82
+ data.volume_type
83
+ end
84
+
85
+ # The number of I/O operations per second (IOPS) that the volume
86
+ # supports. For Provisioned IOPS SSD volumes, this represents the number
87
+ # of IOPS that are provisioned for the volume. For General Purpose SSD
88
+ # volumes, this represents the baseline performance of the volume and
89
+ # the rate at which the volume accumulates I/O credits for bursting. For
90
+ # more information on General Purpose SSD baseline performance, I/O
91
+ # credits, and bursting, see [Amazon EBS Volume Types][1] in the *Amazon
92
+ # Elastic Compute Cloud User Guide*.
93
+ #
94
+ # Constraint: Range is 100-20000 IOPS for io1 volumes and 100-10000 IOPS
95
+ # for `gp2` volumes.
96
+ #
97
+ # Condition: This parameter is required for requests to create `io1`
98
+ # volumes; it is not used in requests to create `gp2`, `st1`, `sc1`, or
99
+ # `standard` volumes.
100
+ #
101
+ #
102
+ #
103
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
104
+ # @return [Integer]
105
+ def iops
106
+ data.iops
107
+ end
108
+
109
+ # Indicates whether the volume will be encrypted.
110
+ # @return [Boolean]
111
+ def encrypted
112
+ data.encrypted
113
+ end
114
+
115
+ # The full ARN of the AWS Key Management Service (AWS KMS) customer
116
+ # master key (CMK) that was used to protect the volume encryption key
117
+ # for the volume.
118
+ # @return [String]
119
+ def kms_key_id
120
+ data.kms_key_id
121
+ end
122
+
123
+ # @!endgroup
124
+
125
+ # @return [Client]
126
+ def client
127
+ @client
128
+ end
129
+
130
+ # Loads, or reloads {#data} for the current {Volume}.
131
+ # Returns `self` making it possible to chain methods.
132
+ #
133
+ # volume.reload.data
134
+ #
135
+ # @return [self]
136
+ def load
137
+ resp = @client.describe_volumes(volume_ids: [@id])
138
+ @data = resp.volumes[0]
139
+ self
140
+ end
141
+ alias :reload :load
142
+
143
+ # @return [Types::Volume]
144
+ # Returns the data for this {Volume}. Calls
145
+ # {Client#describe_volumes} if {#data_loaded?} is `false`.
146
+ def data
147
+ load unless @data
148
+ @data
149
+ end
150
+
151
+ # @return [Boolean]
152
+ # Returns `true` if this resource is loaded. Accessing attributes or
153
+ # {#data} on an unloaded resource will trigger a call to {#load}.
154
+ def data_loaded?
155
+ !!@data
156
+ end
157
+
158
+ # @!group Actions
159
+
160
+ # @example Request syntax with placeholder values
161
+ #
162
+ # volume.attach_to_instance({
163
+ # dry_run: false,
164
+ # instance_id: "String", # required
165
+ # device: "String", # required
166
+ # })
167
+ # @param [Hash] options ({})
168
+ # @option options [Boolean] :dry_run
169
+ # Checks whether you have the required permissions for the action,
170
+ # without actually making the request, and provides an error response.
171
+ # If you have the required permissions, the error response is
172
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
173
+ # @option options [required, String] :instance_id
174
+ # The ID of the instance.
175
+ # @option options [required, String] :device
176
+ # The device name to expose to the instance (for example, `/dev/sdh` or
177
+ # `xvdh`).
178
+ # @return [Types::VolumeAttachment]
179
+ def attach_to_instance(options = {})
180
+ options = options.merge(volume_id: @id)
181
+ resp = @client.attach_volume(options)
182
+ resp.data
183
+ end
184
+
185
+ # @example Request syntax with placeholder values
186
+ #
187
+ # snapshot = volume.create_snapshot({
188
+ # dry_run: false,
189
+ # description: "String",
190
+ # })
191
+ # @param [Hash] options ({})
192
+ # @option options [Boolean] :dry_run
193
+ # Checks whether you have the required permissions for the action,
194
+ # without actually making the request, and provides an error response.
195
+ # If you have the required permissions, the error response is
196
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
197
+ # @option options [String] :description
198
+ # A description for the snapshot.
199
+ # @return [Snapshot]
200
+ def create_snapshot(options = {})
201
+ options = options.merge(volume_id: @id)
202
+ resp = @client.create_snapshot(options)
203
+ Snapshot.new(
204
+ id: resp.data.snapshot_id,
205
+ data: resp.data,
206
+ client: @client
207
+ )
208
+ end
209
+
210
+ # @example Request syntax with placeholder values
211
+ #
212
+ # tag = volume.create_tags({
213
+ # dry_run: false,
214
+ # tags: [ # required
215
+ # {
216
+ # key: "String",
217
+ # value: "String",
218
+ # },
219
+ # ],
220
+ # })
221
+ # @param [Hash] options ({})
222
+ # @option options [Boolean] :dry_run
223
+ # Checks whether you have the required permissions for the action,
224
+ # without actually making the request, and provides an error response.
225
+ # If you have the required permissions, the error response is
226
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
227
+ # @option options [required, Array<Types::Tag>] :tags
228
+ # One or more tags. The `value` parameter is required, but if you don't
229
+ # want the tag to have a value, specify the parameter with no value, and
230
+ # we set the value to an empty string.
231
+ # @return [Tag::Collection]
232
+ def create_tags(options = {})
233
+ batch = []
234
+ options = Aws::Util.deep_merge(options, resources: [@id])
235
+ resp = @client.create_tags(options)
236
+ options[:tags].each do |t|
237
+ batch << Tag.new(
238
+ resource_id: @id,
239
+ key: t[:key],
240
+ value: t[:value],
241
+ client: @client
242
+ )
243
+ end
244
+ Tag::Collection.new([batch], size: batch.size)
245
+ end
246
+
247
+ # @example Request syntax with placeholder values
248
+ #
249
+ # volume.delete({
250
+ # dry_run: false,
251
+ # })
252
+ # @param [Hash] options ({})
253
+ # @option options [Boolean] :dry_run
254
+ # Checks whether you have the required permissions for the action,
255
+ # without actually making the request, and provides an error response.
256
+ # If you have the required permissions, the error response is
257
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
258
+ # @return [EmptyStructure]
259
+ def delete(options = {})
260
+ options = options.merge(volume_id: @id)
261
+ resp = @client.delete_volume(options)
262
+ resp.data
263
+ end
264
+
265
+ # @example Request syntax with placeholder values
266
+ #
267
+ # volume.describe_attribute({
268
+ # dry_run: false,
269
+ # attribute: "autoEnableIO", # accepts autoEnableIO, productCodes
270
+ # })
271
+ # @param [Hash] options ({})
272
+ # @option options [Boolean] :dry_run
273
+ # Checks whether you have the required permissions for the action,
274
+ # without actually making the request, and provides an error response.
275
+ # If you have the required permissions, the error response is
276
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
277
+ # @option options [String] :attribute
278
+ # The instance attribute.
279
+ # @return [Types::DescribeVolumeAttributeResult]
280
+ def describe_attribute(options = {})
281
+ options = options.merge(volume_id: @id)
282
+ resp = @client.describe_volume_attribute(options)
283
+ resp.data
284
+ end
285
+
286
+ # @example Request syntax with placeholder values
287
+ #
288
+ # volume.describe_status({
289
+ # dry_run: false,
290
+ # filters: [
291
+ # {
292
+ # name: "String",
293
+ # values: ["String"],
294
+ # },
295
+ # ],
296
+ # next_token: "String",
297
+ # max_results: 1,
298
+ # })
299
+ # @param [Hash] options ({})
300
+ # @option options [Boolean] :dry_run
301
+ # Checks whether you have the required permissions for the action,
302
+ # without actually making the request, and provides an error response.
303
+ # If you have the required permissions, the error response is
304
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
305
+ # @option options [Array<Types::Filter>] :filters
306
+ # One or more filters.
307
+ #
308
+ # * `action.code` - The action code for the event (for example,
309
+ # `enable-volume-io`).
310
+ #
311
+ # * `action.description` - A description of the action.
312
+ #
313
+ # * `action.event-id` - The event ID associated with the action.
314
+ #
315
+ # * `availability-zone` - The Availability Zone of the instance.
316
+ #
317
+ # * `event.description` - A description of the event.
318
+ #
319
+ # * `event.event-id` - The event ID.
320
+ #
321
+ # * `event.event-type` - The event type (for `io-enabled`\: `passed` \|
322
+ # `failed`; for `io-performance`\: `io-performance:degraded` \|
323
+ # `io-performance:severely-degraded` \| `io-performance:stalled`).
324
+ #
325
+ # * `event.not-after` - The latest end time for the event.
326
+ #
327
+ # * `event.not-before` - The earliest start time for the event.
328
+ #
329
+ # * `volume-status.details-name` - The cause for `volume-status.status`
330
+ # (`io-enabled` \| `io-performance`).
331
+ #
332
+ # * `volume-status.details-status` - The status of
333
+ # `volume-status.details-name` (for `io-enabled`\: `passed` \|
334
+ # `failed`; for `io-performance`\: `normal` \| `degraded` \|
335
+ # `severely-degraded` \| `stalled`).
336
+ #
337
+ # * `volume-status.status` - The status of the volume (`ok` \|
338
+ # `impaired` \| `warning` \| `insufficient-data`).
339
+ # @option options [String] :next_token
340
+ # The `NextToken` value to include in a future `DescribeVolumeStatus`
341
+ # request. When the results of the request exceed `MaxResults`, this
342
+ # value can be used to retrieve the next page of results. This value is
343
+ # `null` when there are no more results to return.
344
+ # @option options [Integer] :max_results
345
+ # The maximum number of volume results returned by
346
+ # `DescribeVolumeStatus` in paginated output. When this parameter is
347
+ # used, the request only returns `MaxResults` results in a single page
348
+ # along with a `NextToken` response element. The remaining results of
349
+ # the initial request can be seen by sending another request with the
350
+ # returned `NextToken` value. This value can be between 5 and 1000; if
351
+ # `MaxResults` is given a value larger than 1000, only 1000 results are
352
+ # returned. If this parameter is not used, then `DescribeVolumeStatus`
353
+ # returns all results. You cannot specify this parameter and the volume
354
+ # IDs parameter in the same request.
355
+ # @return [Types::DescribeVolumeStatusResult]
356
+ def describe_status(options = {})
357
+ options = Aws::Util.deep_merge(options, volume_ids: [@id])
358
+ resp = @client.describe_volume_status(options)
359
+ resp.data
360
+ end
361
+
362
+ # @example Request syntax with placeholder values
363
+ #
364
+ # volume.detach_from_instance({
365
+ # dry_run: false,
366
+ # instance_id: "String",
367
+ # device: "String",
368
+ # force: false,
369
+ # })
370
+ # @param [Hash] options ({})
371
+ # @option options [Boolean] :dry_run
372
+ # Checks whether you have the required permissions for the action,
373
+ # without actually making the request, and provides an error response.
374
+ # If you have the required permissions, the error response is
375
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
376
+ # @option options [String] :instance_id
377
+ # The ID of the instance.
378
+ # @option options [String] :device
379
+ # The device name.
380
+ # @option options [Boolean] :force
381
+ # Forces detachment if the previous detachment attempt did not occur
382
+ # cleanly (for example, logging into an instance, unmounting the volume,
383
+ # and detaching normally). This option can lead to data loss or a
384
+ # corrupted file system. Use this option only as a last resort to detach
385
+ # a volume from a failed instance. The instance won't have an
386
+ # opportunity to flush file system caches or file system metadata. If
387
+ # you use this option, you must perform file system check and repair
388
+ # procedures.
389
+ # @return [Types::VolumeAttachment]
390
+ def detach_from_instance(options = {})
391
+ options = options.merge(volume_id: @id)
392
+ resp = @client.detach_volume(options)
393
+ resp.data
394
+ end
395
+
396
+ # @example Request syntax with placeholder values
397
+ #
398
+ # volume.enable_io({
399
+ # dry_run: false,
400
+ # })
401
+ # @param [Hash] options ({})
402
+ # @option options [Boolean] :dry_run
403
+ # Checks whether you have the required permissions for the action,
404
+ # without actually making the request, and provides an error response.
405
+ # If you have the required permissions, the error response is
406
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
407
+ # @return [EmptyStructure]
408
+ def enable_io(options = {})
409
+ options = options.merge(volume_id: @id)
410
+ resp = @client.enable_volume_io(options)
411
+ resp.data
412
+ end
413
+
414
+ # @example Request syntax with placeholder values
415
+ #
416
+ # volume.modify_attribute({
417
+ # dry_run: false,
418
+ # auto_enable_io: {
419
+ # value: false,
420
+ # },
421
+ # })
422
+ # @param [Hash] options ({})
423
+ # @option options [Boolean] :dry_run
424
+ # Checks whether you have the required permissions for the action,
425
+ # without actually making the request, and provides an error response.
426
+ # If you have the required permissions, the error response is
427
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
428
+ # @option options [Types::AttributeBooleanValue] :auto_enable_io
429
+ # Indicates whether the volume should be auto-enabled for I/O
430
+ # operations.
431
+ # @return [EmptyStructure]
432
+ def modify_attribute(options = {})
433
+ options = options.merge(volume_id: @id)
434
+ resp = @client.modify_volume_attribute(options)
435
+ resp.data
436
+ end
437
+
438
+ # @!group Associations
439
+
440
+ # @example Request syntax with placeholder values
441
+ #
442
+ # snapshots = volume.snapshots({
443
+ # dry_run: false,
444
+ # snapshot_ids: ["String"],
445
+ # owner_ids: ["String"],
446
+ # restorable_by_user_ids: ["String"],
447
+ # filters: [
448
+ # {
449
+ # name: "String",
450
+ # values: ["String"],
451
+ # },
452
+ # ],
453
+ # })
454
+ # @param [Hash] options ({})
455
+ # @option options [Boolean] :dry_run
456
+ # Checks whether you have the required permissions for the action,
457
+ # without actually making the request, and provides an error response.
458
+ # If you have the required permissions, the error response is
459
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
460
+ # @option options [Array<String>] :snapshot_ids
461
+ # One or more snapshot IDs.
462
+ #
463
+ # Default: Describes snapshots for which you have launch permissions.
464
+ # @option options [Array<String>] :owner_ids
465
+ # Returns the snapshots owned by the specified owner. Multiple owners
466
+ # can be specified.
467
+ # @option options [Array<String>] :restorable_by_user_ids
468
+ # One or more AWS accounts IDs that can create volumes from the
469
+ # snapshot.
470
+ # @option options [Array<Types::Filter>] :filters
471
+ # One or more filters.
472
+ #
473
+ # * `description` - A description of the snapshot.
474
+ #
475
+ # * `owner-alias` - Value from an Amazon-maintained list (`amazon` \|
476
+ # `aws-marketplace` \| `microsoft`) of snapshot owners. Not to be
477
+ # confused with the user-configured AWS account alias, which is set
478
+ # from the IAM consolew.
479
+ #
480
+ # * `owner-id` - The ID of the AWS account that owns the snapshot.
481
+ #
482
+ # * `progress` - The progress of the snapshot, as a percentage (for
483
+ # example, 80%).
484
+ #
485
+ # * `snapshot-id` - The snapshot ID.
486
+ #
487
+ # * `start-time` - The time stamp when the snapshot was initiated.
488
+ #
489
+ # * `status` - The status of the snapshot (`pending` \| `completed` \|
490
+ # `error`).
491
+ #
492
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
493
+ # to the resource.
494
+ #
495
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
496
+ # is independent of the `tag-value` filter. For example, if you use
497
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
498
+ # you get any resources assigned both the tag key Purpose (regardless
499
+ # of what the tag's value is), and the tag value X (regardless of
500
+ # what the tag's key is). If you want to list only resources where
501
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
502
+ #
503
+ # * `tag-value` - The value of a tag assigned to the resource. This
504
+ # filter is independent of the `tag-key` filter.
505
+ #
506
+ # * `volume-id` - The ID of the volume the snapshot is for.
507
+ #
508
+ # * `volume-size` - The size of the volume, in GiB.
509
+ # @return [Snapshot::Collection]
510
+ def snapshots(options = {})
511
+ batches = Enumerator.new do |y|
512
+ options = Aws::Util.deep_merge(options, filters: [{
513
+ name: "volume-id",
514
+ values: [@id]
515
+ }])
516
+ resp = @client.describe_snapshots(options)
517
+ resp.each_page do |page|
518
+ batch = []
519
+ page.data.snapshots.each do |s|
520
+ batch << Snapshot.new(
521
+ id: s.snapshot_id,
522
+ data: s,
523
+ client: @client
524
+ )
525
+ end
526
+ y.yield(batch)
527
+ end
528
+ end
529
+ Snapshot::Collection.new(batches)
530
+ end
531
+
532
+ # @deprecated
533
+ # @api private
534
+ def identifiers
535
+ { id: @id }
536
+ end
537
+ deprecated(:identifiers)
538
+
539
+ private
540
+
541
+ def extract_id(args, options)
542
+ value = args[0] || options.delete(:id)
543
+ case value
544
+ when String then value
545
+ when nil then raise ArgumentError, "missing required option :id"
546
+ else
547
+ msg = "expected :id to be a String, got #{value.class}"
548
+ raise ArgumentError, msg
549
+ end
550
+ end
551
+
552
+ class Collection < Aws::Resources::Collection; end
553
+ end
554
+ end
555
+ end