-
Notifications
You must be signed in to change notification settings - Fork 4
/
delete_table.cpp
executable file
·76 lines (65 loc) · 2.42 KB
/
delete_table.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//snippet-sourcedescription:[delete_table.cpp demonstrates how to delete an Amazon DynamoDB table.]
//snippet-keyword:[AWS SDK for C++]
//snippet-keyword:[Code Sample]
//snippet-service:[Amazon DynamoDB]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[11/30/2021]
//snippet-sourceauthor:[scmacdon - aws]
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
//snippet-start:[dynamodb.cpp.delete_table.inc]
#include <aws/core/Aws.h>
#include <aws/core/utils/Outcome.h>
#include <aws/dynamodb/DynamoDBClient.h>
#include <aws/dynamodb/model/DeleteTableRequest.h>
#include <iostream>
//snippet-end:[dynamodb.cpp.delete_table.inc]
/*
Delete a DynamoDB table.
To run this C++ code example, ensure that you have setup your development environment, including your credentials.
For information, see this documentation topic:
https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/getting-started.html
*/
int main(int argc, char** argv)
{
const Aws::String USAGE =
"Usage:\n"
" run_delete_table <tableName> \n"
"Where:\n"
" tableName - the table to delete.\n"
"Example:\n"
" delete_table Music\n"
"**Warning** This program will actually delete the table that you specify!\n";
if (argc < 2)
{
std::cout << USAGE;
return 1;
}
Aws::SDKOptions options;
Aws::InitAPI(options);
{
const Aws::String table = (argv[1]);
//const Aws::String region = "us-east-1";
// snippet-start:[dynamodb.cpp.delete_table.code]
Aws::Client::ClientConfiguration clientConfig;
//if (!region.empty())
// clientConfig.region = region;
Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfig);
Aws::DynamoDB::Model::DeleteTableRequest dtr;
dtr.SetTableName(table);
const Aws::DynamoDB::Model::DeleteTableOutcome& result = dynamoClient.DeleteTable(dtr);
if (result.IsSuccess())
{
std::cout << "Your Table \"" << result.GetResult().GetTableDescription().GetTableName() << " was deleted!\n";
}
else
{
std::cout << "Failed to delete table: " << result.GetError().GetMessage();
}
// snippet-end:[dynamodb.cpp.delete_table.code]
}
Aws::ShutdownAPI(options);
return 0;
}