Sample code for 30+ languages & platforms
Rust

DynamoDB - DescribeTable

See more Amazon DynamoDB Examples

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.

Chilkat Rust Downloads

Rust

let rest = chilkat::Rest::new();

// Implements the following CURL command:

// curl -X POST https://dynamodb.us-west-2.amazonaws.com/ \
//   -H "Accept-Encoding: identity" \
//   -H "Content-Type: application/x-amz-json-1.0" \
//   -H "Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>" \
//   -H "X-Amz-Date: <Date>" \
//   -H "X-Amz-Target: DynamoDB_20120810.DescribeTable" \
//   -d '{
//     "TableName":"Thread"
// }'

// Use the following online tool to generate REST code from a CURL command
// Convert a cURL Command to REST Source Code

let auth_aws = chilkat::AuthAws::new();
auth_aws.set_access_key("AWS_ACCESS_KEY");
auth_aws.set_secret_key("AWS_SECRET_KEY");
// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
auth_aws.set_region("us-west-2");
auth_aws.set_service_name("dynamodb");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
let _ = rest.set_auth_aws(&auth_aws);

// URL: https://dynamodb.us-west-2.amazonaws.com/
let b_tls = true;
let port = 443;
let b_auto_reconnect = true;
// Don't forget to change the region domain (us-west-2.amazonaws.com) to your particular region.
if rest.connect("dynamodb.us-west-2.amazonaws.com", port, b_tls, b_auto_reconnect).is_err() {
    println!("ConnectFailReason: {}", rest.connect_fail_reason());
    println!("{}", rest.last_error_text());
    return;
}

// Note: The above code does not need to be repeatedly called for each REST request.
// The rest object can be setup once, and then many requests can be sent.  Chilkat will automatically
// reconnect within a FullRequest* method as needed.  It is only the very first connection that is explicitly
// made via the Connect method.

// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "TableName": "Thread"
// }

let json = chilkat::JsonObject::new();
let _ = json.update_string("TableName", "Thread");

let _ = rest.add_header("Content-Type", "application/x-amz-json-1.0");
let _ = rest.add_header("X-Amz-Target", "DynamoDB_20120810.DescribeTable");
let _ = rest.add_header("Accept-Encoding", "identity");

let sb_request_body = chilkat::StringBuilder::new();
let _ = json.emit_sb(&sb_request_body);
let sb_response_body = chilkat::StringBuilder::new();
if rest.full_request_sb("POST", "/", &sb_request_body, &sb_response_body).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let resp_status_code = rest.response_status_code();
println!("response status code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Status Code = {}", resp_status_code);
    println!("Response Header:");
    println!("{}", rest.response_header());
    println!("Response Body:");
    println!("{}", sb_response_body.get_as_string().unwrap_or_default());
    return;
}

let json_response = chilkat::JsonObject::new();
let _ = json_response.load_sb(&sb_response_body);

json_response.set_emit_compact(false);
println!("{}", json_response.emit().unwrap_or_default());

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "Table": {
//     "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/Thread",
//     "AttributeDefinitions": [
//       {
//         "AttributeName": "ForumName",
//         "AttributeType": "S"
//       },
//       {
//         "AttributeName": "LastPostDateTime",
//         "AttributeType": "S"
//       },
//       {
//         "AttributeName": "Subject",
//         "AttributeType": "S"
//       }
//     ],
//     "CreationDateTime": 1.363729002358E9,
//     "ItemCount": 0,
//     "KeySchema": [
//       {
//         "AttributeName": "ForumName",
//         "KeyType": "HASH"
//       },
//       {
//         "AttributeName": "Subject",
//         "KeyType": "RANGE"
//       }
//     ],
//     "LocalSecondaryIndexes": [
//       {
//         "IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/Thread/index/LastPostIndex",
//         "IndexName": "LastPostIndex",
//         "IndexSizeBytes": 0,
//         "ItemCount": 0,
//         "KeySchema": [
//           {
//             "AttributeName": "ForumName",
//             "KeyType": "HASH"
//           },
//           {
//             "AttributeName": "LastPostDateTime",
//             "KeyType": "RANGE"
//           }
//         ],
//         "Projection": {
//           "ProjectionType": "KEYS_ONLY"
//         }
//       }
//     ],
//     "ProvisionedThroughput": {
//       "NumberOfDecreasesToday": 0,
//       "ReadCapacityUnits": 5,
//       "WriteCapacityUnits": 5
//     },
//     "TableName": "Thread",
//     "TableSizeBytes": 0,
//     "TableStatus": "ACTIVE"
//   }
// }

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

let mut j: i32 = 0;
let mut count_j: i32 = 0;

let table_table_arn = json_response.string_of("Table.TableArn").unwrap_or_default();
let table_creation_date_time = json_response.string_of("Table.CreationDateTime").unwrap_or_default();
let table_item_count = json_response.int_of("Table.ItemCount");
let table_provisioned_throughput_number_of_decreases_today = json_response.int_of("Table.ProvisionedThroughput.NumberOfDecreasesToday");
let table_provisioned_throughput_read_capacity_units = json_response.int_of("Table.ProvisionedThroughput.ReadCapacityUnits");
let table_provisioned_throughput_write_capacity_units = json_response.int_of("Table.ProvisionedThroughput.WriteCapacityUnits");
let table_table_name = json_response.string_of("Table.TableName").unwrap_or_default();
let table_table_size_bytes = json_response.int_of("Table.TableSizeBytes");
let table_table_status = json_response.string_of("Table.TableStatus").unwrap_or_default();
let mut i = 0;
let mut count_i = json_response.size_of_array("Table.AttributeDefinitions");
while i < count_i {
    json_response.set_i(i);
    let _ = json_response.string_of("Table.AttributeDefinitions[i].AttributeName").unwrap_or_default();
    let _ = json_response.string_of("Table.AttributeDefinitions[i].AttributeType").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json_response.size_of_array("Table.KeySchema");
while i < count_i {
    json_response.set_i(i);
    let _ = json_response.string_of("Table.KeySchema[i].AttributeName").unwrap_or_default();
    let _ = json_response.string_of("Table.KeySchema[i].KeyType").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json_response.size_of_array("Table.LocalSecondaryIndexes");
while i < count_i {
    json_response.set_i(i);
    let _ = json_response.string_of("Table.LocalSecondaryIndexes[i].IndexArn").unwrap_or_default();
    let _ = json_response.string_of("Table.LocalSecondaryIndexes[i].IndexName").unwrap_or_default();
    let _ = json_response.int_of("Table.LocalSecondaryIndexes[i].IndexSizeBytes");
    let _ = json_response.int_of("Table.LocalSecondaryIndexes[i].ItemCount");
    let _ = json_response.string_of("Table.LocalSecondaryIndexes[i].Projection.ProjectionType").unwrap_or_default();
    j = 0;
    count_j = json_response.size_of_array("Table.LocalSecondaryIndexes[i].KeySchema");
    while j < count_j {
        json_response.set_j(j);
        let _ = json_response.string_of("Table.LocalSecondaryIndexes[i].KeySchema[j].AttributeName").unwrap_or_default();
        let _ = json_response.string_of("Table.LocalSecondaryIndexes[i].KeySchema[j].KeyType").unwrap_or_default();
        j = j + 1;
    }

    i = i + 1;
}