Esempio n. 1
0
        public async static Task <Document> writeDynamoTable(string tableRegion,
                                                             string tableName,
                                                             Document writeDocument,
                                                             string credential = @"embeded",
                                                             AmazonDynamoDBClient dynamoDBClient = null)
        {
            Console.WriteLine(tableName + ", " + writeDocument.ToJson());

            AmazonDynamoDBClient client;

            if (dynamoDBClient != null)
            {
                Console.WriteLine("Setting Client from Input");
                client = dynamoDBClient;
            }
            else
            {
                AmazonDynamoDBConfig clientConfig = new AmazonDynamoDBConfig();
                clientConfig.RegionEndpoint = RegionEndpoint.GetBySystemName(tableRegion);
                Console.WriteLine("Region set to " + tableRegion);
                client = new AmazonDynamoDBClient(clientConfig);
                Console.WriteLine("Setting Client to " + client.ToString());
            }

            Table table = Table.LoadTable(client, tableName);

            Console.WriteLine(tableName + " table loaded");

            return(await table.PutItemAsync(writeDocument));
        }