Class: Aws::Resources::Operations::WaiterOperation

Inherits:
Base
  • Object
show all
Includes:
Aws::Resources::Options
Defined in:
aws-sdk-resources/lib/aws-sdk-resources/operations.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#source

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WaiterOperation

Returns a new instance of WaiterOperation


185
186
187
188
189
190
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 185

def initialize(options = {})
  @waiter_name = option(:waiter_name, options)
  @waiter_params = option(:waiter_params, options)
  @path = options[:path]
  super
end

Instance Attribute Details

#pathString<JMESPathExpression>? (readonly)

Returns:

  • (String<JMESPathExpression>, nil)

199
200
201
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 199

def path
  @path
end

#waiter_nameSymbol (readonly)

Returns:

  • (Symbol)

193
194
195
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 193

def waiter_name
  @waiter_name
end

#waiter_paramsArray<RequestParams::Base> (readonly)

Returns:

  • (Array<RequestParams::Base>)

196
197
198
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 196

def waiter_params
  @waiter_params
end

Instance Method Details

#call(options, &block) ⇒ Object

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :resource (required, Resource)
  • :args (required, Array<Mixed>)

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 203

def call(options, &block)

  resource = options[:resource]

  params_hash = {}
  @waiter_params.each do |param|
    param.apply(params_hash, options)
  end

  user_params = options[:params] || {}
  params = deep_merge(user_params, params_hash)
  resp = resource.client.wait_until(@waiter_name, params)

  resource_opts = resource.identifiers.dup
  resource_opts[:data] = JMESPath.search(@path, resp.data) if @path
  resource_opts[:client] = resource.client
  resource.class.new(resource_opts)
end

#deep_merge(obj1, obj2) ⇒ Object


222
223
224
225
226
227
228
# File 'aws-sdk-resources/lib/aws-sdk-resources/operations.rb', line 222

def deep_merge(obj1, obj2)
  case obj1
  when Hash then obj1.merge(obj2) { |key, v1, v2| deep_merge(v1, v2) }
  when Array then obj2 + obj1
  else obj2
  end
end