The provisioned throughput settings for the specified table. The settings can be modified using the UpdateTable operation.

For current minimum and maximum provisioned throughput values, see Limits in the Amazon DynamoDB Developer Guide.

 /// <summary>
 /// Instantiates CreateTableRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table to create.</param>
 /// <param name="keySchema">Specifies the attributes that make up the primary key for a table or an index. The attributes in <code>KeySchema</code> must also be defined in the <code>AttributeDefinitions</code> array. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html">Data Model</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each <code>KeySchemaElement</code> in the array is composed of: <ul> <li>  <code>AttributeName</code> - The name of this key attribute. </li> <li>  <code>KeyType</code> - The role that the key attribute will assume: <ul> <li>  <code>HASH</code> - partition key </li> <li>  <code>RANGE</code> - sort key </li> </ul> </li> </ul> <note> The partition key of an item is also known as its <i>hash attribute</i>. The term "hash attribute" derives from DynamoDB' 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 <i>range attribute</i>. 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. </note> For a simple primary key (partition key), you must provide exactly one element with a <code>KeyType</code> of <code>HASH</code>. For a composite primary key (partition key and sort key), you must provide exactly two elements, in this order: The first element must have a <code>KeyType</code> of <code>HASH</code>, and the second element must have a <code>KeyType</code> of <code>RANGE</code>. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key">Specifying the Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="attributeDefinitions">An array of attributes that describe the key schema for the table and indexes.</param>
 /// <param name="provisionedThroughput">Represents the provisioned throughput settings for a specified table or index. The settings can be modified using the <code>UpdateTable</code> operation.  If you set BillingMode as <code>PROVISIONED</code>, you must specify this property. If you set BillingMode as <code>PAY_PER_REQUEST</code>, you cannot specify this property.  For current minimum and maximum provisioned throughput values, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 public CreateTableRequest(string tableName, List <KeySchemaElement> keySchema, List <AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput)
 {
     _tableName             = tableName;
     _keySchema             = keySchema;
     _attributeDefinitions  = attributeDefinitions;
     _provisionedThroughput = provisionedThroughput;
 }
        public void CreateCallHistoryTable()
        {
            if (CheckTableExists(TABLE_CALL_HISTORY))
            {
                Console.WriteLine(TABLE_CALL_HISTORY + " table already exists");
                return;
            }

            try
            {
                List<AttributeDefinition> lstAttribDefinitions = new System.Collections.Generic.List<AttributeDefinition>();
                List<KeySchemaElement> lstSchemaElements = new List<KeySchemaElement>();
                ProvisionedThroughput throughput = new ProvisionedThroughput() { ReadCapacityUnits = 10, WriteCapacityUnits = 5 };

                lstAttribDefinitions.Add(new AttributeDefinition { AttributeName = "CallHistoryId", AttributeType = ScalarAttributeType.N });
                lstAttribDefinitions.Add(new AttributeDefinition { AttributeName = "UCID", AttributeType = ScalarAttributeType.N });

                lstSchemaElements.Add(new KeySchemaElement() { AttributeName = "CallHistoryId", KeyType = "HASH" });
                lstSchemaElements.Add(new KeySchemaElement() { AttributeName = "UCID", KeyType = "RANGE" });

                CreateTableRequest tbRequest = new CreateTableRequest(TABLE_CALL_HISTORY, lstSchemaElements, lstAttribDefinitions, throughput);

                var response = _client.CreateTable(tbRequest);

                WaitUntilTableReady(TABLE_CALL_HISTORY);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Example #3
0
 /// <summary>
 /// Instantiates UpdateTableRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table to be updated.</param>
 /// <param name="provisionedThroughput">Sets the UpdateTableRequest ProvisionedThroughput property</param>
 public UpdateTableRequest(string tableName, ProvisionedThroughput provisionedThroughput)
 {
     _tableName             = tableName;
     _provisionedThroughput = provisionedThroughput;
 }
 /// <summary>
 /// Instantiates CreateTableRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table to create.</param>
 /// <param name="keySchema">Specifies the attributes that make up the primary key for a table or an index. The attributes in <i>KeySchema</i> must also be defined in the <i>AttributeDefinitions</i> array. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html">Data Model</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each <i>KeySchemaElement</i> in the array is composed of: <ul> <li> <i>AttributeName</i> - The name of this key attribute. </li> <li> <i>KeyType</i> - Determines whether the key attribute is <code>HASH</code> or <code>RANGE</code>. </li> </ul> For a primary key that consists of a hash attribute, you must provide exactly one element with a <i>KeyType</i> of <code>HASH</code>. For a primary key that consists of hash and range attributes, you must provide exactly two elements, in this order: The first element must have a <i>KeyType</i> of <code>HASH</code>, and the second element must have a <i>KeyType</i> of <code>RANGE</code>. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key">Specifying the Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="attributeDefinitions">An array of attributes that describe the key schema for the table and indexes.</param>
 /// <param name="provisionedThroughput">Sets the CreateTableRequest ProvisionedThroughput property</param>
 public CreateTableRequest(string tableName, List<KeySchemaElement> keySchema, List<AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput)
 {
     _tableName = tableName;
     _keySchema = keySchema;
     _attributeDefinitions = attributeDefinitions;
     _provisionedThroughput = provisionedThroughput;
 }
 /// <summary>
 /// Sets the ProvisionedThroughput property
 /// </summary>
 /// <param name="provisionedThroughput">The value to set for the ProvisionedThroughput property </param>
 /// <returns>this instance</returns>
 public CreateTableRequest WithProvisionedThroughput(ProvisionedThroughput provisionedThroughput)
 {
     this.provisionedThroughput = provisionedThroughput;
     return(this);
 }
 /// <summary>
 /// Sets the ProvisionedThroughput property
 /// </summary>
 /// <param name="provisionedThroughput">The value to set for the ProvisionedThroughput property </param>
 /// <returns>this instance</returns>
 public UpdateTableRequest WithProvisionedThroughput(ProvisionedThroughput provisionedThroughput)
 {
     this.provisionedThroughput = provisionedThroughput;
     return this;
 }
 /// <summary>
 /// Updates the provisioned throughput for the given table, or manages the global secondary
 /// indexes on the table.
 /// 
 ///  
 /// <para>
 /// You can increase or decrease the table's provisioned throughput values within the
 /// maximums and minimums listed in the <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a>
 /// section in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  
 /// <para>
 /// In addition, you can use <i>UpdateTable</i> to add, modify or delete global secondary
 /// indexes on the table. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html">Managing
 /// Global Secondary Indexes</a> in the <i>Amazon DynamoDB Developer Guide</i>. 
 /// </para>
 ///  
 /// <para>
 /// The table must be in the <code>ACTIVE</code> state for <i>UpdateTable</i> to succeed.
 /// <i>UpdateTable</i> is an asynchronous operation; while executing the operation, the
 /// table is in the <code>UPDATING</code> state. While the table is in the <code>UPDATING</code>
 /// state, the table still has the provisioned throughput from before the call. The table's
 /// new provisioned throughput settings go into effect when the table returns to the <code>ACTIVE</code>
 /// state; at that point, the <i>UpdateTable</i> operation is complete. 
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to be updated.</param>
 /// <param name="provisionedThroughput">A property of UpdateTableRequest used to execute the UpdateTable service method.</param>
 /// 
 /// <returns>The response from the UpdateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public UpdateTableResponse UpdateTable(string tableName, ProvisionedThroughput provisionedThroughput)
 {
     var request = new UpdateTableRequest();
     request.TableName = tableName;
     request.ProvisionedThroughput = provisionedThroughput;
     return UpdateTable(request);
 }
 /// <summary>
 /// The <i>CreateTable</i> operation adds a new table to your account. In an AWS account,
 /// table names must be unique within each region. That is, you can have two tables with
 /// same name if you create the tables in different regions.
 /// 
 ///  
 /// <para>
 /// <i>CreateTable</i> is an asynchronous operation. Upon receiving a <i>CreateTable</i>
 /// request, DynamoDB immediately returns a response with a <i>TableStatus</i> of <code>CREATING</code>.
 /// After the table is created, DynamoDB sets the <i>TableStatus</i> to <code>ACTIVE</code>.
 /// You can perform read and write operations only on an <code>ACTIVE</code> table. 
 /// </para>
 ///  
 /// <para>
 /// You can optionally define secondary indexes on the new table, as part of the <i>CreateTable</i>
 /// operation. If you want to create multiple tables with secondary indexes on them, you
 /// must create the tables sequentially. Only one table with secondary indexes can be
 /// in the <code>CREATING</code> state at any given time.
 /// </para>
 ///  
 /// <para>
 /// You can use the <i>DescribeTable</i> API to check the table status.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to create.</param>
 /// <param name="keySchema">Specifies the attributes that make up the primary key for a table or an index. The attributes in <i>KeySchema</i> must also be defined in the <i>AttributeDefinitions</i> array. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html">Data Model</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each <i>KeySchemaElement</i> in the array is composed of: <ul> <li> <i>AttributeName</i> - The name of this key attribute. </li> <li> <i>KeyType</i> - Determines whether the key attribute is <code>HASH</code> or <code>RANGE</code>. </li> </ul> For a primary key that consists of a hash attribute, you must provide exactly one element with a <i>KeyType</i> of <code>HASH</code>. For a primary key that consists of hash and range attributes, you must provide exactly two elements, in this order: The first element must have a <i>KeyType</i> of <code>HASH</code>, and the second element must have a <i>KeyType</i> of <code>RANGE</code>. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key">Specifying the Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="attributeDefinitions">An array of attributes that describe the key schema for the table and indexes.</param>
 /// <param name="provisionedThroughput">A property of CreateTableRequest used to execute the CreateTable service method.</param>
 /// 
 /// <returns>The response from the CreateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 public CreateTableResponse CreateTable(string tableName, List<KeySchemaElement> keySchema, List<AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput)
 {
     var request = new CreateTableRequest();
     request.TableName = tableName;
     request.KeySchema = keySchema;
     request.AttributeDefinitions = attributeDefinitions;
     request.ProvisionedThroughput = provisionedThroughput;
     return CreateTable(request);
 }
 /// <summary>
 /// Instantiates UpdateTableRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table to be updated.</param>
 /// <param name="provisionedThroughput">Sets the UpdateTableRequest ProvisionedThroughput property</param>
 public UpdateTableRequest(string tableName, ProvisionedThroughput provisionedThroughput)
 {
     _tableName = tableName;
     _provisionedThroughput = provisionedThroughput;
 }
 /// <summary>
 /// The <i>CreateTable</i> operation adds a new table to your account. In an AWS account,
 /// table names must be unique within each region. That is, you can have two tables with
 /// same name if you create the tables in different regions.
 /// 
 ///  
 /// <para>
 /// <i>CreateTable</i> is an asynchronous operation. Upon receiving a <i>CreateTable</i>
 /// request, DynamoDB immediately returns a response with a <i>TableStatus</i> of <code>CREATING</code>.
 /// After the table is created, DynamoDB sets the <i>TableStatus</i> to <code>ACTIVE</code>.
 /// You can perform read and write operations only on an <code>ACTIVE</code> table. 
 /// </para>
 ///  
 /// <para>
 /// You can optionally define secondary indexes on the new table, as part of the <i>CreateTable</i>
 /// operation. If you want to create multiple tables with secondary indexes on them, you
 /// must create the tables sequentially. Only one table with secondary indexes can be
 /// in the <code>CREATING</code> state at any given time.
 /// </para>
 ///  
 /// <para>
 /// You can use the <i>DescribeTable</i> API to check the table status.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to create.</param>
 /// <param name="keySchema">Specifies the attributes that make up the primary key for a table or an index. The attributes in <i>KeySchema</i> must also be defined in the <i>AttributeDefinitions</i> array. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html">Data Model</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each <i>KeySchemaElement</i> in the array is composed of: <ul> <li> <i>AttributeName</i> - The name of this key attribute. </li> <li> <i>KeyType</i> - Determines whether the key attribute is <code>HASH</code> or <code>RANGE</code>. </li> </ul> For a primary key that consists of a hash attribute, you must provide exactly one element with a <i>KeyType</i> of <code>HASH</code>. For a primary key that consists of hash and range attributes, you must provide exactly two elements, in this order: The first element must have a <i>KeyType</i> of <code>HASH</code>, and the second element must have a <i>KeyType</i> of <code>RANGE</code>. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key">Specifying the Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="attributeDefinitions">An array of attributes that describe the key schema for the table and indexes.</param>
 /// <param name="provisionedThroughput">A property of CreateTableRequest used to execute the CreateTable service method.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the CreateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 public Task<CreateTableResponse> CreateTableAsync(string tableName, List<KeySchemaElement> keySchema, List<AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new CreateTableRequest();
     request.TableName = tableName;
     request.KeySchema = keySchema;
     request.AttributeDefinitions = attributeDefinitions;
     request.ProvisionedThroughput = provisionedThroughput;
     return CreateTableAsync(request, cancellationToken);
 }
 /// <summary>
 /// Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB
 /// Streams settings for a given table.
 /// 
 ///  
 /// <para>
 /// You can only perform one of the following operations at once:
 /// </para>
 ///  <ul> <li>
 /// <para>
 /// Modify the provisioned throughput settings of the table.
 /// </para>
 /// </li> <li>
 /// <para>
 /// Enable or disable Streams on the table.
 /// </para>
 /// </li> <li>
 /// <para>
 /// Remove a global secondary index from the table.
 /// </para>
 /// </li> <li> 
 /// <para>
 /// Create a new global secondary index on the table. Once the index begins backfilling,
 /// you can use <i>UpdateTable</i> to perform other operations.
 /// </para>
 ///  </li> </ul> 
 /// <para>
 /// <i>UpdateTable</i> is an asynchronous operation; while it is executing, the table
 /// status changes from <code>ACTIVE</code> to <code>UPDATING</code>. While it is <code>UPDATING</code>,
 /// you cannot issue another <i>UpdateTable</i> request. When the table returns to the
 /// <code>ACTIVE</code> state, the <i>UpdateTable</i> operation is complete.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to be updated.</param>
 /// <param name="provisionedThroughput">A property of UpdateTableRequest used to execute the UpdateTable service method.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the UpdateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public Task<UpdateTableResponse> UpdateTableAsync(string tableName, ProvisionedThroughput provisionedThroughput, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new UpdateTableRequest();
     request.TableName = tableName;
     request.ProvisionedThroughput = provisionedThroughput;
     return UpdateTableAsync(request, cancellationToken);
 }
