This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

Overview

The following operations allow you to work with tables. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with tables, see Sample configuration.

OperationDescription
createTableCreates a new table.
deleteTableDeletes a table.
describeTableReturns information about the table.
listTablesReturns an array of table names.
updateTableUpdates a table.
describeLimitsReturns the current provisioned-capacity limits.

Operation details

This section provides further details on the operations related to tables.

Creating a table

The createTable operation creates a new table, table names must be unique within each region.

createTable
<amazondynamodb.createTable>
    <attributeDefinitions>{$ctx:attributeDefinitions}</attributeDefinitions>
    <tableName>{$ctx:tableName}</tableName>
    <keySchema>{$ctx:keySchema}</keySchema>
    <localSecondaryIndexes>{$ctx:localSecondaryIndexes}</localSecondaryIndexes>
    <provisionedThroughput>{$ctx:provisionedThroughput}</provisionedThroughput>
    <StreamSpecification>{$ctx:StreamSpecification}</StreamSpecification>
    <globalSecondaryIndexes>{$ctx:globalSecondaryIndexes}</globalSecondaryIndexes>
</amazondynamodb.createTable>
Properties
  • tableName: Required - The name of the table to create.(Minimum length of 3. Maximum length of 255.)
  • attributeDefinitions: Required - An array of attributes that describe the key schema for the table and indexes.
  • keySchema: Required - Specifies the attributes that make up the primary key for a table or an index. The attributes in keySchema must also be defined in the attributeDefinitions array. Each KeySchemaElement in the array is composed of:
    • AttributeName - The name of this key attribute.

    • KeyType - The role that the key attribute will assume:

                          HASH - partition key
                          RANGE - sort key

    Note that the partition key of an item is also known as its hash attribute and the sort key of an item is also known as its range attribute. For a simple primary key (partition key), you must provide exactly one element with a KeyType of HASH. 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 KeyType of HASH, and the second element must have a KeyType of RANGE.

  • localSecondaryIndexes: Optional -  One or more local secondary indexes (the maximum is five) to be created on the table. Each index is scoped to a given partition key value. There is a 10 GB size limit per partition key value; otherwise, the size of a local secondary index is unconstrained. Each local secondary index in the array includes the following:
    • IndexName The name of the local secondary index. Must be unique only for this table.

    • KeySchema Specifies the key schema for the local secondary index. 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 are in NonKeyAttributes.

        • 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 in NonKeyAttributes, summed across all of the secondary indexes, must not exceed 20.

  • provisionedThroughput: Required - Represents the provisioned throughput settings for a specified table or index.
  • StreamSpecification:  Optional - The settings for DynamoDB Streams on the table. These settings consist of:
    • StreamEnabled Indicates whether Streams is to be enabled (true) or disabled (false).

    • StreamViewType - When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values for StreamViewType are:

      • KEYS_ONLY Only the key attributes of the modified item are written to the stream.

      • NEW_IMAGE - The entire item, as it appears after it was modified, is written to the stream.

      • OLD_IMAGE - The entire item, as it appeared before it was modified, is written to the stream.

      • NEW_AND_OLD_IMAGES - Both the new and the old item images of the item are written to the stream.

  • globalSecondaryIndexes: Optional - One or more global secondary indexes (the maximum is five) to be created on the table. Each global secondary index in the array includes the following:
    • IndexName - The name of the global secondary index. Must be unique only for this table.

    • KeySchema - Specifies the key schema for the global secondary index.

    • 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 are in NonKeyAttributes.

        • 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 in NonKeyAttributes, summed across all of the secondary indexes, must not exceed 20.

    • ProvisionedThroughput - Specifies the key schema for the global secondary index.

Sample request

Following is a sample REST request that can be handled by the createTable operation.

