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,478 @@
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 Snapshot
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 :snapshot_id :id
34
+
35
+ # The ID of the volume that was used to create the snapshot. Snapshots
36
+ # created by the CopySnapshot action have an arbitrary volume ID that
37
+ # should not be used for any purpose.
38
+ # @return [String]
39
+ def volume_id
40
+ data.volume_id
41
+ end
42
+
43
+ # The snapshot state.
44
+ # @return [String]
45
+ def state
46
+ data.state
47
+ end
48
+
49
+ # Encrypted Amazon EBS snapshots are copied asynchronously. If a
50
+ # snapshot copy operation fails (for example, if the proper AWS Key
51
+ # Management Service (AWS KMS) permissions are not obtained) this field
52
+ # displays error state details to help you diagnose why the error
53
+ # occurred. This parameter is only returned by the DescribeSnapshots API
54
+ # operation.
55
+ # @return [String]
56
+ def state_message
57
+ data.state_message
58
+ end
59
+
60
+ # The time stamp when the snapshot was initiated.
61
+ # @return [Time]
62
+ def start_time
63
+ data.start_time
64
+ end
65
+
66
+ # The progress of the snapshot, as a percentage.
67
+ # @return [String]
68
+ def progress
69
+ data.progress
70
+ end
71
+
72
+ # The AWS account ID of the EBS snapshot owner.
73
+ # @return [String]
74
+ def owner_id
75
+ data.owner_id
76
+ end
77
+
78
+ # The description for the snapshot.
79
+ # @return [String]
80
+ def description
81
+ data.description
82
+ end
83
+
84
+ # The size of the volume, in GiB.
85
+ # @return [Integer]
86
+ def volume_size
87
+ data.volume_size
88
+ end
89
+
90
+ # Value from an Amazon-maintained list (`amazon` \| `aws-marketplace` \|
91
+ # `microsoft`) of snapshot owners. Not to be confused with the
92
+ # user-configured AWS account alias, which is set from the IAM console.
93
+ # @return [String]
94
+ def owner_alias
95
+ data.owner_alias
96
+ end
97
+
98
+ # Any tags assigned to the snapshot.
99
+ # @return [Array<Types::Tag>]
100
+ def tags
101
+ data.tags
102
+ end
103
+
104
+ # Indicates whether the snapshot is encrypted.
105
+ # @return [Boolean]
106
+ def encrypted
107
+ data.encrypted
108
+ end
109
+
110
+ # The full ARN of the AWS Key Management Service (AWS KMS) customer
111
+ # master key (CMK) that was used to protect the volume encryption key
112
+ # for the parent volume.
113
+ # @return [String]
114
+ def kms_key_id
115
+ data.kms_key_id
116
+ end
117
+
118
+ # The data encryption key identifier for the snapshot. This value is a
119
+ # unique identifier that corresponds to the data encryption key that was
120
+ # used to encrypt the original volume or snapshot copy. Because data
121
+ # encryption keys are inherited by volumes created from snapshots, and
122
+ # vice versa, if snapshots share the same data encryption key
123
+ # identifier, then they belong to the same volume/snapshot lineage. This
124
+ # parameter is only returned by the DescribeSnapshots API operation.
125
+ # @return [String]
126
+ def data_encryption_key_id
127
+ data.data_encryption_key_id
128
+ end
129
+
130
+ # @!endgroup
131
+
132
+ # @return [Client]
133
+ def client
134
+ @client
135
+ end
136
+
137
+ # Loads, or reloads {#data} for the current {Snapshot}.
138
+ # Returns `self` making it possible to chain methods.
139
+ #
140
+ # snapshot.reload.data
141
+ #
142
+ # @return [self]
143
+ def load
144
+ resp = @client.describe_snapshots(snapshot_ids: [@id])
145
+ @data = resp.snapshots[0]
146
+ self
147
+ end
148
+ alias :reload :load
149
+
150
+ # @return [Types::Snapshot]
151
+ # Returns the data for this {Snapshot}. Calls
152
+ # {Client#describe_snapshots} if {#data_loaded?} is `false`.
153
+ def data
154
+ load unless @data
155
+ @data
156
+ end
157
+
158
+ # @return [Boolean]
159
+ # Returns `true` if this resource is loaded. Accessing attributes or
160
+ # {#data} on an unloaded resource will trigger a call to {#load}.
161
+ def data_loaded?
162
+ !!@data
163
+ end
164
+
165
+ # @param [Hash] options ({})
166
+ # @option options [Integer] :max_attempts (40)
167
+ # @option options [Float] :delay (15)
168
+ # @option options [Proc] :before_attempt
169
+ # @option options [Proc] :before_wait
170
+ # @return [Snapshot]
171
+ def wait_until_completed(options = {})
172
+ options, params = separate_params_and_options(options)
173
+ waiter = Waiters::SnapshotCompleted.new(options)
174
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
175
+ resp = waiter.wait(params.merge(snapshot_ids: [@id]))
176
+ Snapshot.new({
177
+ id: @id,
178
+ data: resp.data.snapshots[],
179
+ client: @client
180
+ })
181
+ end
182
+
183
+ # @!group Actions
184
+
185
+ # @example Request syntax with placeholder values
186
+ #
187
+ # snapshot.copy({
188
+ # dry_run: false,
189
+ # source_region: "String", # required
190
+ # description: "String",
191
+ # destination_region: "String",
192
+ # presigned_url: "String",
193
+ # encrypted: false,
194
+ # kms_key_id: "String",
195
+ # })
196
+ # @param [Hash] options ({})
197
+ # @option options [Boolean] :dry_run
198
+ # Checks whether you have the required permissions for the action,
199
+ # without actually making the request, and provides an error response.
200
+ # If you have the required permissions, the error response is
201
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
202
+ # @option options [required, String] :source_region
203
+ # The ID of the region that contains the snapshot to be copied.
204
+ # @option options [String] :description
205
+ # A description for the EBS snapshot.
206
+ # @option options [String] :destination_region
207
+ # The destination region to use in the `PresignedUrl` parameter of a
208
+ # snapshot copy operation. This parameter is only valid for specifying
209
+ # the destination region in a `PresignedUrl` parameter, where it is
210
+ # required.
211
+ #
212
+ # <note markdown="1"> `CopySnapshot` sends the snapshot copy to the regional endpoint that
213
+ # you send the HTTP request to, such as `ec2.us-east-1.amazonaws.com`
214
+ # (in the AWS CLI, this is specified with the `--region` parameter or
215
+ # the default region in your AWS configuration file).
216
+ #
217
+ # </note>
218
+ # @option options [String] :presigned_url
219
+ # The pre-signed URL that facilitates copying an encrypted snapshot.
220
+ # This parameter is only required when copying an encrypted snapshot
221
+ # with the Amazon EC2 Query API; it is available as an optional
222
+ # parameter in all other cases. The `PresignedUrl` should use the
223
+ # snapshot source endpoint, the `CopySnapshot` action, and include the
224
+ # `SourceRegion`, `SourceSnapshotId`, and `DestinationRegion`
225
+ # parameters. The `PresignedUrl` must be signed using AWS Signature
226
+ # Version 4. Because EBS snapshots are stored in Amazon S3, the signing
227
+ # algorithm for this parameter uses the same logic that is described in
228
+ # [Authenticating Requests by Using Query Parameters (AWS Signature
229
+ # Version 4)][1] in the *Amazon Simple Storage Service API Reference*.
230
+ # An invalid or improperly signed `PresignedUrl` will cause the copy
231
+ # operation to fail asynchronously, and the snapshot will move to an
232
+ # `error` state.
233
+ #
234
+ #
235
+ #
236
+ # [1]: http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
237
+ # @option options [Boolean] :encrypted
238
+ # Specifies whether the destination snapshot should be encrypted. You
239
+ # can encrypt a copy of an unencrypted snapshot using this flag, but you
240
+ # cannot use it to create an unencrypted copy from an encrypted
241
+ # snapshot. Your default CMK for EBS is used unless a non-default AWS
242
+ # Key Management Service (AWS KMS) CMK is specified with `KmsKeyId`. For
243
+ # more information, see [Amazon EBS Encryption][1] in the *Amazon
244
+ # Elastic Compute Cloud User Guide*.
245
+ #
246
+ #
247
+ #
248
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html
249
+ # @option options [String] :kms_key_id
250
+ # The full ARN of the AWS Key Management Service (AWS KMS) CMK to use
251
+ # when creating the snapshot copy. This parameter is only required if
252
+ # you want to use a non-default CMK; if this parameter is not specified,
253
+ # the default CMK for EBS is used. The ARN contains the `arn:aws:kms`
254
+ # namespace, followed by the region of the CMK, the AWS account ID of
255
+ # the CMK owner, the `key` namespace, and then the CMK ID. For example,
256
+ # arn:aws:kms:*us-east-1*\:*012345678910*\:key/*abcd1234-a123-456a-a12b-a123b4cd56ef*.
257
+ # The specified CMK must exist in the region that the snapshot is being
258
+ # copied to. If a `KmsKeyId` is specified, the `Encrypted` flag must
259
+ # also be set.
260
+ # @return [Types::CopySnapshotResult]
261
+ def copy(options = {})
262
+ options = options.merge(source_snapshot_id: @id)
263
+ resp = @client.copy_snapshot(options)
264
+ resp.data
265
+ end
266
+
267
+ # @example Request syntax with placeholder values
268
+ #
269
+ # tag = snapshot.create_tags({
270
+ # dry_run: false,
271
+ # tags: [ # required
272
+ # {
273
+ # key: "String",
274
+ # value: "String",
275
+ # },
276
+ # ],
277
+ # })
278
+ # @param [Hash] options ({})
279
+ # @option options [Boolean] :dry_run
280
+ # Checks whether you have the required permissions for the action,
281
+ # without actually making the request, and provides an error response.
282
+ # If you have the required permissions, the error response is
283
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
284
+ # @option options [required, Array<Types::Tag>] :tags
285
+ # One or more tags. The `value` parameter is required, but if you don't
286
+ # want the tag to have a value, specify the parameter with no value, and
287
+ # we set the value to an empty string.
288
+ # @return [Tag::Collection]
289
+ def create_tags(options = {})
290
+ batch = []
291
+ options = Aws::Util.deep_merge(options, resources: [@id])
292
+ resp = @client.create_tags(options)
293
+ options[:tags].each do |t|
294
+ batch << Tag.new(
295
+ resource_id: @id,
296
+ key: t[:key],
297
+ value: t[:value],
298
+ client: @client
299
+ )
300
+ end
301
+ Tag::Collection.new([batch], size: batch.size)
302
+ end
303
+
304
+ # @example Request syntax with placeholder values
305
+ #
306
+ # snapshot.delete({
307
+ # dry_run: false,
308
+ # })
309
+ # @param [Hash] options ({})
310
+ # @option options [Boolean] :dry_run
311
+ # Checks whether you have the required permissions for the action,
312
+ # without actually making the request, and provides an error response.
313
+ # If you have the required permissions, the error response is
314
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
315
+ # @return [EmptyStructure]
316
+ def delete(options = {})
317
+ options = options.merge(snapshot_id: @id)
318
+ resp = @client.delete_snapshot(options)
319
+ resp.data
320
+ end
321
+
322
+ # @example Request syntax with placeholder values
323
+ #
324
+ # snapshot.describe_attribute({
325
+ # dry_run: false,
326
+ # attribute: "productCodes", # required, accepts productCodes, createVolumePermission
327
+ # })
328
+ # @param [Hash] options ({})
329
+ # @option options [Boolean] :dry_run
330
+ # Checks whether you have the required permissions for the action,
331
+ # without actually making the request, and provides an error response.
332
+ # If you have the required permissions, the error response is
333
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
334
+ # @option options [required, String] :attribute
335
+ # The snapshot attribute you would like to view.
336
+ # @return [Types::DescribeSnapshotAttributeResult]
337
+ def describe_attribute(options = {})
338
+ options = options.merge(snapshot_id: @id)
339
+ resp = @client.describe_snapshot_attribute(options)
340
+ resp.data
341
+ end
342
+
343
+ # @example Request syntax with placeholder values
344
+ #
345
+ # snapshot.modify_attribute({
346
+ # dry_run: false,
347
+ # attribute: "productCodes", # accepts productCodes, createVolumePermission
348
+ # operation_type: "add", # accepts add, remove
349
+ # user_ids: ["String"],
350
+ # group_names: ["String"],
351
+ # create_volume_permission: {
352
+ # add: [
353
+ # {
354
+ # user_id: "String",
355
+ # group: "all", # accepts all
356
+ # },
357
+ # ],
358
+ # remove: [
359
+ # {
360
+ # user_id: "String",
361
+ # group: "all", # accepts all
362
+ # },
363
+ # ],
364
+ # },
365
+ # })
366
+ # @param [Hash] options ({})
367
+ # @option options [Boolean] :dry_run
368
+ # Checks whether you have the required permissions for the action,
369
+ # without actually making the request, and provides an error response.
370
+ # If you have the required permissions, the error response is
371
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
372
+ # @option options [String] :attribute
373
+ # The snapshot attribute to modify.
374
+ #
375
+ # <note markdown="1"> Only volume creation permissions may be modified at the customer
376
+ # level.
377
+ #
378
+ # </note>
379
+ # @option options [String] :operation_type
380
+ # The type of operation to perform to the attribute.
381
+ # @option options [Array<String>] :user_ids
382
+ # The account ID to modify for the snapshot.
383
+ # @option options [Array<String>] :group_names
384
+ # The group to modify for the snapshot.
385
+ # @option options [Types::CreateVolumePermissionModifications] :create_volume_permission
386
+ # A JSON representation of the snapshot attribute modification.
387
+ # @return [EmptyStructure]
388
+ def modify_attribute(options = {})
389
+ options = options.merge(snapshot_id: @id)
390
+ resp = @client.modify_snapshot_attribute(options)
391
+ resp.data
392
+ end
393
+
394
+ # @example Request syntax with placeholder values
395
+ #
396
+ # snapshot.reset_attribute({
397
+ # dry_run: false,
398
+ # attribute: "productCodes", # required, accepts productCodes, createVolumePermission
399
+ # })
400
+ # @param [Hash] options ({})
401
+ # @option options [Boolean] :dry_run
402
+ # Checks whether you have the required permissions for the action,
403
+ # without actually making the request, and provides an error response.
404
+ # If you have the required permissions, the error response is
405
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
406
+ # @option options [required, String] :attribute
407
+ # The attribute to reset. Currently, only the attribute for permission
408
+ # to create volumes can be reset.
409
+ # @return [EmptyStructure]
410
+ def reset_attribute(options = {})
411
+ options = options.merge(snapshot_id: @id)
412
+ resp = @client.reset_snapshot_attribute(options)
413
+ resp.data
414
+ end
415
+
416
+ # @!group Associations
417
+
418
+ # @return [Volume, nil]
419
+ def volume
420
+ if data.volume_id
421
+ Volume.new(
422
+ id: data.volume_id,
423
+ client: @client
424
+ )
425
+ else
426
+ nil
427
+ end
428
+ end
429
+
430
+ # @deprecated
431
+ # @api private
432
+ def identifiers
433
+ { id: @id }
434
+ end
435
+ deprecated(:identifiers)
436
+
437
+ private
438
+
439
+ def extract_id(args, options)
440
+ value = args[0] || options.delete(:id)
441
+ case value
442
+ when String then value
443
+ when nil then raise ArgumentError, "missing required option :id"
444
+ else
445
+ msg = "expected :id to be a String, got #{value.class}"
446
+ raise ArgumentError, msg
447
+ end
448
+ end
449
+
450
+ def yield_waiter_and_warn(waiter, &block)
451
+ if !@waiter_block_warned
452
+ msg = "pass options to configure the waiter; "
453
+ msg << "yielding the waiter is deprecated"
454
+ warn(msg)
455
+ @waiter_block_warned = true
456
+ end
457
+ yield(waiter.waiter)
458
+ end
459
+
460
+ def separate_params_and_options(options)
461
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
462
+ waiter_opts = {}
463
+ waiter_params = {}
464
+ options.each_pair do |key, value|
465
+ if opts.include?(key)
466
+ waiter_opts[key] = value
467
+ else
468
+ waiter_params[key] = value
469
+ end
470
+ end
471
+ waiter_opts[:client] ||= @client
472
+ [waiter_opts, waiter_params]
473
+ end
474
+
475
+ class Collection < Aws::Resources::Collection; end
476
+ end
477
+ end
478
+ end