Example #12
0
        private void CreateLSITable()
        {
            #region CreateTable LSI Sample

            // Create a client
            AmazonDynamoDBClient client = new AmazonDynamoDBClient();

            // Define table schema:
            //  Table has a hash-key "Author" and a range-key "Title"
            List<KeySchemaElement> schema = new List<KeySchemaElement>
            {
                new KeySchemaElement
                {
                    AttributeName = "Author", KeyType = "HASH"
                },
                new KeySchemaElement
                {
                    AttributeName = "Title", KeyType = "RANGE"
                }
            };

            // Define local secondary indexes:
            //  Table has two indexes, one on "Year" and the other on "Setting"
            List<LocalSecondaryIndex> indexes = new List<LocalSecondaryIndex>
            {
                new LocalSecondaryIndex
                {
                    IndexName = "YearsIndex",
                    KeySchema = new List<KeySchemaElement>
                    {
                        // Hash key must match table hash key
                        new KeySchemaElement { AttributeName = "Author", KeyType = "HASH" },
                        // Secondary index on "Year" attribute
                        new KeySchemaElement { AttributeName = "Year", KeyType = "RANGE" }
                    },
                    // Projection type is set to ALL, all attributes returned for this index
                    Projection = new Projection
                    {
                        ProjectionType = "ALL"
                    }
                },
                new LocalSecondaryIndex
                {
                    IndexName = "SettingsIndex",
                    KeySchema = new List<KeySchemaElement>
                    {
                        // Hash key must match table hash key
                        new KeySchemaElement { AttributeName = "Author", KeyType = "HASH" },
                        // Secondary index on "Setting" attribute
                        new KeySchemaElement { AttributeName = "Setting", KeyType = "RANGE" }
                    },
                    // Projection type is set to INCLUDE, the specified attributes + keys are returned
                    Projection = new Projection
                    {
                        ProjectionType = "INCLUDE",
                        NonKeyAttributes = new List<string>
                        {
                            "Pages", "Genres"
                        }
                    }
                }
            };

            // Define key attributes:
            //  The key attributes "Author" and "Title" are string types.
            //  The local secondary index attributes are "Year" (numerical) and "Setting" (string).
            List<AttributeDefinition> definitions = new List<AttributeDefinition>
            {
                new AttributeDefinition
                {
                    AttributeName = "Author", AttributeType = "S"
                },
                new AttributeDefinition
                {
                    AttributeName = "Title", AttributeType = "S"
                },
                new AttributeDefinition
                {
                    AttributeName = "Year", AttributeType = "N"
                },
                new AttributeDefinition
                {
                    AttributeName = "Setting", AttributeType = "S"
                }
            };

            // Define table throughput:
            //  Table has capacity of 20 reads and 50 writes
            ProvisionedThroughput throughput = new ProvisionedThroughput
            {
                ReadCapacityUnits = 20,
                WriteCapacityUnits = 50
            };

            // Configure the CreateTable request
            CreateTableRequest request = new CreateTableRequest
            {
                TableName = "SampleTable",
                KeySchema = schema,
                ProvisionedThroughput = throughput,
                AttributeDefinitions = definitions,
                LocalSecondaryIndexes = indexes
            };

            // View new table properties
            TableDescription tableDescription = client.CreateTable(request).TableDescription;
            Console.WriteLine("Table name: {0}", tableDescription.TableName);
            Console.WriteLine("Creation time: {0}", tableDescription.CreationDateTime);
            Console.WriteLine("Item count: {0}", tableDescription.ItemCount);
            Console.WriteLine("Table size (bytes): {0}", tableDescription.TableSizeBytes);
            Console.WriteLine("Table status: {0}", tableDescription.TableStatus);

            // List table key schema
            List<KeySchemaElement> tableSchema = tableDescription.KeySchema;
            for (int i = 0; i < tableSchema.Count; i++)
            {
                KeySchemaElement element = tableSchema[i];
                Console.WriteLine("Key: Name = {0}, KeyType = {1}",
                    element.AttributeName, element.KeyType);
            }

            // List attribute definitions
            List<AttributeDefinition> attributeDefinitions = tableDescription.AttributeDefinitions;
            for (int i = 0; i < attributeDefinitions.Count; i++)
            {
                AttributeDefinition definition = attributeDefinitions[i];
                Console.WriteLine("Attribute: Name = {0}, Type = {1}",
                    definition.AttributeName, definition.AttributeType);
            }

            Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                tableDescription.ProvisionedThroughput.WriteCapacityUnits);

            #endregion
        }
