lib/aws-sdk-databasemigrationservice/client.rb in aws-sdk-databasemigrationservice-1.11.0 vs lib/aws-sdk-databasemigrationservice/client.rb in aws-sdk-databasemigrationservice-1.12.0
- old
+ new
@@ -4282,17 +4282,144 @@
operation: config.api.operation(operation_name),
client: self,
params: params,
config: config)
context[:gem_name] = 'aws-sdk-databasemigrationservice'
- context[:gem_version] = '1.11.0'
+ context[:gem_version] = '1.12.0'
Seahorse::Client::Request.new(handlers, context)
end
+ # Polls an API operation until a resource enters a desired state.
+ #
+ # ## Basic Usage
+ #
+ # A waiter will call an API operation until:
+ #
+ # * It is successful
+ # * It enters a terminal state
+ # * It makes the maximum number of attempts
+ #
+ # In between attempts, the waiter will sleep.
+ #
+ # # polls in a loop, sleeping between attempts
+ # client.waiter_until(waiter_name, params)
+ #
+ # ## Configuration
+ #
+ # You can configure the maximum number of polling attempts, and the
+ # delay (in seconds) between each polling attempt. You can pass
+ # configuration as the final arguments hash.
+ #
+ # # poll for ~25 seconds
+ # client.wait_until(waiter_name, params, {
+ # max_attempts: 5,
+ # delay: 5,
+ # })
+ #
+ # ## Callbacks
+ #
+ # You can be notified before each polling attempt and before each
+ # delay. If you throw `:success` or `:failure` from these callbacks,
+ # it will terminate the waiter.
+ #
+ # started_at = Time.now
+ # client.wait_until(waiter_name, params, {
+ #
+ # # disable max attempts
+ # max_attempts: nil,
+ #
+ # # poll for 1 hour, instead of a number of attempts
+ # before_wait: -> (attempts, response) do
+ # throw :failure if Time.now - started_at > 3600
+ # end
+ # })
+ #
+ # ## Handling Errors
+ #
+ # When a waiter is unsuccessful, it will raise an error.
+ # All of the failure errors extend from
+ # {Aws::Waiters::Errors::WaiterFailed}.
+ #
+ # begin
+ # client.wait_until(...)
+ # rescue Aws::Waiters::Errors::WaiterFailed
+ # # resource did not enter the desired state in time
+ # end
+ #
+ # ## Valid Waiters
+ #
+ # The following table lists the valid waiter names, the operations they call,
+ # and the default `:delay` and `:max_attempts` values.
+ #
+ # | waiter_name | params | :delay | :max_attempts |
+ # | ------------------------------ | --------------------------------- | -------- | ------------- |
+ # | endpoint_deleted | {#describe_endpoints} | 5 | 60 |
+ # | replication_instance_available | {#describe_replication_instances} | 60 | 60 |
+ # | replication_instance_deleted | {#describe_replication_instances} | 15 | 60 |
+ # | replication_task_deleted | {#describe_replication_tasks} | 15 | 60 |
+ # | replication_task_ready | {#describe_replication_tasks} | 15 | 60 |
+ # | replication_task_running | {#describe_replication_tasks} | 15 | 60 |
+ # | replication_task_stopped | {#describe_replication_tasks} | 15 | 60 |
+ # | test_connection_succeeds | {#test_connection} | 5 | 60 |
+ #
+ # @raise [Errors::FailureStateError] Raised when the waiter terminates
+ # because the waiter has entered a state that it will not transition
+ # out of, preventing success.
+ #
+ # @raise [Errors::TooManyAttemptsError] Raised when the configured
+ # maximum number of attempts have been made, and the waiter is not
+ # yet successful.
+ #
+ # @raise [Errors::UnexpectedError] Raised when an error is encounted
+ # while polling for a resource that is not expected.
+ #
+ # @raise [Errors::NoSuchWaiterError] Raised when you request to wait
+ # for an unknown state.
+ #
+ # @return [Boolean] Returns `true` if the waiter was successful.
+ # @param [Symbol] waiter_name
+ # @param [Hash] params ({})
+ # @param [Hash] options ({})
+ # @option options [Integer] :max_attempts
+ # @option options [Integer] :delay
+ # @option options [Proc] :before_attempt
+ # @option options [Proc] :before_wait
+ def wait_until(waiter_name, params = {}, options = {})
+ w = waiter(waiter_name, options)
+ yield(w.waiter) if block_given? # deprecated
+ w.wait(params)
+ end
+
# @api private
# @deprecated
def waiter_names
- []
+ waiters.keys
+ end
+
+ private
+
+ # @param [Symbol] waiter_name
+ # @param [Hash] options ({})
+ def waiter(waiter_name, options = {})
+ waiter_class = waiters[waiter_name]
+ if waiter_class
+ waiter_class.new(options.merge(client: self))
+ else
+ raise Aws::Waiters::Errors::NoSuchWaiterError.new(waiter_name, waiters.keys)
+ end
+ end
+
+ def waiters
+ {
+ endpoint_deleted: Waiters::EndpointDeleted,
+ replication_instance_available: Waiters::ReplicationInstanceAvailable,
+ replication_instance_deleted: Waiters::ReplicationInstanceDeleted,
+ replication_task_deleted: Waiters::ReplicationTaskDeleted,
+ replication_task_ready: Waiters::ReplicationTaskReady,
+ replication_task_running: Waiters::ReplicationTaskRunning,
+ replication_task_stopped: Waiters::ReplicationTaskStopped,
+ test_connection_succeeds: Waiters::TestConnectionSucceeds
+ }
end
class << self
# @api private