You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::IVS::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for Amazon Interactive Video Service. To construct a client, you need to configure a :region and :credentials.

ivs = Aws::IVS::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::IVS::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::IVS::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :active_endpoint_cache (Boolean)

    When set to true, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :disable_host_prefix_injection (Boolean)

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available. See Plugins::EndpointPattern for more details.

  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :endpoint_cache_max_entries (Integer)

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_max_threads (Integer)

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_poll_interval (Integer)

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec. See Plugins::EndpointDiscovery for more details.

  • :endpoint_discovery (Boolean)

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#batch_get_channel(options = {}) ⇒ Types::BatchGetChannelResponse

Performs GetChannel on multiple ARNs simultaneously.

Examples:

Request syntax with placeholder values


resp = client.batch_get_channel({
  arns: ["ChannelArn"], # required
})

Response structure


resp.channels #=> Array
resp.channels[0].arn #=> String
resp.channels[0].name #=> String
resp.channels[0].latency_mode #=> String, one of "NORMAL", "LOW"
resp.channels[0].type #=> String, one of "BASIC", "STANDARD"
resp.channels[0].ingest_endpoint #=> String
resp.channels[0].playback_url #=> String
resp.channels[0].authorized #=> true/false
resp.channels[0].tags #=> Hash
resp.channels[0].tags["TagKey"] #=> String
resp.errors #=> Array
resp.errors[0].arn #=> String
resp.errors[0].code #=> String
resp.errors[0].message #=> String

Options Hash (options):

  • :arns (required, Array<String>)

    Array of ARNs, one per channel.

Returns:

See Also:

#batch_get_stream_key(options = {}) ⇒ Types::BatchGetStreamKeyResponse

Performs GetStreamKey on multiple ARNs simultaneously.

Examples:

Request syntax with placeholder values


resp = client.batch_get_stream_key({
  arns: ["StreamKeyArn"], # required
})

Response structure


resp.stream_keys #=> Array
resp.stream_keys[0].arn #=> String
resp.stream_keys[0].value #=> String
resp.stream_keys[0].channel_arn #=> String
resp.stream_keys[0].tags #=> Hash
resp.stream_keys[0].tags["TagKey"] #=> String
resp.errors #=> Array
resp.errors[0].arn #=> String
resp.errors[0].code #=> String
resp.errors[0].message #=> String

Options Hash (options):

  • :arns (required, Array<String>)

    Array of ARNs, one per channel.

Returns:

See Also:

#create_channel(options = {}) ⇒ Types::CreateChannelResponse

Creates a new channel and an associated stream key to start streaming.

Examples:

Request syntax with placeholder values


resp = client.create_channel({
  name: "ChannelName",
  latency_mode: "NORMAL", # accepts NORMAL, LOW
  type: "BASIC", # accepts BASIC, STANDARD
  authorized: false,
  tags: {
    "TagKey" => "TagValue",
  },
})

Response structure


resp.channel.arn #=> String
resp.channel.name #=> String
resp.channel.latency_mode #=> String, one of "NORMAL", "LOW"
resp.channel.type #=> String, one of "BASIC", "STANDARD"
resp.channel.ingest_endpoint #=> String
resp.channel.playback_url #=> String
resp.channel.authorized #=> true/false
resp.channel.tags #=> Hash
resp.channel.tags["TagKey"] #=> String
resp.stream_key.arn #=> String
resp.stream_key.value #=> String
resp.stream_key.channel_arn #=> String
resp.stream_key.tags #=> Hash
resp.stream_key.tags["TagKey"] #=> String

Options Hash (options):

  • :name (String)

    Channel name.

  • :latency_mode (String)

    Channel latency mode. Default: LOW.

  • :type (String)

    Channel type, which determines the allowable resolution and bitrate. If you exceed the allowable resolution or bitrate, the stream probably will disconnect immediately. Valid values:

    • STANDARD: Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions. Vertical resolution can be up to 1080 and bitrate can be up to 8.5 Mbps.

    • BASIC: Amazon IVS delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input. Vertical resolution can be up to 480 and bitrate can be up to 1.5 Mbps.

    Default: STANDARD.

  • :authorized (Boolean)

    Whether the channel is authorized. Default: false.

  • :tags (Hash<String,String>)

Returns:

See Also:

#create_stream_key(options = {}) ⇒ Types::CreateStreamKeyResponse

Creates a stream key, used to initiate a stream, for the specified channel ARN.