Sample Request for createTable
{
	"accessKeyId":"AKIAxxxxxxxxxxxx",
	"secretAccessKey":"id4qxxxxxxxx",
	"region":"us-east-1",
	"blocking":"false",
	"attributeDefinitions": [
        {
            "AttributeName": "ForumName",
            "AttributeType": "S"
        },
        {
            "AttributeName": "Subject",
            "AttributeType": "S"
        },
        {
            "AttributeName": "LastPostDateTime",
            "AttributeType": "S"
        }
    ],
    "tableName": "Thread",
    "keySchema": [
        {
            "AttributeName": "ForumName",
            "KeyType": "HASH"
        },
        {
            "AttributeName": "Subject",
            "KeyType": "RANGE"
        }
    ],
    "localSecondaryIndexes": [
        {
            "IndexName": "LastPostIndex",
            "KeySchema": [
                {
                    "AttributeName": "ForumName",
                    "KeyType": "HASH"
                },
                {
                    "AttributeName": "LastPostDateTime",
                    "KeyType": "RANGE"
                }
            ],
            "Projection": {
                "ProjectionType": "KEYS_ONLY"
            }
        }
    ],
    "provisionedThroughput": {
        "ReadCapacityUnits": 5,
        "WriteCapacityUnits": 5
    }
} 
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html

Deleting a table

The deleteTable operation deletes a table and all of its items.  

deleteTable
<amazondynamodb.deleteTable>
    <tableName>{$ctx:tableName}</tableName>
</amazondynamodb.deleteTable>
Properties
  • tableName: Required - The name of the table to delete.(Minimum length of 3. Maximum length of 255.) 
Sample request

Following is a sample REST request that can be handled by the deleteTable operation.

Sample Request for deleteTable
{
	"accessKeyId":"AKIAxxxxxxxxxxxx",
	"secretAccessKey":"id4qxxxxxxxx",
	"region":"us-east-1",
	"blocking":"false",
    "tableName": "TestTable"
}
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html

Retrieving an information about the table

The describeTable operation returns information about the table, including the current status of the table, when it was created, the primary key schema, and any indexes on the table.

describeTable
<amazondynamodb.describeTable>
    <tableName>{$ctx:tableName}</tableName>
</amazondynamodb.describeTable>
Properties
  • tableName: Required - The name of the table to describe.(Minimum length of 3. Maximum length of 255.) 
Sample request

Following is a sample REST request that can be handled by the describeTable operation.

Sample Request for describeTable
{
	"accessKeyId":"AKIAxxxxxxxxxxxx",
	"secretAccessKey":"id4qxxxxxxxx",
	"region":"us-east-1",
	"blocking":"false",
    "tableName": "TestTable"
}
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html

Retrieving an array of table names

The listTables operation returns an array of table names. The output from listTables is paginated, with each page returning a maximum of 100 table names.

listTables
<amazondynamodb.listTables>
    <exclusiveStartTableName>{$ctx:exclusiveStartTableName}</exclusiveStartTableName>
    <limit>{$ctx:limit}</limit>
</amazondynamodb.listTables>
Properties
  • exclusiveStartTableName: Optional - The first table name that this operation will evaluate. Use the value that was returned for LastEvaluatedTableName in a previous operation, so that you can obtain the next page of results.
  • limit: Optional - A maximum number of table names to return. If this parameter is not specified, the limit is 100.

Sample request

Following is a sample REST request that can be handled by the describeTable operation.

Sample Request for listTables
{
	"accessKeyId":"AKIAxxxxxxxxxxxx",
	"secretAccessKey":"id4qxxxxxxxx",
	"region":"us-east-1",
	"blocking":"false",
	"exclusiveStartTableName":"Music",
	"limit":4
}
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html

Updating a table

The updateTable  operation updates provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table. You can only perform one of the following operations at once:

  • Modify the provisioned throughput settings of the table.
  • Enable or disable Streams on the table.
  • Remove a global secondary index from the table.
  • Create a new global secondary index on the table. Once the index begins backfilling, you can use updateTable to perform other operations.
