Example #1
0
        static async Task MainAsync(string kmsKeyId, string csvFilePath)
        {
            // Recommended Timestream write client SDK configuration:
            // - Set SDK retry count to 10
            // - Set RequestTimeout to 20 seconds
            var writeClientConfig = new AmazonTimestreamWriteConfig
            {
                Timeout        = TimeSpan.FromSeconds(20),
                MaxErrorRetry  = 10,
                RegionEndpoint = RegionEndpoint.USEast2
            };

            var queryClientConfig = new AmazonTimestreamQueryConfig
            {
                RegionEndpoint = RegionEndpoint.USEast2
            };

            var writeClient = new AmazonTimestreamWriteClient("awsAccessKeyId", "awsSecretAccessKey", writeClientConfig);
            var crudAndSimpleIngestionExample = new CrudAndSimpleIngestionExample(writeClient);
            var csvIngestionExample           = new CsvIngestionExample(writeClient);

            var queryClient  = new AmazonTimestreamQueryClient("awsAccessKeyId", "awsSecretAccessKey", queryClientConfig);
            var queryExample = new QueryExample(queryClient);

            await crudAndSimpleIngestionExample.CreateDatabase();

            await crudAndSimpleIngestionExample.DescribeDatabase();

            await crudAndSimpleIngestionExample.ListDatabases();

            if (kmsKeyId != null)
            {
                await crudAndSimpleIngestionExample.UpdateDatabase(kmsKeyId);
            }

            await crudAndSimpleIngestionExample.CreateTable();

            await crudAndSimpleIngestionExample.DescribeTable();

            await crudAndSimpleIngestionExample.ListTables();

            //  await crudAndSimpleIngestionExample.UpdateTable();

            // Simple records ingestion

            await crudAndSimpleIngestionExample.WriteRecords();

            // await crudAndSimpleIngestionExample.WriteRecordsWithCommonAttributes();

            // upsert records
            // await crudAndSimpleIngestionExample.WriteRecordsWithUpsert();

            if (csvFilePath != null)
            {
                // Bulk record ingestion for bootstrapping a table with fresh data
                await csvIngestionExample.BulkWriteRecords(csvFilePath);
            }

            await queryExample.MeasureQuery();

            // Try cancelling query
            // await queryExample.CancelQuery();

            // Run query with multiple pages
            //  await queryExample.RunQueryWithMultiplePages(20000);

            // Commenting out clean up.
            await crudAndSimpleIngestionExample.DeleteTable();

            await crudAndSimpleIngestionExample.DeleteDatabase();
        }