Note that CreateChannel creates a stream key. If you subsequently use CreateStreamKey on the same channel, it will fail because a stream key already exists and there is a limit of 1 stream key per channel. To reset the stream key on a channel, use DeleteStreamKey and then CreateStreamKey.

Examples:

Request syntax with placeholder values


resp = client.create_stream_key({
  channel_arn: "ChannelArn", # required
  tags: {
    "TagKey" => "TagValue",
  },
})

Response structure


resp.stream_key.arn #=> String
resp.stream_key.value #=> String
resp.stream_key.channel_arn #=> String
resp.stream_key.tags #=> Hash
resp.stream_key.tags["TagKey"] #=> String

Options Hash (options):

  • :channel_arn (required, String)

    ARN of the channel for which to create the stream key.

  • :tags (Hash<String,String>)

Returns:

See Also:

#delete_channel(options = {}) ⇒ Struct

Deletes the specified channel and its associated stream keys.

Examples:

Request syntax with placeholder values


resp = client.delete_channel({
  arn: "ChannelArn", # required
})

Options Hash (options):

  • :arn (required, String)

    ARN of the channel to be deleted.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete_playback_key_pair(options = {}) ⇒ Struct

Deletes a specified authorization key pair. This invalidates future viewer tokens generated using the key pair’s privateKey.

Examples:

Request syntax with placeholder values


resp = client.delete_playback_key_pair({
  arn: "PlaybackKeyPairArn", # required
})

Options Hash (options):

  • :arn (required, String)

    ARN of the key pair to be deleted.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete_stream_key(options = {}) ⇒ Struct

Deletes the stream key for the specified ARN, so it can no longer be used to stream.

Examples:

Request syntax with placeholder values


resp = client.delete_stream_key({
  arn: "StreamKeyArn", # required
})

Options Hash (options):

  • :arn (required, String)

    ARN of the stream key to be deleted.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#get_channel(options = {}) ⇒ Types::GetChannelResponse

Gets the channel configuration for the specified channel ARN. See also BatchGetChannel.

Examples:

Request syntax with placeholder values


resp = client.get_channel({
  arn: "ChannelArn", # required
})

Response structure


resp.channel.arn #=> String
resp.channel.name #=> String
resp.channel.latency_mode #=> String, one of "NORMAL", "LOW"
resp.channel.type #=> String, one of "BASIC", "STANDARD"
resp.channel.ingest_endpoint #=> String
resp.channel.playback_url #=> String
resp.channel.authorized #=> true/false
resp.channel.tags #=> Hash
resp.channel.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    ARN of the channel for which the configuration is to be retrieved.

Returns:

See Also:

#get_playback_key_pair(options = {}) ⇒ Types::GetPlaybackKeyPairResponse

Gets a specified playback authorization key pair and returns the arn and fingerprint. The privateKey held by the caller can be used to generate viewer authorization tokens, to grant viewers access to authorized channels.

Examples:

Request syntax with placeholder values


resp = client.get_playback_key_pair({
  arn: "PlaybackKeyPairArn", # required
})

Response structure


resp.key_pair.arn #=> String
resp.key_pair.name #=> String
resp.key_pair.fingerprint #=> String
resp.key_pair.tags #=> Hash
resp.key_pair.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    ARN of the key pair to be returned.

Returns:

See Also:

#get_stream(options = {}) ⇒ Types::GetStreamResponse

Gets information about the active (live) stream on a specified channel.

Examples:

Request syntax with placeholder values


resp = client.get_stream({
  channel_arn: "ChannelArn", # required
})

Response structure


resp.stream.channel_arn #=> String
resp.stream.playback_url #=> String
resp.stream.start_time #=> Time
resp.stream.state #=> String, one of "LIVE", "OFFLINE"
resp.stream.health #=> String, one of "HEALTHY", "STARVING", "UNKNOWN"
resp.stream.viewer_count #=> Integer

Options Hash (options):

  • :channel_arn (required, String)

    Channel ARN for stream to be accessed.

Returns:

See Also:

#get_stream_key(options = {}) ⇒ Types::GetStreamKeyResponse

Gets stream-key information for a specified ARN.

Examples:

Request syntax with placeholder values


resp = client.get_stream_key({
  arn: "StreamKeyArn", # required
})

Response structure


resp.stream_key.arn #=> String
resp.stream_key.value #=> String
resp.stream_key.channel_arn #=> String
resp.stream_key.tags #=> Hash
resp.stream_key.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    ARN for the stream key to be retrieved.

