aws-sdk-resources 2.11.632 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/aws-sdk-resources.rb +1 -91
- metadata +14 -85
- data/lib/aws-sdk-resources/batch.rb +0 -143
- data/lib/aws-sdk-resources/builder.rb +0 -85
- data/lib/aws-sdk-resources/builder_sources.rb +0 -105
- data/lib/aws-sdk-resources/collection.rb +0 -107
- data/lib/aws-sdk-resources/definition.rb +0 -331
- data/lib/aws-sdk-resources/documenter.rb +0 -70
- data/lib/aws-sdk-resources/documenter/base_operation_documenter.rb +0 -279
- data/lib/aws-sdk-resources/documenter/data_operation_documenter.rb +0 -25
- data/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb +0 -69
- data/lib/aws-sdk-resources/documenter/has_operation_documenter.rb +0 -66
- data/lib/aws-sdk-resources/documenter/operation_documenter.rb +0 -20
- data/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb +0 -53
- data/lib/aws-sdk-resources/documenter/waiter_operation_documenter.rb +0 -77
- data/lib/aws-sdk-resources/errors.rb +0 -15
- data/lib/aws-sdk-resources/operation_methods.rb +0 -83
- data/lib/aws-sdk-resources/operations.rb +0 -280
- data/lib/aws-sdk-resources/options.rb +0 -17
- data/lib/aws-sdk-resources/request.rb +0 -39
- data/lib/aws-sdk-resources/request_params.rb +0 -140
- data/lib/aws-sdk-resources/resource.rb +0 -243
- data/lib/aws-sdk-resources/services/ec2.rb +0 -21
- data/lib/aws-sdk-resources/services/ec2/instance.rb +0 -29
- data/lib/aws-sdk-resources/services/iam.rb +0 -19
- data/lib/aws-sdk-resources/services/s3.rb +0 -21
- data/lib/aws-sdk-resources/services/s3/bucket.rb +0 -131
- data/lib/aws-sdk-resources/services/s3/encryption.rb +0 -24
- data/lib/aws-sdk-resources/services/s3/encryption/client.rb +0 -386
- data/lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb +0 -225
- data/lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb +0 -101
- data/lib/aws-sdk-resources/services/s3/encryption/default_key_provider.rb +0 -40
- data/lib/aws-sdk-resources/services/s3/encryption/encrypt_handler.rb +0 -61
- data/lib/aws-sdk-resources/services/s3/encryption/errors.rb +0 -15
- data/lib/aws-sdk-resources/services/s3/encryption/io_auth_decrypter.rb +0 -58
- data/lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb +0 -37
- data/lib/aws-sdk-resources/services/s3/encryption/io_encrypter.rb +0 -71
- data/lib/aws-sdk-resources/services/s3/encryption/key_provider.rb +0 -31
- data/lib/aws-sdk-resources/services/s3/encryption/kms_cipher_provider.rb +0 -104
- data/lib/aws-sdk-resources/services/s3/encryption/materials.rb +0 -60
- data/lib/aws-sdk-resources/services/s3/encryption/utils.rb +0 -104
- data/lib/aws-sdk-resources/services/s3/encryptionV2/client.rb +0 -561
- data/lib/aws-sdk-resources/services/s3/encryptionV2/decrypt_handler.rb +0 -214
- data/lib/aws-sdk-resources/services/s3/encryptionV2/default_cipher_provider.rb +0 -170
- data/lib/aws-sdk-resources/services/s3/encryptionV2/default_key_provider.rb +0 -40
- data/lib/aws-sdk-resources/services/s3/encryptionV2/encrypt_handler.rb +0 -69
- data/lib/aws-sdk-resources/services/s3/encryptionV2/errors.rb +0 -37
- data/lib/aws-sdk-resources/services/s3/encryptionV2/io_auth_decrypter.rb +0 -58
- data/lib/aws-sdk-resources/services/s3/encryptionV2/io_decrypter.rb +0 -37
- data/lib/aws-sdk-resources/services/s3/encryptionV2/io_encrypter.rb +0 -73
- data/lib/aws-sdk-resources/services/s3/encryptionV2/key_provider.rb +0 -31
- data/lib/aws-sdk-resources/services/s3/encryptionV2/kms_cipher_provider.rb +0 -169
- data/lib/aws-sdk-resources/services/s3/encryptionV2/materials.rb +0 -60
- data/lib/aws-sdk-resources/services/s3/encryptionV2/utils.rb +0 -103
- data/lib/aws-sdk-resources/services/s3/encryption_v2.rb +0 -24
- data/lib/aws-sdk-resources/services/s3/file_downloader.rb +0 -169
- data/lib/aws-sdk-resources/services/s3/file_part.rb +0 -75
- data/lib/aws-sdk-resources/services/s3/file_uploader.rb +0 -58
- data/lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb +0 -187
- data/lib/aws-sdk-resources/services/s3/multipart_upload.rb +0 -42
- data/lib/aws-sdk-resources/services/s3/multipart_upload_error.rb +0 -16
- data/lib/aws-sdk-resources/services/s3/object.rb +0 -290
- data/lib/aws-sdk-resources/services/s3/object_copier.rb +0 -99
- data/lib/aws-sdk-resources/services/s3/object_multipart_copier.rb +0 -180
- data/lib/aws-sdk-resources/services/s3/object_summary.rb +0 -73
- data/lib/aws-sdk-resources/services/s3/presigned_post.rb +0 -651
- data/lib/aws-sdk-resources/services/sns.rb +0 -7
- data/lib/aws-sdk-resources/services/sns/message_verifier.rb +0 -171
- data/lib/aws-sdk-resources/services/sqs.rb +0 -7
- data/lib/aws-sdk-resources/services/sqs/queue_poller.rb +0 -521
- data/lib/aws-sdk-resources/source.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b87eb4edb3eb3717fc868b1be12ff529d8d70c1a
|
4
|
+
data.tar.gz: 5e35c989e84d6722afb272ed2e1a4f288cb20c28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d9c2a34ff74c9be846361dd9e46dc9b3edd8bbe537dde5714930184cfe51aa8ecaa761f8273a1d74cc8e603eb83f65b97b30fda6dce4ce86ea9d543c1763f2
|
7
|
+
data.tar.gz: fbdf4f5ea6e7177174c645ad1bc304d39f5ea011b76c1e05a6daf4f3ba1f722fd58155277bfad3776dd687d315698f5be6e8094dc4321f2c46bc237e26905d18
|
data/lib/aws-sdk-resources.rb
CHANGED
@@ -1,91 +1 @@
|
|
1
|
-
require 'aws-sdk
|
2
|
-
|
3
|
-
module Aws
|
4
|
-
|
5
|
-
module Resources
|
6
|
-
autoload :Batch, 'aws-sdk-resources/batch'
|
7
|
-
autoload :Builder, 'aws-sdk-resources/builder'
|
8
|
-
autoload :BuilderSources, 'aws-sdk-resources/builder_sources'
|
9
|
-
autoload :Collection, 'aws-sdk-resources/collection'
|
10
|
-
autoload :Definition, 'aws-sdk-resources/definition'
|
11
|
-
autoload :Documenter, 'aws-sdk-resources/documenter'
|
12
|
-
autoload :Errors, 'aws-sdk-resources/errors'
|
13
|
-
autoload :OperationMethods, 'aws-sdk-resources/operation_methods'
|
14
|
-
autoload :Operations, 'aws-sdk-resources/operations'
|
15
|
-
autoload :Options, 'aws-sdk-resources/options'
|
16
|
-
autoload :Request, 'aws-sdk-resources/request'
|
17
|
-
autoload :RequestParams, 'aws-sdk-resources/request_params'
|
18
|
-
autoload :Resource, 'aws-sdk-resources/resource'
|
19
|
-
autoload :Source, 'aws-sdk-resources/source'
|
20
|
-
end
|
21
|
-
|
22
|
-
service_added do |name, svc_module, options|
|
23
|
-
definition = options[:resources]
|
24
|
-
definition = case definition
|
25
|
-
when nil then Resources::Definition.new({})
|
26
|
-
when Resources::Definition then definition
|
27
|
-
when Hash then Resources::Definition.new(definition)
|
28
|
-
when String
|
29
|
-
Resources::Definition.new(Json.load_file(definition), source_path: definition)
|
30
|
-
else raise ArgumentError, "invalid resource definition #{definition}"
|
31
|
-
end
|
32
|
-
definition.apply(svc_module)
|
33
|
-
|
34
|
-
# load customizations
|
35
|
-
svc = File.join(
|
36
|
-
File.dirname(__FILE__),
|
37
|
-
'aws-sdk-resources',
|
38
|
-
'services',
|
39
|
-
"#{name.downcase}.rb")
|
40
|
-
|
41
|
-
require(svc) if File.exist?(svc)
|
42
|
-
end
|
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, correct_name|
|
68
|
-
Resources::Operations::DeprecatedOperation.define({
|
69
|
-
resource_class: EC2::Instance,
|
70
|
-
deprecated_name: deprecated_name,
|
71
|
-
name: correct_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
|
-
|
91
|
-
end
|
1
|
+
require 'aws-sdk'
|
metadata
CHANGED
@@ -1,33 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.rc1
|
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:
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws-sdk
|
14
|
+
name: aws-sdk
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0.rc8
|
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:
|
27
|
-
description:
|
28
|
-
AWS
|
29
|
-
|
30
|
-
Ruby.
|
26
|
+
version: 3.0.0.rc8
|
27
|
+
description: Provides resource oriented interfaces and other higher-level abstractions
|
28
|
+
for many AWS services. For Versions >= 3, please switch to `aws-sdk` or individual
|
29
|
+
service gems.
|
31
30
|
email:
|
32
31
|
- trevrowe@amazon.com
|
33
32
|
executables: []
|
@@ -35,81 +34,11 @@ extensions: []
|
|
35
34
|
extra_rdoc_files: []
|
36
35
|
files:
|
37
36
|
- lib/aws-sdk-resources.rb
|
38
|
-
- lib/aws-sdk-resources/batch.rb
|
39
|
-
- lib/aws-sdk-resources/builder.rb
|
40
|
-
- lib/aws-sdk-resources/builder_sources.rb
|
41
|
-
- lib/aws-sdk-resources/collection.rb
|
42
|
-
- lib/aws-sdk-resources/definition.rb
|
43
|
-
- lib/aws-sdk-resources/documenter.rb
|
44
|
-
- lib/aws-sdk-resources/documenter/base_operation_documenter.rb
|
45
|
-
- lib/aws-sdk-resources/documenter/data_operation_documenter.rb
|
46
|
-
- lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb
|
47
|
-
- lib/aws-sdk-resources/documenter/has_operation_documenter.rb
|
48
|
-
- lib/aws-sdk-resources/documenter/operation_documenter.rb
|
49
|
-
- lib/aws-sdk-resources/documenter/resource_operation_documenter.rb
|
50
|
-
- lib/aws-sdk-resources/documenter/waiter_operation_documenter.rb
|
51
|
-
- lib/aws-sdk-resources/errors.rb
|
52
|
-
- lib/aws-sdk-resources/operation_methods.rb
|
53
|
-
- lib/aws-sdk-resources/operations.rb
|
54
|
-
- lib/aws-sdk-resources/options.rb
|
55
|
-
- lib/aws-sdk-resources/request.rb
|
56
|
-
- lib/aws-sdk-resources/request_params.rb
|
57
|
-
- lib/aws-sdk-resources/resource.rb
|
58
|
-
- lib/aws-sdk-resources/services/ec2.rb
|
59
|
-
- lib/aws-sdk-resources/services/ec2/instance.rb
|
60
|
-
- lib/aws-sdk-resources/services/iam.rb
|
61
|
-
- lib/aws-sdk-resources/services/s3.rb
|
62
|
-
- lib/aws-sdk-resources/services/s3/bucket.rb
|
63
|
-
- lib/aws-sdk-resources/services/s3/encryption.rb
|
64
|
-
- lib/aws-sdk-resources/services/s3/encryption/client.rb
|
65
|
-
- lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb
|
66
|
-
- lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb
|
67
|
-
- lib/aws-sdk-resources/services/s3/encryption/default_key_provider.rb
|
68
|
-
- lib/aws-sdk-resources/services/s3/encryption/encrypt_handler.rb
|
69
|
-
- lib/aws-sdk-resources/services/s3/encryption/errors.rb
|
70
|
-
- lib/aws-sdk-resources/services/s3/encryption/io_auth_decrypter.rb
|
71
|
-
- lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb
|
72
|
-
- lib/aws-sdk-resources/services/s3/encryption/io_encrypter.rb
|
73
|
-
- lib/aws-sdk-resources/services/s3/encryption/key_provider.rb
|
74
|
-
- lib/aws-sdk-resources/services/s3/encryption/kms_cipher_provider.rb
|
75
|
-
- lib/aws-sdk-resources/services/s3/encryption/materials.rb
|
76
|
-
- lib/aws-sdk-resources/services/s3/encryption/utils.rb
|
77
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/client.rb
|
78
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/decrypt_handler.rb
|
79
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/default_cipher_provider.rb
|
80
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/default_key_provider.rb
|
81
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/encrypt_handler.rb
|
82
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/errors.rb
|
83
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/io_auth_decrypter.rb
|
84
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/io_decrypter.rb
|
85
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/io_encrypter.rb
|
86
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/key_provider.rb
|
87
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/kms_cipher_provider.rb
|
88
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/materials.rb
|
89
|
-
- lib/aws-sdk-resources/services/s3/encryptionV2/utils.rb
|
90
|
-
- lib/aws-sdk-resources/services/s3/encryption_v2.rb
|
91
|
-
- lib/aws-sdk-resources/services/s3/file_downloader.rb
|
92
|
-
- lib/aws-sdk-resources/services/s3/file_part.rb
|
93
|
-
- lib/aws-sdk-resources/services/s3/file_uploader.rb
|
94
|
-
- lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb
|
95
|
-
- lib/aws-sdk-resources/services/s3/multipart_upload.rb
|
96
|
-
- lib/aws-sdk-resources/services/s3/multipart_upload_error.rb
|
97
|
-
- lib/aws-sdk-resources/services/s3/object.rb
|
98
|
-
- lib/aws-sdk-resources/services/s3/object_copier.rb
|
99
|
-
- lib/aws-sdk-resources/services/s3/object_multipart_copier.rb
|
100
|
-
- lib/aws-sdk-resources/services/s3/object_summary.rb
|
101
|
-
- lib/aws-sdk-resources/services/s3/presigned_post.rb
|
102
|
-
- lib/aws-sdk-resources/services/sns.rb
|
103
|
-
- lib/aws-sdk-resources/services/sns/message_verifier.rb
|
104
|
-
- lib/aws-sdk-resources/services/sqs.rb
|
105
|
-
- lib/aws-sdk-resources/services/sqs/queue_poller.rb
|
106
|
-
- lib/aws-sdk-resources/source.rb
|
107
37
|
homepage: http://github.com/aws/aws-sdk-ruby
|
108
38
|
licenses:
|
109
|
-
- Apache
|
39
|
+
- Apache-2.0
|
110
40
|
metadata: {}
|
111
|
-
post_install_message:
|
112
|
-
to AWS SDK For Ruby V3.
|
41
|
+
post_install_message:
|
113
42
|
rdoc_options: []
|
114
43
|
require_paths:
|
115
44
|
- lib
|
@@ -120,13 +49,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
49
|
version: '0'
|
121
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
51
|
requirements:
|
123
|
-
- - "
|
52
|
+
- - ">"
|
124
53
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
54
|
+
version: 1.3.1
|
126
55
|
requirements: []
|
127
56
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.5.1
|
129
58
|
signing_key:
|
130
59
|
specification_version: 4
|
131
|
-
summary: AWS SDK for Ruby
|
60
|
+
summary: AWS SDK for Ruby
|
132
61
|
test_files: []
|
@@ -1,143 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Resources
|
3
|
-
|
4
|
-
# A batch provides array like access to a list of resources. Batches
|
5
|
-
# also provide the ability to invoke certain operations against
|
6
|
-
# the entire batch.
|
7
|
-
#
|
8
|
-
# ## Getting a Batch
|
9
|
-
#
|
10
|
-
# You should normally not need to construct a batch. Anywhere a list
|
11
|
-
# of resources is returned, they are returned as a batch:
|
12
|
-
#
|
13
|
-
# # security_groups is a batch
|
14
|
-
# security_groups = ec2.instance('i-12345678').security_groups
|
15
|
-
#
|
16
|
-
# When the possible number of resources is unknown or large, the
|
17
|
-
# resources will be returned in a collection. Collections can enumerate
|
18
|
-
# individual resources or batches. They manage paging over the
|
19
|
-
# AWS request/responses to produce batches.
|
20
|
-
#
|
21
|
-
# # objects is a collection
|
22
|
-
# objects = s3.bucket('aws-sdk').objects
|
23
|
-
#
|
24
|
-
# You can invoke batch operations against collections and they will
|
25
|
-
# invoke them on each batch.
|
26
|
-
#
|
27
|
-
# # delete all objects in this bucket in batches of 1k
|
28
|
-
# objects = s3.bucket('aws-sdk').objects
|
29
|
-
# objects.delete
|
30
|
-
#
|
31
|
-
# ## Batch Operations
|
32
|
-
#
|
33
|
-
# Batches provide operations that operate on the entire batch. These
|
34
|
-
# operations are only defined for resources where the AWS API accepts
|
35
|
-
# multiple inputs. This means a batch operation for n resources will
|
36
|
-
# only make one request.
|
37
|
-
#
|
38
|
-
# Resource classes document each of their own batch operations.
|
39
|
-
# See {S3::Object} for an example.
|
40
|
-
#
|
41
|
-
class Batch
|
42
|
-
|
43
|
-
include Enumerable
|
44
|
-
|
45
|
-
# @param [Array<Resource>] resources
|
46
|
-
# @option options [Seahorse::Client::Response] :response
|
47
|
-
def initialize(resource_class, resources, options = {})
|
48
|
-
@resource_class = resource_class
|
49
|
-
@resources = resources
|
50
|
-
@response = options[:response]
|
51
|
-
@size = resources.size
|
52
|
-
@options = options
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [Class<Resource>]
|
56
|
-
attr_reader :resource_class
|
57
|
-
|
58
|
-
# @return [Seahorse::Client::Response, nil]
|
59
|
-
attr_reader :response
|
60
|
-
|
61
|
-
# @return [Integer]
|
62
|
-
attr_reader :size
|
63
|
-
|
64
|
-
alias count size
|
65
|
-
|
66
|
-
# @param [Integer] index
|
67
|
-
# @return [Resource]
|
68
|
-
def [](index)
|
69
|
-
@resources[index]
|
70
|
-
end
|
71
|
-
|
72
|
-
# Yields each resource of the batch, one at a time.
|
73
|
-
def each(&block)
|
74
|
-
enum = @resources.to_enum
|
75
|
-
enum.each(&block) if block_given?
|
76
|
-
enum
|
77
|
-
end
|
78
|
-
|
79
|
-
# @param [Integer] count
|
80
|
-
# @return [Resource, Batch]
|
81
|
-
def first(count = nil)
|
82
|
-
if count
|
83
|
-
self.class.new(@resource_class, @resources.first(count), @options)
|
84
|
-
else
|
85
|
-
@resources.first
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# @return [Boolean]
|
90
|
-
def empty?
|
91
|
-
@resources.empty?
|
92
|
-
end
|
93
|
-
|
94
|
-
# @api private
|
95
|
-
def inspect
|
96
|
-
"#<#{self.class.name} resources=#{@resources.inspect}>"
|
97
|
-
end
|
98
|
-
|
99
|
-
# @api private
|
100
|
-
def respond_to?(method_name, *args)
|
101
|
-
if @resource_class.batch_operation_names.include?(method_name.to_sym)
|
102
|
-
true
|
103
|
-
else
|
104
|
-
super
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# @api private
|
109
|
-
def method_missing(method_name, *args, &block)
|
110
|
-
if respond_to?(method_name)
|
111
|
-
invoke_batch_operation(method_name, args, block) unless empty?
|
112
|
-
else
|
113
|
-
super
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
|
119
|
-
def invoke_batch_operation(method_name, args, block)
|
120
|
-
self.class.validate_batch_args!(args)
|
121
|
-
operation = @resource_class.batch_operation(method_name)
|
122
|
-
operation.call(resource:self, args:args, block:block)
|
123
|
-
end
|
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
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Resources
|
3
|
-
|
4
|
-
# A {Builder} construct resource objects. It extracts resource identifiers
|
5
|
-
# for the objects it builds from another resource object and/or an
|
6
|
-
# AWS response.
|
7
|
-
class Builder
|
8
|
-
|
9
|
-
include Options
|
10
|
-
|
11
|
-
# @option options [required, Class<Resource>] resource_class
|
12
|
-
# @option options [Array<BuilderSources::Source>] :sources ([])
|
13
|
-
def initialize(options = {})
|
14
|
-
@resource_class = options[:resource_class]
|
15
|
-
@sources = options[:sources] || []
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [Class<Resource>]
|
19
|
-
attr_reader :resource_class
|
20
|
-
|
21
|
-
# @return [Array<BuilderSources::Source>] A list of resource
|
22
|
-
# identifier sources.
|
23
|
-
attr_reader :sources
|
24
|
-
|
25
|
-
# @return [Boolean] Returns `true` if this builder returns an array
|
26
|
-
# of resource objects from {#build}.
|
27
|
-
def plural?
|
28
|
-
@sources.any?(&:plural?)
|
29
|
-
end
|
30
|
-
|
31
|
-
# @option [Resource] :resource
|
32
|
-
# @option [Seahorse::Client::Response] :response
|
33
|
-
# @return [Resource, Array<Resource>] Returns a resource object or an
|
34
|
-
# array of resource objects if {#plural?}.
|
35
|
-
def build(options = {})
|
36
|
-
identifier_map = @sources.each.with_object({}) do |source, hash|
|
37
|
-
hash[source.target] = source.extract(options)
|
38
|
-
end
|
39
|
-
if plural?
|
40
|
-
build_batch(identifier_map, options)
|
41
|
-
else
|
42
|
-
build_one(identifier_map, options)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def build_batch(identifier_map, options, &block)
|
49
|
-
resources = (0...resource_count(identifier_map)).collect do |n|
|
50
|
-
identifiers = @sources.inject({}) do |hash, source|
|
51
|
-
value = identifier_map[source.target]
|
52
|
-
value = value[n] if source.plural?
|
53
|
-
hash[source.target] = value
|
54
|
-
hash
|
55
|
-
end
|
56
|
-
resource = build_one(identifiers, options)
|
57
|
-
yield(resource) if block_given?
|
58
|
-
resource
|
59
|
-
end
|
60
|
-
Batch.new(resource_class, resources, options)
|
61
|
-
end
|
62
|
-
|
63
|
-
def build_one(identifiers, options)
|
64
|
-
if identifiers.count > 0 && identifiers.values.any?(&:nil?)
|
65
|
-
nil
|
66
|
-
else
|
67
|
-
@resource_class.new(identifiers.merge(
|
68
|
-
client: client(options)
|
69
|
-
))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def resource_count(identifier_map)
|
74
|
-
identifier_map.values.inject(0) do |max, values|
|
75
|
-
[max, values.is_a?(Array) ? values.size : 0].max
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def client(options)
|
80
|
-
Array(options[:resource]).first.client
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|