updateTable
<amazondynamodb.updateTable>
    <tableName>{$ctx:tableName}</tableName>
    <attributeDefinitions>{$ctx:attributeDefinitions}</attributeDefinitions>
    <globalSecondaryIndexUpdates>{$ctx:globalSecondaryIndexUpdates}</globalSecondaryIndexUpdates>
    <StreamSpecification>{$ctx:StreamSpecification}</StreamSpecification>
    <provisionedThroughput>{$ctx:provisionedThroughput}</provisionedThroughput>
</amazondynamodb.updateTable>
Properties
  • tableName: Required - The name of the table to be updated.(Minimum length of 3. Maximum length of 255.) 
  • attributeDefinitions: Optional - An array of attributes that describe the key schema for the table and indexes. If you are adding a new global secondary index to the table, AttributeDefinitions must include the key element(s) of the new index.
  • globalSecondaryIndexUpdates: Optional - An array of one or more global secondary indexes for the table. For each index in the array, you can request one action: 
    • Create - add a new global secondary index to the table.

    • Update - modify the provisioned throughput settings of an existing global secondary index.

    • Delete - remove a global secondary index from the table.

  • StreamSpecification: Optional - Represents the DynamoDB Streams configuration for the table. 
  • provisionedThroughput: Optional - The new provisioned throughput settings for the specified table or index.
Sample request

Following is a sample REST request that can be handled by the  updateTable  operation.

Sample Request for updateTable
{  
   "accessKeyId":"AKIAxxxxxxxxxxxx",
   "secretAccessKey":"id4qxxxxxxxx",
   "region":"us-east-1",
   "blocking":"false",
   "tableName":"Thread",
   "provisionedThroughput":{  
      "ReadCapacityUnits":12,
      "WriteCapacityUnits":12
   }
}
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html

Retrieving the current provisioned-capacity limits

The   describeLimits  operation returns the current provisioned-capacity limits.

describeLimits
<amazondynamodb.describeLimits/>
Sample request  

Following is a sample REST request that can be handled by the  describeLimits  operation.

Sample Request for describeLimits
{  
   "accessKeyId":"AKIAxxxxxxxxxxxx",
   "secretAccessKey":"id4qxxxxxxxx",
   "region":"us-east-1",
   "blocking":"false"
}
Related Amazon DynamoDB documentation

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeLimits.html

Sample configuration

Following is a sample proxy service that illustrates how to connect to Amazon DynamoDB with the init operation and use the createTable operation. The sample request for this proxy can be found in createTable sample request. You can use this sample as a template for using other operations in this category. 

Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="amazondynamodb_createTable"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property expression="json-eval($.secretAccessKey)" name="secretAccessKey"/>
         <property expression="json-eval($.accessKeyId)" name="accessKeyId"/>
         <property expression="json-eval($.region)" name="region"/>
         <property expression="json-eval($.blocking)" name="blocking"/>
         <property expression="json-eval($.attributeDefinitions)" name="attributeDefinitions"/>
         <property expression="json-eval($.tableName)" name="tableName"/>
         <property expression="json-eval($.keySchema)" name="keySchema"/>
         <property expression="json-eval($.localSecondaryIndexes)" name="localSecondaryIndexes"/>
         <property expression="json-eval($.provisionedThroughput)" name="provisionedThroughput"/>
         <amazondynamodb.init>
            <secretAccessKey>{$ctx:secretAccessKey}</secretAccessKey>
            <accessKeyId>{$ctx:accessKeyId}</accessKeyId>
            <region>{$ctx:region}</region>
            <blocking>{$ctx:blocking}</blocking>
         </amazondynamodb.init>
         <amazondynamodb.createTable>
            <attributeDefinitions>{$ctx:attributeDefinitions}</attributeDefinitions>
            <tableName>{$ctx:tableName}</tableName>
            <keySchema>{$ctx:keySchema}</keySchema>
            <localSecondaryIndexes>{$ctx:localSecondaryIndexes}</localSecondaryIndexes>
            <provisionedThroughput>{$ctx:provisionedThroughput}</provisionedThroughput>
         </amazondynamodb.createTable>
         <respond/>
      </inSequence>
      <outSequence>
        <send/>
      </outSequence>
   </target>
   <description/>
</proxy>          

 

  • No labels