Returns:

See Also:

#import_playback_key_pair(options = {}) ⇒ Types::ImportPlaybackKeyPairResponse

Imports the public portion of a new key pair and returns its arn and fingerprint. The privateKey can then be used to generate viewer authorization tokens, to grant viewers access to authorized channels.

Examples:

Request syntax with placeholder values


resp = client.import_playback_key_pair({
  public_key_material: "PlaybackPublicKeyMaterial", # required
  name: "PlaybackKeyPairName",
  tags: {
    "TagKey" => "TagValue",
  },
})

Response structure


resp.key_pair.arn #=> String
resp.key_pair.name #=> String
resp.key_pair.fingerprint #=> String
resp.key_pair.tags #=> Hash
resp.key_pair.tags["TagKey"] #=> String

Options Hash (options):

  • :public_key_material (required, String)

    The public portion of a customer-generated key pair.

  • :name (String)

    An arbitrary string (a nickname) assigned to a playback key pair that helps the customer identify that resource. The value does not need to be unique.

  • :tags (Hash<String,String>)

    Any tags provided with the request are added to the playback key pair tags.

Returns:

See Also:

#list_channels(options = {}) ⇒ Types::ListChannelsResponse

Gets summary information about all channels in your account, in the AWS region where the API request is processed. This list can be filtered to match a specified string.

Examples:

Request syntax with placeholder values


resp = client.list_channels({
  filter_by_name: "ChannelName",
  next_token: "PaginationToken",
  max_results: 1,
})

Response structure