Example #13
0
        public void DataPlaneSamples()
        {
            {
                #region CreateTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define table schema:
                //  Table has a hash-key "Author" and a range-key "Title"
                List<KeySchemaElement> schema = new List<KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Author", KeyType = "HASH"
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "Title", KeyType = "RANGE"
                    }
                };

                // Define key attributes:
                //  The key attributes "Author" and "Title" are string types
                List<AttributeDefinition> definitions = new List<AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Author", AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Title", AttributeType = "S"
                    }
                };

                // Define table throughput:
                //  Table has capacity of 20 reads and 50 writes
                ProvisionedThroughput throughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits = 20,
                    WriteCapacityUnits = 50
                };

                // Configure the CreateTable request
                CreateTableRequest request = new CreateTableRequest
                {
                    TableName = "SampleTable",
                    KeySchema = schema,
                    ProvisionedThroughput = throughput,
                    AttributeDefinitions = definitions
                };

                // View new table properties
                TableDescription tableDescription = client.CreateTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Creation time: {0}", tableDescription.CreationDateTime);
                Console.WriteLine("Item count: {0}", tableDescription.ItemCount);
                Console.WriteLine("Table size (bytes): {0}", tableDescription.TableSizeBytes);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);

                // List table key schema
                List<KeySchemaElement> tableSchema = tableDescription.KeySchema;
                for (int i = 0; i < tableSchema.Count; i++)
                {
                    KeySchemaElement element = tableSchema[i];
                    Console.WriteLine("Key: Name = {0}, KeyType = {1}",
                        element.AttributeName, element.KeyType);
                }

                // List attribute definitions
                List<AttributeDefinition> attributeDefinitions = tableDescription.AttributeDefinitions;
                for (int i = 0; i < attributeDefinitions.Count; i++)
                {
                    AttributeDefinition definition = attributeDefinitions[i];
                    Console.WriteLine("Attribute: Name = {0}, Type = {1}",
                        definition.AttributeName, definition.AttributeType);
                }

                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            {
                #region DescribeTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Create DescribeTable request
                DescribeTableRequest request = new DescribeTableRequest
                {
                    TableName = "SampleTable"
                };

                // Issue DescribeTable request and retrieve the table description
                TableDescription tableDescription = client.DescribeTable(request).Table;

                // View new table properties
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Creation time: {0}", tableDescription.CreationDateTime);
                Console.WriteLine("Item count: {0}", tableDescription.ItemCount);
                Console.WriteLine("Table size (bytes): {0}", tableDescription.TableSizeBytes);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);
                // List table key schema
                List<KeySchemaElement> tableSchema = tableDescription.KeySchema;
                for (int i = 0; i < tableSchema.Count; i++)
                {
                    KeySchemaElement element = tableSchema[i];
                    Console.WriteLine("Key: Name = {0}, KeyType = {1}",
                        element.AttributeName, element.KeyType);
                }

                // List attribute definitions
                List<AttributeDefinition> attributeDefinitions = tableDescription.AttributeDefinitions;
                for (int i = 0; i < attributeDefinitions.Count; i++)
                {
                    AttributeDefinition definition = attributeDefinitions[i];
                    Console.WriteLine("Attribute: Name = {0}, Type = {1}",
                        definition.AttributeName, definition.AttributeType);
                }
                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            {
                #region ListTables Paging Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                string startTableName = null;
                do
                {
                    // Configure ListTables request with the marker value
                    ListTablesRequest request = new ListTablesRequest
                    {
                        ExclusiveStartTableName = startTableName,
                    };

                    // Issue call
                    ListTablesResult result = client.ListTables(request);

                    // List retrieved tables
                    List<string> tables = result.TableNames;
                    Console.WriteLine("Retrieved tables: {0}",
                        string.Join(", ", tables));

                    // Update marker value from the result
                    startTableName = result.LastEvaluatedTableName;

                } while (!string.IsNullOrEmpty(startTableName)); // Test marker value

                #endregion
            }

            {
                #region ListTables NonPaging Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Issue call
                ListTablesResult result = client.ListTables();

                // List retrieved tables
                List<string> tables = result.TableNames;
                Console.WriteLine("Retrieved tables: {0}",
                    string.Join(", ", tables));

                #endregion
            }

            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                #region UpdateTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define new table throughput:
                //  Table will now have capacity of 40 reads and 50 writes
                ProvisionedThroughput throughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits = 40,
                    WriteCapacityUnits = 50
                };

                // Compose the UpdateTable request
                UpdateTableRequest request = new UpdateTableRequest
                {
                    TableName = "SampleTable",
                    ProvisionedThroughput = throughput
                };

                // View new table properties
                TableDescription tableDescription = client.UpdateTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                #region DeleteTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Configure the DeleteTable request
                DeleteTableRequest request = new DeleteTableRequest
                {
                    TableName = "SampleTable"
                };

                // Issue DeleteTable request and retrieve the table description
                TableDescription tableDescription = client.DeleteTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);

                #endregion
            }

        }
 /// <summary>
 /// The <i>CreateTable</i> operation adds a new table to your account. In an AWS account,
 /// table names must be unique within each region. That is, you can have two tables with
 /// same name if you create the tables in different regions.
 /// 
 ///  
 /// <para>
 /// <i>CreateTable</i> is an asynchronous operation. Upon receiving a <i>CreateTable</i>
 /// request, DynamoDB immediately returns a response with a <i>TableStatus</i> of <code>CREATING</code>.
 /// After the table is created, DynamoDB sets the <i>TableStatus</i> to <code>ACTIVE</code>.
 /// You can perform read and write operations only on an <code>ACTIVE</code> table. 
 /// </para>
 ///  
 /// <para>
 /// You can optionally define secondary indexes on the new table, as part of the <i>CreateTable</i>
 /// operation. If you want to create multiple tables with secondary indexes on them, you
 /// must create the tables sequentially. Only one table with secondary indexes can be
 /// in the <code>CREATING</code> state at any given time.
 /// </para>
 ///  
 /// <para>
 /// You can use the <i>DescribeTable</i> API to check the table status.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to create.</param>
 /// <param name="keySchema">Specifies the attributes that make up the primary key for a table or an index. The attributes in <i>KeySchema</i> must also be defined in the <i>AttributeDefinitions</i> array. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html">Data Model</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each <i>KeySchemaElement</i> in the array is composed of: <ul> <li> <i>AttributeName</i> - The name of this key attribute. </li> <li> <i>KeyType</i> - Determines whether the key attribute is <code>HASH</code> or <code>RANGE</code>. </li> </ul> For a primary key that consists of a hash attribute, you must provide exactly one element with a <i>KeyType</i> of <code>HASH</code>. For a primary key that consists of hash and range attributes, you must provide exactly two elements, in this order: The first element must have a <i>KeyType</i> of <code>HASH</code>, and the second element must have a <i>KeyType</i> of <code>RANGE</code>. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key">Specifying the Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="attributeDefinitions">An array of attributes that describe the key schema for the table and indexes.</param>
 /// <param name="provisionedThroughput">A property of CreateTableRequest used to execute the CreateTable service method.</param>
 /// 
 /// <returns>The response from the CreateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 public void CreateTableAsync(string tableName, List<KeySchemaElement> keySchema, List<AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput, AmazonServiceCallback<CreateTableRequest, CreateTableResponse> callback, AsyncOptions options = null)
 {
     var request = new CreateTableRequest();
     request.TableName = tableName;
     request.KeySchema = keySchema;
     request.AttributeDefinitions = attributeDefinitions;
     request.ProvisionedThroughput = provisionedThroughput;
     CreateTableAsync(request, callback, options);
 }
 /// <summary>
 /// Updates the provisioned throughput for the given table, or manages the global secondary
 /// indexes on the table.
 /// 
 ///  
 /// <para>
 /// You can increase or decrease the table's provisioned throughput values within the
 /// maximums and minimums listed in the <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html">Limits</a>
 /// section in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  
 /// <para>
 /// In addition, you can use <i>UpdateTable</i> to add, modify or delete global secondary
 /// indexes on the table. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html">Managing
 /// Global Secondary Indexes</a> in the <i>Amazon DynamoDB Developer Guide</i>. 
 /// </para>
 ///  
 /// <para>
 /// The table must be in the <code>ACTIVE</code> state for <i>UpdateTable</i> to succeed.
 /// <i>UpdateTable</i> is an asynchronous operation; while executing the operation, the
 /// table is in the <code>UPDATING</code> state. While the table is in the <code>UPDATING</code>
 /// state, the table still has the provisioned throughput from before the call. The table's
 /// new provisioned throughput settings go into effect when the table returns to the <code>ACTIVE</code>
 /// state; at that point, the <i>UpdateTable</i> operation is complete. 
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table to be updated.</param>
 /// <param name="provisionedThroughput">A property of UpdateTableRequest used to execute the UpdateTable service method.</param>
 /// 
 /// <returns>The response from the UpdateTable service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.LimitExceededException">
 /// The number of concurrent table requests (cumulative number of tables in the <code>CREATING</code>,
 /// <code>DELETING</code> or <code>UPDATING</code> state) exceeds the maximum allowed
 /// of 10.
 /// 
 ///  
 /// <para>
 /// Also, for tables with secondary indexes, only one of those tables can be in the <code>CREATING</code>
 /// state at any point in time. Do not attempt to create more than one such table simultaneously.
 /// </para>
 ///  
 /// <para>
 /// The total limit of tables in the <code>ACTIVE</code> state is 250.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceInUseException">
 /// The operation conflicts with the resource's availability. For example, you attempted
 /// to recreate an existing table, or tried to delete a table currently in the <code>CREATING</code>
 /// state.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public void UpdateTableAsync(string tableName, ProvisionedThroughput provisionedThroughput, AmazonServiceCallback<UpdateTableRequest, UpdateTableResponse> callback, AsyncOptions options = null)
 {
     var request = new UpdateTableRequest();
     request.TableName = tableName;
     request.ProvisionedThroughput = provisionedThroughput;
     UpdateTableAsync(request, callback, options);
 }