Class: Aws::DynamoDB::Table
- Inherits:
-
Object
- Object
- Aws::DynamoDB::Table
- Defined in:
- gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#archival_summary ⇒ Types::ArchivalSummary
Contains information about the table archive.
-
#attribute_definitions ⇒ Array<Types::AttributeDefinition>
An array of
AttributeDefinitionobjects. -
#billing_mode_summary ⇒ Types::BillingModeSummary
Contains the details for the read/write capacity mode.
-
#creation_date_time ⇒ Time
The date and time when the table was created, in [UNIX epoch time][1] format.
-
#deletion_protection_enabled ⇒ Boolean
Indicates whether deletion protection is enabled (true) or disabled (false) on the table.
-
#disassociation_protection_enabled ⇒ Boolean
Specifies whether disassociation protection is enabled (
true) or disabled (false) for the local global table replica. -
#global_secondary_indexes ⇒ Array<Types::GlobalSecondaryIndexDescription>
The global secondary indexes, if any, on the table.
-
#global_table_settings_replication_mode ⇒ String
Indicates one of the settings synchronization modes for the global table:.
-
#global_table_version ⇒ String
Represents the version of [global tables][1] in use, if the table is replicated across Amazon Web Services Regions.
-
#global_table_witnesses ⇒ Array<Types::GlobalTableWitnessDescription>
The witness Region and its current status in the MRSC global table.
-
#item_count ⇒ Integer
The number of items in the specified table.
-
#key_schema ⇒ Array<Types::KeySchemaElement>
The primary key structure for the table.
-
#latest_stream_arn ⇒ String
The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table.
-
#latest_stream_label ⇒ String
A timestamp, in ISO 8601 format, for this stream.
-
#local_secondary_indexes ⇒ Array<Types::LocalSecondaryIndexDescription>
Represents one or more local secondary indexes on the table.
-
#multi_region_consistency ⇒ String
Indicates one of the following consistency modes for a global table:.
-
#name ⇒ String
(also: #table_name)
-
#on_demand_throughput ⇒ Types::OnDemandThroughput
The maximum number of read and write units for the specified on-demand table.
-
#provisioned_throughput ⇒ Types::ProvisionedThroughputDescription
The provisioned throughput settings for the table, consisting of read and write capacity units, along with data about increases and decreases.
-
#replicas ⇒ Array<Types::ReplicaDescription>
Represents replicas of the table.
-
#restore_summary ⇒ Types::RestoreSummary
Contains details for the restore.
-
#sse_description ⇒ Types::SSEDescription
The description of the server-side encryption status on the specified table.
-
#stream_specification ⇒ Types::StreamSpecification
The current DynamoDB Streams configuration for the table.
-
#table_arn ⇒ String
The Amazon Resource Name (ARN) that uniquely identifies the table.
-
#table_class_summary ⇒ Types::TableClassSummary
Contains details of the table class.
-
#table_id ⇒ String
A unique identifier for the table, in UUID format, generated by DynamoDB when the table is created.
-
#table_size_bytes ⇒ Integer
The total size of the specified table, in bytes.
-
#table_status ⇒ String
The current state of the table:.
-
#vector_indexes ⇒ Array<Types::VectorIndexDescription>
The vector indexes, if any, on the table.
-
#warm_throughput ⇒ Types::TableWarmThroughputDescription
Describes the warm throughput value of the base table.
Actions collapse
-
#delete(options = {}) ⇒ Types::DeleteTableOutput
-
#delete_item(options = {}) ⇒ Types::DeleteItemOutput
-
#get_item(options = {}) ⇒ Types::GetItemOutput
-
#put_item(options = {}) ⇒ Types::PutItemOutput
-
#query(options = {}) ⇒ Types::QueryOutput
-
#scan(options = {}) ⇒ Types::ScanOutput
-
#update(options = {}) ⇒ Table
-
#update_item(options = {}) ⇒ Types::UpdateItemOutput
Instance Method Summary collapse
-
#client ⇒ Client
-
#data ⇒ Types::TableDescription
Returns the data for this Table.
-
#data_loaded? ⇒ Boolean
Returns
trueif this resource is loaded. -
#initialize(*args) ⇒ Table
constructor
A new instance of Table.
- #load ⇒ self (also: #reload)
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::DynamoDB::Client] #wait_until instead
Constructor Details
#initialize(name, options = {}) ⇒ Table #initialize(options = {}) ⇒ Table
Returns a new instance of Table.
22 23 24 25 26 27 28 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#archival_summary ⇒ Types::ArchivalSummary
Contains information about the table archive.
386 387 388 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 386 def archival_summary data[:archival_summary] end |
#attribute_definitions ⇒ Array<Types::AttributeDefinition>
An array of AttributeDefinition objects. Each of these objects
describes one attribute in the table and index key schema.
Each AttributeDefinition object in this array is composed of:
AttributeName- The name of the attribute.AttributeType- The data type for the attribute.
47 48 49 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 47 def attribute_definitions data[:attribute_definitions] end |
#billing_mode_summary ⇒ Types::BillingModeSummary
Contains the details for the read/write capacity mode.
161 162 163 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 161 def billing_mode_summary data[:billing_mode_summary] end |
#client ⇒ Client
488 489 490 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 488 def client @client end |
#creation_date_time ⇒ Time
The date and time when the table was created, in UNIX epoch time format.
118 119 120 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 118 def creation_date_time data[:creation_date_time] end |
#data ⇒ Types::TableDescription
Returns the data for this Aws::DynamoDB::Table. Calls
Client#describe_table if #data_loaded? is false.
510 511 512 513 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 510 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
518 519 520 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 518 def data_loaded? !!@data end |
#delete(options = {}) ⇒ Types::DeleteTableOutput
628 629 630 631 632 633 634 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 628 def delete( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_table() end resp.data end |
#delete_item(options = {}) ⇒ Types::DeleteItemOutput
832 833 834 835 836 837 838 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 832 def delete_item( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_item() end resp.data end |
#deletion_protection_enabled ⇒ Boolean
Indicates whether deletion protection is enabled (true) or disabled (false) on the table.
399 400 401 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 399 def deletion_protection_enabled data[:deletion_protection_enabled] end |
#disassociation_protection_enabled ⇒ Boolean
Specifies whether disassociation protection is enabled (true) or
disabled (false) for the local global table replica. Protection is
enabled by default.
407 408 409 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 407 def disassociation_protection_enabled data[:disassociation_protection_enabled] end |
#get_item(options = {}) ⇒ Types::GetItemOutput
957 958 959 960 961 962 963 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 957 def get_item( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.get_item() end resp.data end |
#global_secondary_indexes ⇒ Array<Types::GlobalSecondaryIndexDescription>
The global secondary indexes, if any, on the table. Each index is scoped to a given partition key value. Each element is composed of:
Backfilling- If true, then the index is currently in the backfilling phase. Backfilling occurs only when a new global secondary index is added to the table. It is the process by which DynamoDB populates the new index with data from the table. (This attribute does not appear for indexes that were created during aCreateTableoperation.)You can delete an index that is being created during the
Backfillingphase whenIndexStatusis set to CREATING andBackfillingis true. You can't delete the index that is being created whenIndexStatusis set to CREATING andBackfillingis false. (This attribute does not appear for indexes that were created during aCreateTableoperation.)IndexName- The name of the global secondary index.IndexSizeBytes- The total size of the global secondary index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.IndexStatus- The current status of the global secondary index:CREATING- The index is being created.UPDATING- The index is being updated.DELETING- The index is being deleted.ACTIVE- The index is ready for use.
ItemCount- The number of items in the global secondary index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.KeySchema- Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.Projection- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:ProjectionType- One of the following:KEYS_ONLY- Only the index and primary keys are projected into the index.INCLUDE- In addition to the attributes described inKEYS_ONLY, the secondary index will include other non-key attributes that you specify.ALL- All of the table attributes are projected into the index.
NonKeyAttributes- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total. This limit only applies when you specify the ProjectionType ofINCLUDE. You still can specify the ProjectionType ofALLto project all attributes from the source table, even if the table has more than 100 attributes.
ProvisionedThroughput- The provisioned throughput settings for the global secondary index, consisting of read and write capacity units, along with data about increases and decreases.
If the table is in the DELETING state, no information about indexes
will be returned.
293 294 295 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 293 def global_secondary_indexes data[:global_secondary_indexes] end |
#global_table_settings_replication_mode ⇒ String
Indicates one of the settings synchronization modes for the global table:
ENABLED: Indicates that the settings synchronization mode for the global table is enabled.DISABLED: Indicates that the settings synchronization mode for the global table is disabled.ENABLED_WITH_OVERRIDES: This mode is set by default for a same account global table. Indicates that certain global table settings can be overridden.
367 368 369 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 367 def global_table_settings_replication_mode data[:global_table_settings_replication_mode] end |
#global_table_version ⇒ String
Represents the version of global tables in use, if the table is replicated across Amazon Web Services Regions.
334 335 336 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 334 def global_table_version data[:global_table_version] end |
#global_table_witnesses ⇒ Array<Types::GlobalTableWitnessDescription>
The witness Region and its current status in the MRSC global table. Only one witness Region can be configured per MRSC global table.
350 351 352 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 350 def global_table_witnesses data[:global_table_witnesses] end |
#item_count ⇒ Integer
The number of items in the specified table. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
142 143 144 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 142 def item_count data[:item_count] end |
#key_schema ⇒ Array<Types::KeySchemaElement>
The primary key structure for the table. Each KeySchemaElement
consists of:
AttributeName- The name of the attribute.KeyType- The role of the attribute:HASH- partition keyRANGE- sort keyThe partition key of an item is also known as its hash attribute. The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute. The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
For more information about primary keys, see Primary Key in the Amazon DynamoDB Developer Guide.
80 81 82 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 80 def key_schema data[:key_schema] end |
#latest_stream_arn ⇒ String
The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table.
323 324 325 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 323 def latest_stream_arn data[:latest_stream_arn] end |
#latest_stream_label ⇒ String
A timestamp, in ISO 8601 format, for this stream.
Note that LatestStreamLabel is not a unique identifier for the
stream, because it is possible that a stream from another table might
have the same timestamp. However, the combination of the following
three elements is guaranteed to be unique:
Amazon Web Services customer ID
Table name
StreamLabel
316 317 318 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 316 def latest_stream_label data[:latest_stream_label] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::DynamoDB::Table.
Returns self making it possible to chain methods.
table.reload.data
498 499 500 501 502 503 504 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 498 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_table(table_name: @name) end @data = resp.table self end |
#local_secondary_indexes ⇒ Array<Types::LocalSecondaryIndexDescription>
Represents one or more local secondary indexes on the table. Each index is scoped to a given partition key value. Tables with one or more local secondary indexes are subject to an item collection size limit, where the amount of data within a given item collection cannot exceed 10 GB. Each element is composed of:
IndexName- The name of the local secondary index.KeySchema- Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.Projection- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:ProjectionType- One of the following:KEYS_ONLY- Only the index and primary keys are projected into the index.INCLUDE- Only the specified table attributes are projected into the index. The list of projected attributes is inNonKeyAttributes.ALL- All of the table attributes are projected into the index.
NonKeyAttributes- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total. This limit only applies when you specify the ProjectionType ofINCLUDE. You still can specify the ProjectionType ofALLto project all attributes from the source table, even if the table has more than 100 attributes.
IndexSizeBytes- Represents the total size of the index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.ItemCount- Represents the number of items in the index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
If the table is in the DELETING state, no information about indexes
will be returned.
215 216 217 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 215 def local_secondary_indexes data[:local_secondary_indexes] end |
#multi_region_consistency ⇒ String
Indicates one of the following consistency modes for a global table:
EVENTUAL: Indicates that the global table is configured for multi-Region eventual consistency (MREC).STRONG: Indicates that the global table is configured for multi-Region strong consistency (MRSC).
If you don't specify this field, the global table consistency mode
defaults to EVENTUAL. For more information about global tables
consistency modes, see Consistency modes in DynamoDB developer
guide.
442 443 444 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 442 def multi_region_consistency data[:multi_region_consistency] end |
#name ⇒ String Also known as: table_name
33 34 35 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 33 def name @name end |
#on_demand_throughput ⇒ Types::OnDemandThroughput
The maximum number of read and write units for the specified on-demand
table. If you use this parameter, you must specify
MaxReadRequestUnits, MaxWriteRequestUnits, or both.
415 416 417 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 415 def on_demand_throughput data[:on_demand_throughput] end |
#provisioned_throughput ⇒ Types::ProvisionedThroughputDescription
The provisioned throughput settings for the table, consisting of read and write capacity units, along with data about increases and decreases.
126 127 128 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 126 def provisioned_throughput data[:provisioned_throughput] end |
#put_item(options = {}) ⇒ Types::PutItemOutput
1195 1196 1197 1198 1199 1200 1201 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 1195 def put_item( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.put_item() end resp.data end |
#query(options = {}) ⇒ Types::QueryOutput
1585 1586 1587 1588 1589 1590 1591 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 1585 def query( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.query() end resp.data end |
#replicas ⇒ Array<Types::ReplicaDescription>
Represents replicas of the table.
After a successful disassociation, this list is absent or empty. To
confirm disassociation, also verify that TableStatus is ACTIVE.
343 344 345 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 343 def replicas data[:replicas] end |
#restore_summary ⇒ Types::RestoreSummary
Contains details for the restore.
373 374 375 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 373 def restore_summary data[:restore_summary] end |
#scan(options = {}) ⇒ Types::ScanOutput
1902 1903 1904 1905 1906 1907 1908 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 1902 def scan( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.scan() end resp.data end |
#sse_description ⇒ Types::SSEDescription
The description of the server-side encryption status on the specified table.
380 381 382 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 380 def sse_description data[:sse_description] end |
#stream_specification ⇒ Types::StreamSpecification
The current DynamoDB Streams configuration for the table.
299 300 301 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 299 def stream_specification data[:stream_specification] end |
#table_arn ⇒ String
The Amazon Resource Name (ARN) that uniquely identifies the table.
148 149 150 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 148 def table_arn data[:table_arn] end |
#table_class_summary ⇒ Types::TableClassSummary
Contains details of the table class.
392 393 394 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 392 def table_class_summary data[:table_class_summary] end |
#table_id ⇒ String
A unique identifier for the table, in UUID format, generated by DynamoDB when the table is created.
155 156 157 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 155 def table_id data[:table_id] end |
#table_size_bytes ⇒ Integer
The total size of the specified table, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
134 135 136 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 134 def table_size_bytes data[:table_size_bytes] end |
#table_status ⇒ String
The current state of the table:
CREATING- The table is being created.UPDATING- The table/index configuration is being updated. The table/index remains available for data operations whenUPDATING.DELETING- The table is being deleted.ACTIVE- The table is ready for use.INACCESSIBLE_ENCRYPTION_CREDENTIALS- The KMS key used to encrypt the table in inaccessible. Table operations may fail due to failure to use the KMS key. DynamoDB will initiate the table archival process when a table's KMS key remains inaccessible for more than seven days.ARCHIVING- The table is being archived. Operations are not allowed until archival is complete.ARCHIVED- The table has been archived. See the ArchivalReason for more information.
107 108 109 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 107 def table_status data[:table_status] end |
#update(options = {}) ⇒ Table
2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 2233 def update( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.update_table() end Table.new( name: @name, data: resp.data.table_description, client: @client ) end |
#update_item(options = {}) ⇒ Types::UpdateItemOutput
2543 2544 2545 2546 2547 2548 2549 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 2543 def update_item( = {}) = .merge(table_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.update_item() end resp.data end |
#vector_indexes ⇒ Array<Types::VectorIndexDescription>
The vector indexes, if any, on the table. Each element is composed of:
IndexName- The name of the vector index.IndexStatus- The current status of the vector index:CREATING,ACTIVE, orDELETING.Backfilling- Specifies whether the index is currently backfilling. During backfill,SearchVectorsoperations might return incomplete results.VectorAttribute- The attribute that contains vector embeddings.Dimensions- The number of dimensions in each vector.DistanceFunction- The distance function used to calculate similarity (COSINE,EUCLIDEAN, orDOT_PRODUCT).SearchSchema- The partition key and inline filter attributes for the vector index.Projection- Specifies attributes that are copied (projected) from the table into the vector index.IndexArn- The Amazon Resource Name (ARN) that uniquely identifies the index.IndexSizeBytes- The total size of the vector index, in bytes. Amazon DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.ItemCount- The number of items indexed in the vector index. Amazon DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
481 482 483 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 481 def vector_indexes data[:vector_indexes] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::DynamoDB::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
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
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 602 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |
#warm_throughput ⇒ Types::TableWarmThroughputDescription
Describes the warm throughput value of the base table.
421 422 423 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb', line 421 def warm_throughput data[:warm_throughput] end |