resp.channels #=> Array
resp.channels[0].arn #=> String
resp.channels[0].name #=> String
resp.channels[0].latency_mode #=> String, one of "NORMAL", "LOW"
resp.channels[0].authorized #=> true/false
resp.channels[0].tags #=> Hash
resp.channels[0].tags["TagKey"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :filter_by_name (String)

    Filters the channel list to match the specified name.

  • :next_token (String)

    The first channel to retrieve. This is used for pagination; see the nextToken response field.

  • :max_results (Integer)

    Maximum number of channels to return.

Returns:

See Also:

#list_playback_key_pairs(options = {}) ⇒ Types::ListPlaybackKeyPairsResponse

Gets summary information about playback key pairs.

Examples:

Request syntax with placeholder values


resp = client.list_playback_key_pairs({
  next_token: "PaginationToken",
  max_results: 1,
})

Response structure


resp.key_pairs #=> Array
resp.key_pairs[0].arn #=> String
resp.key_pairs[0].name #=> String
resp.key_pairs[0].tags #=> Hash
resp.key_pairs[0].tags["TagKey"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    Maximum number of key pairs to return.

  • :max_results (Integer)

    The first key pair to retrieve. This is used for pagination; see the nextToken response field.

Returns:

See Also:

#list_stream_keys(options = {}) ⇒ Types::ListStreamKeysResponse

Gets summary information about stream keys for the specified channel.

Examples:

Request syntax with placeholder values


resp = client.list_stream_keys({
  channel_arn: "ChannelArn", # required
  next_token: "PaginationToken",
  max_results: 1,
})

Response structure


resp.stream_keys #=> Array
resp.stream_keys[0].arn #=> String
resp.stream_keys[0].channel_arn #=> String
resp.stream_keys[0].tags #=> Hash
resp.stream_keys[0].tags["TagKey"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :channel_arn (required, String)

    Channel ARN used to filter the list.

  • :next_token (String)

    The first stream key to retrieve. This is used for pagination; see the nextToken response field.

  • :max_results (Integer)

    Maximum number of streamKeys to return.

Returns:

See Also:

#list_streams(options = {}) ⇒ Types::ListStreamsResponse

Gets summary information about live streams in your account, in the AWS region where the API request is processed.

Examples:

Request syntax with placeholder values


resp = client.list_streams({
  next_token: "PaginationToken",
  max_results: 1,
})

Response structure


resp.streams #=> Array
resp.streams[0].channel_arn #=> String
resp.streams[0].state #=> String, one of "LIVE", "OFFLINE"
resp.streams[0].health #=> String, one of "HEALTHY", "STARVING", "UNKNOWN"
resp.streams[0].viewer_count #=> Integer
resp.streams[0].start_time #=> Time
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    The first stream to retrieve. This is used for pagination; see the nextToken response field.

  • :max_results (Integer)

    Maximum number of streams to return.

Returns:

See Also:

#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse

Gets information about AWS tags for the specified ARN.

Examples:

Request syntax with placeholder values


resp = client.list_tags_for_resource({
  resource_arn: "ResourceArn", # required
  next_token: "String",
  max_results: 1,
})

Response structure


resp.tags #=> Hash
resp.tags["TagKey"] #=> String
resp.next_token #=> String

Options Hash (options):

  • :resource_arn (required, String)

    The ARN of the resource to be retrieved.

  • :next_token (String)

    The first tag to retrieve. This is used for pagination; see the nextToken response field.

  • :max_results (Integer)

    Maximum number of tags to return.

Returns:

See Also:

#put_metadata(options = {}) ⇒ Struct

Inserts metadata into an RTMPS stream for the specified channel. A maximum of 5 requests per second per channel is allowed, each with a maximum 1KB payload.

Examples:

Request syntax with placeholder values


resp = client.({
  channel_arn: "ChannelArn", # required
  metadata: "StreamMetadata", # required
})

Options Hash (options):

  • :channel_arn (required, String)

    ARN of the channel into which metadata is inserted. This channel must have an active stream.

  • :metadata (required, String)

    Metadata to insert into the stream. Maximum: 1 KB per request.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#stop_stream(options = {}) ⇒ Struct

Disconnects the incoming RTMPS stream for the specified channel. Can be used in conjunction with DeleteStreamKey to prevent further streaming to a channel.

Many streaming client-software libraries automatically reconnect a dropped RTMPS session, so to stop the stream permanently, you may want to first revoke the streamKey attached to the channel.

Examples:

Request syntax with placeholder values


resp = client.stop_stream({
  channel_arn: "ChannelArn", # required
})

Options Hash (options):

  • :channel_arn (required, String)

    ARN of the channel for which the stream is to be stopped.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#tag_resource(options = {}) ⇒ Struct

Adds or updates tags for the AWS resource with the specified ARN.

Examples:

Request syntax with placeholder values


resp = client.tag_resource({
  resource_arn: "ResourceArn", # required
  tags: { # required
    "TagKey" => "TagValue",
  },
})

Options Hash (options):

  • :resource_arn (required, String)

    ARN of the resource for which tags are to be added or updated.

  • :tags (required, Hash<String,String>)

    Array of tags to be added or updated.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#untag_resource(options = {}) ⇒ Struct

Removes tags from the resource with the specified ARN.

Examples:

Request syntax with placeholder values


resp = client.untag_resource({
  resource_arn: "ResourceArn", # required
  tag_keys: ["TagKey"], # required
})

Options Hash (options):

  • :resource_arn (required, String)

    ARN of the resource for which tags are to be removed.

  • :tag_keys (required, Array<String>)

    Array of tags to be removed.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_channel(options = {}) ⇒ Types::UpdateChannelResponse

Updates a channel's configuration. This does not affect an ongoing stream of this channel. You must stop and restart the stream for the changes to take effect.

Examples:

Request syntax with placeholder values


resp = client.update_channel({
  arn: "ChannelArn", # required
  name: "ChannelName",
  latency_mode: "NORMAL", # accepts NORMAL, LOW
  type: "BASIC", # accepts BASIC, STANDARD
  authorized: false,
})

Response structure


resp.channel.arn #=> String
resp.channel.name #=> String
resp.channel.latency_mode #=> String, one of "NORMAL", "LOW"
resp.channel.type #=> String, one of "BASIC", "STANDARD"
resp.channel.ingest_endpoint #=> String
resp.channel.playback_url #=> String
resp.channel.authorized #=> true/false
resp.channel.tags #=> Hash
resp.channel.tags["TagKey"] #=> String

Options Hash (options):

  • :arn (required, String)

    ARN of the channel to be updated.

  • :name (String)

    Channel name.

  • :latency_mode (String)

    Channel latency mode. Default: LOW.

  • :type (String)

    Channel type, which determines the allowable resolution and bitrate. If you exceed the allowable resolution or bitrate, the stream probably will disconnect immediately. Valid values:

    • STANDARD: Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions. Vertical resolution can be up to 1080 and bitrate can be up to 8.5 Mbps.

    • BASIC: Amazon IVS delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input. Vertical resolution can be up to 480 and bitrate can be up to 1.5 Mbps.

    Default: STANDARD.

  • :authorized (Boolean)

    Whether the channel is authorized. Default: false.

Returns:

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# 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 configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

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(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.