aws-sdk-resources 2.11.397 → 3.57.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aws-v3.rb +201 -0
- data/lib/aws-sdk-resources.rb +200 -87
- metadata +2748 -69
- 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 -20
- data/lib/aws-sdk-resources/services/s3/bucket.rb +0 -127
- data/lib/aws-sdk-resources/services/s3/encryption.rb +0 -21
- data/lib/aws-sdk-resources/services/s3/encryption/client.rb +0 -369
- data/lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb +0 -174
- data/lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb +0 -63
- data/lib/aws-sdk-resources/services/s3/encryption/default_key_provider.rb +0 -38
- data/lib/aws-sdk-resources/services/s3/encryption/encrypt_handler.rb +0 -50
- data/lib/aws-sdk-resources/services/s3/encryption/errors.rb +0 -13
- data/lib/aws-sdk-resources/services/s3/encryption/io_auth_decrypter.rb +0 -56
- data/lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb +0 -29
- data/lib/aws-sdk-resources/services/s3/encryption/io_encrypter.rb +0 -69
- data/lib/aws-sdk-resources/services/s3/encryption/key_provider.rb +0 -29
- data/lib/aws-sdk-resources/services/s3/encryption/kms_cipher_provider.rb +0 -71
- data/lib/aws-sdk-resources/services/s3/encryption/materials.rb +0 -58
- data/lib/aws-sdk-resources/services/s3/encryption/utils.rb +0 -79
- 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 -647
- 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
@@ -1,39 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Resources
|
3
|
-
class Request
|
4
|
-
|
5
|
-
# @option options [required, String] :method_name
|
6
|
-
# @option options [Array<RequestParams::Param>] :params ([]) A list of
|
7
|
-
# request params to apply to the request when called.
|
8
|
-
def initialize(options = {})
|
9
|
-
@method_name = options[:method_name]
|
10
|
-
@params = options[:params] || []
|
11
|
-
end
|
12
|
-
|
13
|
-
# @return [String] Name of the method called on the client when this
|
14
|
-
# operation is called.
|
15
|
-
attr_reader :method_name
|
16
|
-
|
17
|
-
# @return [Array<RequestParams::Param>]
|
18
|
-
attr_reader :params
|
19
|
-
|
20
|
-
# @option options [required, Resource] :resource
|
21
|
-
# @option options [Array<Mixed>] :args
|
22
|
-
# @return [Seahorse::Client::Response]
|
23
|
-
def call(options)
|
24
|
-
client(options).send(@method_name, req_params(options), &options[:block])
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def client(options)
|
30
|
-
Array(options[:resource]).first.client
|
31
|
-
end
|
32
|
-
|
33
|
-
def req_params(options)
|
34
|
-
RequestParams::ParamHash.new(@params).build(options)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Resources
|
3
|
-
module RequestParams
|
4
|
-
|
5
|
-
# @api private
|
6
|
-
class ParamHash
|
7
|
-
|
8
|
-
# @param [Array<RequestParams::Param>] params
|
9
|
-
def initialize(params)
|
10
|
-
@params = params
|
11
|
-
end
|
12
|
-
|
13
|
-
# @option options [required,Resource] :resource
|
14
|
-
# @option options [required,Array<Mixed>] :args
|
15
|
-
# @return [Hash]
|
16
|
-
def build(options = {})
|
17
|
-
deep_merge(user_params(options), computed_params(options))
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def user_params(options)
|
23
|
-
args = options[:args] || []
|
24
|
-
args.last.is_a?(Hash) ? args.last : {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def computed_params(options)
|
28
|
-
params_hash = {}
|
29
|
-
Array(options[:resource]).each.with_index do |resource, n|
|
30
|
-
@params.each do |param|
|
31
|
-
param.apply(params_hash, options.merge(resource: resource, n: n))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
params_hash
|
35
|
-
end
|
36
|
-
|
37
|
-
def deep_merge(obj1, obj2)
|
38
|
-
case obj1
|
39
|
-
when Hash then obj1.merge(obj2) { |key, v1, v2| deep_merge(v1, v2) }
|
40
|
-
when Array then obj2 + obj1
|
41
|
-
else obj2
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
module Param
|
48
|
-
|
49
|
-
def initialize(options)
|
50
|
-
@target = options[:target].to_s
|
51
|
-
@steps = []
|
52
|
-
@target.scan(/\w+|\[\]|\[\*\]|\[[0-9]+\]/) do |step|
|
53
|
-
case step
|
54
|
-
when /\[\d+\]/ then @steps += [:array, step[1..-2].to_i]
|
55
|
-
when /\[\*\]/ then @steps += [:array, :n]
|
56
|
-
when '[]' then @steps += [:array, -1]
|
57
|
-
else @steps += [:hash, step.to_sym]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
@steps.shift
|
61
|
-
@final = @steps.pop
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [String] target
|
65
|
-
attr_reader :target
|
66
|
-
|
67
|
-
def apply(params, options = {})
|
68
|
-
if @final == -1
|
69
|
-
build_context(params, options[:n]) << value(options)
|
70
|
-
else
|
71
|
-
build_context(params, options[:n])[@final] = value(options)
|
72
|
-
end
|
73
|
-
params
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def build_context(params, n)
|
79
|
-
@steps.each_slice(2).inject(params) do |context, (key, type)|
|
80
|
-
entry = type == :array ? [] : {}
|
81
|
-
if key == -1
|
82
|
-
context << entry
|
83
|
-
entry
|
84
|
-
elsif key == :n
|
85
|
-
context[n] ||= entry
|
86
|
-
else
|
87
|
-
context[key] ||= entry
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
class Identifier
|
95
|
-
|
96
|
-
include Param
|
97
|
-
|
98
|
-
def initialize(options)
|
99
|
-
@identifier_name = options[:name]
|
100
|
-
super
|
101
|
-
end
|
102
|
-
|
103
|
-
def value(options)
|
104
|
-
options[:resource].send(@identifier_name)
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
class DataMember
|
110
|
-
|
111
|
-
include Param
|
112
|
-
|
113
|
-
def initialize(options)
|
114
|
-
@path = options[:path]
|
115
|
-
super
|
116
|
-
end
|
117
|
-
|
118
|
-
def value(options)
|
119
|
-
JMESPath.search(@path, options[:resource].data)
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
class Literal
|
125
|
-
|
126
|
-
include Param
|
127
|
-
|
128
|
-
def initialize(options)
|
129
|
-
@value = options[:value]
|
130
|
-
super
|
131
|
-
end
|
132
|
-
|
133
|
-
def value(*args)
|
134
|
-
@value
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,243 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module Resources
|
3
|
-
class Resource
|
4
|
-
|
5
|
-
extend OperationMethods
|
6
|
-
|
7
|
-
# @overload initialize(*identifiers, options = {})
|
8
|
-
# @param [Hash] options Options except `:data` and identifier options are
|
9
|
-
# used to construct a {Client} unless `:client` is given.
|
10
|
-
# @option options [Client] :client
|
11
|
-
def initialize(*args)
|
12
|
-
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
13
|
-
@identifiers = extract_identifiers(args, options)
|
14
|
-
@data = options.delete(:data)
|
15
|
-
@client = extract_client(options)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Marked private to prevent double documentation
|
19
|
-
# @return [Client]
|
20
|
-
attr_reader :client
|
21
|
-
|
22
|
-
# Marked private to prevent double documentation
|
23
|
-
# @return [Hash<Symbol,String>]
|
24
|
-
attr_reader :identifiers
|
25
|
-
|
26
|
-
# Waiter polls an API operation until a resource enters a desired
|
27
|
-
# state.
|
28
|
-
#
|
29
|
-
# @note The waiting operation is performed on a copy. The original resource remains unchanged
|
30
|
-
#
|
31
|
-
# ## Basic Usage
|
32
|
-
#
|
33
|
-
# Waiter will polls until it is successful, it fails by
|
34
|
-
# entering a terminal state, or until a maximum number of attempts
|
35
|
-
# are made.
|
36
|
-
#
|
37
|
-
# # polls in a loop until condition is true
|
38
|
-
# resource.wait_until(options) {|resource| condition}
|
39
|
-
#
|
40
|
-
# ## Example
|
41
|
-
#
|
42
|
-
# instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
|
43
|
-
#
|
44
|
-
# ## Configuration
|
45
|
-
#
|
46
|
-
# You can configure the maximum number of polling attempts, and the
|
47
|
-
# delay (in seconds) between each polling attempt. The waiting condition is set
|
48
|
-
# by passing a block to {#wait_until}:
|
49
|
-
#
|
50
|
-
# # poll for ~25 seconds
|
51
|
-
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
52
|
-
#
|
53
|
-
# ## Callbacks
|
54
|
-
#
|
55
|
-
# You can be notified before each polling attempt and before each
|
56
|
-
# delay. If you throw `:success` or `:failure` from these callbacks,
|
57
|
-
# it will terminate the waiter.
|
58
|
-
#
|
59
|
-
# started_at = Time.now
|
60
|
-
# # poll for 1 hour, instead of a number of attempts
|
61
|
-
# proc = Proc.new do |attempts, response|
|
62
|
-
# throw :failure if Time.now - started_at > 3600
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# # disable max attempts
|
66
|
-
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
67
|
-
#
|
68
|
-
# ## Handling Errors
|
69
|
-
#
|
70
|
-
# When a waiter is successful, it returns the Resource. When a waiter
|
71
|
-
# fails, it raises an error.
|
72
|
-
#
|
73
|
-
# begin
|
74
|
-
# resource.wait_until(...)
|
75
|
-
# rescue Aws::Waiters::Errors::WaiterFailed
|
76
|
-
# # resource did not enter the desired state in time
|
77
|
-
# end
|
78
|
-
#
|
79
|
-
#
|
80
|
-
# @yieldparam [Resource] resource to be used in the waiting condition
|
81
|
-
#
|
82
|
-
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
|
83
|
-
# because the waiter has entered a state that it will not transition
|
84
|
-
# out of, preventing success.
|
85
|
-
#
|
86
|
-
# @raise [Aws::Waiters::Errors::TooManyAttemptsError] Raised when the configured
|
87
|
-
# maximum number of attempts have been made, and the waiter is not
|
88
|
-
# yet successful.
|
89
|
-
#
|
90
|
-
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
|
91
|
-
# while polling for a resource that is not expected.
|
92
|
-
#
|
93
|
-
# @raise [NotImplementedError] Raised when the resource does not
|
94
|
-
# support #reload operation
|
95
|
-
#
|
96
|
-
# @option options [Integer] :max_attempts (10) Maximum number of attempts
|
97
|
-
# @option options [Integer] :delay (10) Delay between each attempt in seconds
|
98
|
-
# @option options [Proc] :before_attempt (nil) Callback invoked before each attempt
|
99
|
-
# @option options [Proc] :before_wait (nil) Callback invoked before each wait
|
100
|
-
# @return [Resource] if the waiter was successful
|
101
|
-
def wait_until(options = {}, &block)
|
102
|
-
resource_copy = self.dup
|
103
|
-
attempts = 0
|
104
|
-
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
105
|
-
options[:delay] ||= 10
|
106
|
-
options[:poller] = Proc.new do
|
107
|
-
attempts += 1
|
108
|
-
if block.call(resource_copy)
|
109
|
-
[:success, resource_copy]
|
110
|
-
else
|
111
|
-
resource_copy.reload unless attempts == options[:max_attempts]
|
112
|
-
:retry
|
113
|
-
end
|
114
|
-
end
|
115
|
-
Waiters::Waiter.new(options).wait({})
|
116
|
-
end
|
117
|
-
|
118
|
-
# @return [Struct]
|
119
|
-
def data
|
120
|
-
load unless @data
|
121
|
-
@data
|
122
|
-
end
|
123
|
-
|
124
|
-
# @return [Boolean] Returns `true` if {#data} has been loaded.
|
125
|
-
def data_loaded?
|
126
|
-
!@data.nil?
|
127
|
-
end
|
128
|
-
|
129
|
-
# @api private
|
130
|
-
def exists?(options = {})
|
131
|
-
wait_until_exists(options) { |w| w.max_attempts = 1 }
|
132
|
-
true
|
133
|
-
rescue Waiters::Errors::UnexpectedError => e
|
134
|
-
raise e.error
|
135
|
-
rescue Waiters::Errors::WaiterFailed
|
136
|
-
false
|
137
|
-
rescue NoMethodError
|
138
|
-
msg = "#exists? is not implemented for #{self.class.name}"
|
139
|
-
raise NotImplementedError, msg
|
140
|
-
end
|
141
|
-
|
142
|
-
# Loads data for this resource.
|
143
|
-
# @note Calling this method will send a request to AWS.
|
144
|
-
# @return [self]
|
145
|
-
def load
|
146
|
-
if load_operation = self.class.load_operation
|
147
|
-
@data = load_operation.call(resource:self, client:client)
|
148
|
-
self
|
149
|
-
else
|
150
|
-
raise NotImplementedError, "#load not defined for #{self.class.name}"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
alias reload load
|
154
|
-
|
155
|
-
# @api private
|
156
|
-
def inspect
|
157
|
-
identifiers = self.identifiers.map do |name, value|
|
158
|
-
"#{name}=#{value.inspect}"
|
159
|
-
end.join(', ')
|
160
|
-
"#<#{[self.class.name, identifiers].join(' ').strip}>"
|
161
|
-
end
|
162
|
-
|
163
|
-
private
|
164
|
-
|
165
|
-
def extract_client(options)
|
166
|
-
if options[:client]
|
167
|
-
options[:client]
|
168
|
-
else
|
169
|
-
self.class.client_class.new(options.merge(
|
170
|
-
user_agent_suffix: "resources"
|
171
|
-
))
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def extract_identifiers(args, options)
|
176
|
-
identifiers = {}
|
177
|
-
self.class.identifiers.each.with_index do |name, n|
|
178
|
-
if args[n]
|
179
|
-
identifiers[name] = args[n]
|
180
|
-
elsif options[name]
|
181
|
-
identifiers[name] = options.delete(name)
|
182
|
-
else
|
183
|
-
raise ArgumentError, "missing required option #{name.inspect}"
|
184
|
-
end
|
185
|
-
end
|
186
|
-
identifiers
|
187
|
-
end
|
188
|
-
|
189
|
-
class << self
|
190
|
-
|
191
|
-
# @return [String, nil] The resource name.
|
192
|
-
attr_accessor :resource_name
|
193
|
-
|
194
|
-
# @return [Class<Client>, nil] When constructing
|
195
|
-
# a resource, the client will default to an instance of the
|
196
|
-
# this class.
|
197
|
-
attr_accessor :client_class
|
198
|
-
|
199
|
-
# @return [Operations::LoadOperation, nil]
|
200
|
-
attr_accessor :load_operation
|
201
|
-
|
202
|
-
# @return [Array<Symbol>]
|
203
|
-
# @see add_identifier
|
204
|
-
# @see #identifiers
|
205
|
-
def identifiers
|
206
|
-
@identifiers.dup
|
207
|
-
end
|
208
|
-
|
209
|
-
# @param [Symbol] name
|
210
|
-
# @return [void]
|
211
|
-
def add_identifier(name)
|
212
|
-
name = name.to_sym
|
213
|
-
safe_define_method(name) { @identifiers[name] }
|
214
|
-
@identifiers << name
|
215
|
-
end
|
216
|
-
|
217
|
-
# Registers a data attribute. This defines a simple getter
|
218
|
-
# for the attribute which will access {#data}, loading the
|
219
|
-
# resource if necessary.
|
220
|
-
# @param [Symbol] name
|
221
|
-
# @return [void]
|
222
|
-
def add_data_attribute(name)
|
223
|
-
safe_define_method(name) { data[name] }
|
224
|
-
@data_attributes << name
|
225
|
-
end
|
226
|
-
|
227
|
-
# @return [Array<Symbol>] Returns an array of symbolized data
|
228
|
-
# attribute names.
|
229
|
-
def data_attributes
|
230
|
-
@data_attributes.dup
|
231
|
-
end
|
232
|
-
|
233
|
-
# @api private
|
234
|
-
def inherited(subclass)
|
235
|
-
subclass.send(:instance_variable_set, "@identifiers", [])
|
236
|
-
subclass.send(:instance_variable_set, "@data_attributes", [])
|
237
|
-
super
|
238
|
-
end
|
239
|
-
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Aws
|
2
|
-
module EC2
|
3
|
-
|
4
|
-
require 'aws-sdk-resources/services/ec2/instance'
|
5
|
-
|
6
|
-
class Resource
|
7
|
-
|
8
|
-
def create_tags(options)
|
9
|
-
resp = @client.create_tags(options)
|
10
|
-
tags = []
|
11
|
-
options[:resources].each do |resource_id|
|
12
|
-
options[:tags].each do |tag|
|
13
|
-
tags << Tag.new(resource_id, tag[:key], tag[:value], client: @client)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
Resources::Batch.new(Tag, tags, response: resp)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|