Exemplo n.º 1
0
 internal void DeleteEntities(EntityType tableName)
 {
     try
     {
         if (CheckingTableExistence(tableName.ToString()))
         {
             // Delete Existing Table...
             DynamoClient.DeleteTableAsync(tableName.ToString()).Wait();
             //Deleted Existing Table...
         }
     }
     catch
     {
         throw new Exception("Require collection not exists. Please try after a while");
     }
 }
        private async Task DeleteDynamoDbTableAsync(string tableName)
        {
            var response = new DeleteTableResponse();

            try
            {
                var deleteResponse = _dynamoDbClient.DeleteTableAsync(tableName);
                response = await deleteResponse;
            }
            catch (Exception ex)
            {
                Logger.Log($"ERROR: Failed to delete the table, because:\n {ex.Message}");
            }

            await WaitTillTableDeletedAsync(tableName, response);
        }
        public static async Task <bool> DeleteExampleTable(AmazonDynamoDBClient client)
        {
            Console.WriteLine("\n*** Deleting {0} Table ***", _tableName);

            var request = new DeleteTableRequest
            {
                TableName = _tableName
            };

            await client.DeleteTableAsync(request);

            Console.WriteLine("{0} is being deleted...", _tableName);
            WaitUntilTableDeleted(client, _tableName);

            return(true);
        }
Exemplo n.º 4
0
        public static async Task DeleteTableAsync()
        {
            #region delete_table
            using (var ddbClient = new AmazonDynamoDBClient())
            {
                var request = new DeleteTableRequest
                {
                    TableName = "TODOList"
                };

                var response = await ddbClient.DeleteTableAsync(request);

                Console.WriteLine($"Table {response.TableDescription.TableName} is deleted and current status is {response.TableDescription.TableStatus}");
            }
            #endregion
        }
        public static async Task Main(string[] args)
        {
            AmazonDynamoDBClient client = new AmazonDynamoDBClient();

            var tableName = "TryDaxTable";

            var request = new DeleteTableRequest()
            {
                TableName = tableName
            };

            var response = await client.DeleteTableAsync(request);

            Console.WriteLine("Hit <enter> to continue...");
            Console.ReadLine();
        }
Exemplo n.º 6
0
        private async Task DeleteTableAsync()
        {
            try
            {
                var deleteTableResponse = await client.DeleteTableAsync(new DeleteTableRequest()
                {
                    TableName = TableName
                });

                await WaitTillTableDeletedAsync(client, TableName, deleteTableResponse);
            }
            catch (ResourceNotFoundException)
            {
                // There is no such table.
            }
        }
Exemplo n.º 7
0
        private static async Task TryToDeleteTableAsync()
        {
            Console.WriteLine("\n*** Deleting table ***");

            if (await TryToGetTableStatusAsync(TableName) == null)
            {
                Console.WriteLine("Table does not exist...");
                return;
            }

            var request = new DeleteTableRequest
            {
                TableName = TableName
            };

            var response = await _client.DeleteTableAsync(request);

            Console.WriteLine("Table is being deleted...");
        }
        public async Task DeleteTable()
        {
            try
            {
                Console.WriteLine("\n*** Deleting table {0} ***", tableName);
                DeleteTableRequest request = new DeleteTableRequest
                {
                    TableName = tableName
                };

                DeleteTableResponse response = await client.DeleteTableAsync(request);

                Console.WriteLine("Table {0} is being deleted...", tableName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 9
0
 public static async Task DeleteTable(AmazonDynamoDBClient client, string tableName)
 {
     try
     {
         var response = await client.DeleteTableAsync(new DeleteTableRequest
         {
             TableName = tableName
         });
         await WaitTillTableDeleted(client, tableName, response);
     }
     catch (ResourceNotFoundException exRnf)
     {
         // There is no such table.
         for (Exception ex = exRnf; ex != null; ex = ex.InnerException)
         {
             Debug.WriteLine(ex.GetType().Name + " - " + ex.Message);
         }
     }
 }
        // snippet-end:[DynamoDB.dotnetv3.dynamodb-basics.ScanTable]

        // snippet-start:[DynamoDB.dotnetv3.dynamodb-basics.DeleteTableExample]
        public static async Task <bool> DeleteTableAsync(AmazonDynamoDBClient client, string tableName)
        {
            var request = new DeleteTableRequest
            {
                TableName = tableName,
            };

            var response = await client.DeleteTableAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"Table {response.TableDescription.TableName} successfully deleted.");
                return(true);
            }
            else
            {
                Console.WriteLine("Could not delete table.");
                return(false);
            }
        }
Exemplo n.º 11
0
        private void DeleteExampleTable()
        {
            this.displayMessage += ("\n*** Deleting table ***\n");
            var request = new DeleteTableRequest
            {
                TableName = tableName
            };

            client.DeleteTableAsync(request, (AmazonServiceResult result) =>
            {
                if (result.Exception != null)
                {
                    this.displayMessage += result.Exception.Message;
                    Debug.Log(result.Exception);
                    return;
                }
                var response = result.Response as DeleteTableResponse;

                this.displayMessage += ("Table " + response.TableDescription.TableName + " is being deleted... \nContinue !");
            }, null);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Delete a table async.
 /// </summary>
 /// <param name="tableName">The name of the table.</param>
 /// <returns>The async task.</returns>
 public async Task <DeleteTableResponse> DeleteTableAsync(string tableName)
 {
     return(await _client.DeleteTableAsync(new DeleteTableRequest(tableName)));
 }
Exemplo n.º 13
0
        private static async Task DeleteTable(AmazonDynamoDBClient client, string tableName)
        {
            await client.DeleteTableAsync(tableName);

            Console.WriteLine($"Table {tableName} was deleted.");
        }
Exemplo n.º 14
0
        public async Task TestToUpperFunction()
        {
            try
            {
                AmazonDynamoDBClient client = new AmazonDynamoDBClient(RegionEndpoint.USEast1);
                string mdtexttest           = "{\r\n \"RatingDataAsOf\": \"20190828\",\r\n  \"KeyCurrency\": \"USD\",\r\n  \"KeyRatingCreditType\": \"CORP\",\r\n  \"CreditRatingDerivedCDS\": \"AAA\",\r\n  \"CDSBenchmarkSpread\": \"17.506131099768\",\r\n  \"CDSBenchmarkSpread1Day\": \"17.499652220154\",\r\n  \"CDSBenchmarkSpread7Day\": \"17.689977433049\",\r\n  \"CDSBenchmarkSpread30Day\": \"17.612596564917\",\r\n  \"CDSBenchmarkSpread90Day\": \"17.531741482981\",\r\n  \"CDSBenchmarkSpread1Year\": \"16.721663421274\",\r\n  \"CDSBenchmarkSpread2Year\": \"22.812501511208\",\r\n  \"CDSBenchmarkSpread3Year\": \"28.591981044712\",\r\n  \"RatingPublishDate\": \"08/29/2019\"\r\n}";

                var requestDel = new DeleteTableRequest
                {
                    TableName = "MDSSourceDynamoDBTest1"
                };

                //
                var responseDel = await client.DeleteTableAsync(requestDel);

                var requestDelDest = new DeleteTableRequest
                {
                    TableName = "MDSSourceDynamoDBDest1"
                };
                var responseDelDest = await client.DeleteTableAsync(requestDelDest);

                System.Threading.Thread.Sleep(3000);
                List <KeySchemaElement> schemadest = new List <KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "GUID", KeyType = "HASH"
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "Data", KeyType = "RANGE"
                    }
                };

                // Define key attributes:
                //  The key attributes "Author" and "Title" are string types
                List <AttributeDefinition> definitionsdest = new List <AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "GUID", AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Data", AttributeType = "S"
                    }
                };

                // Define table throughput:
                //  Table has capacity of 20 reads and 50 writes
                ProvisionedThroughput throughputdest = new ProvisionedThroughput
                {
                    ReadCapacityUnits  = 20,
                    WriteCapacityUnits = 50
                };

                // Configure the CreateTable request
                CreateTableRequest requestdest = new CreateTableRequest
                {
                    TableName             = "MDSSourceDynamoDBDest1",
                    KeySchema             = schemadest,
                    ProvisionedThroughput = throughputdest,
                    AttributeDefinitions  = definitionsdest
                };


                // View new table properties
                var tableDescriptiondest = await client.CreateTableAsync(requestdest);

                Table  Catologdest = Table.LoadTable(client, tableDescriptiondest.TableDescription.TableName);
                string status      = null;
                // Let us wait until table is created. Call DescribeTable.
                do
                {
                    System.Threading.Thread.Sleep(3000); // Wait 5 seconds.
                    try
                    {
                        var res = await client.DescribeTableAsync(new DescribeTableRequest
                        {
                            TableName = "MDSSourceDynamoDBDest1"
                        });

                        Console.WriteLine("Table name: {0}, status: {1}",
                                          res.Table.TableName,
                                          res.Table.TableStatus);
                        status = res.Table.TableStatus;
                    }
                    catch (ResourceNotFoundException)
                    {
                        // DescribeTable is eventually consistent. So you might
                        // get resource not found. So we handle the potential exception.
                    }
                } while (status != "ACTIVE");
                //var context = new TestLambdaContext();
                //var function = new Function();

                //function.FunctionHandler(null, context);

                // Define table schema:
                //  Table has a hash-key "Author" and a range-key "Title"
                List <KeySchemaElement> schema = new List <KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "guid", KeyType = "HASH"
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "Data", KeyType = "RANGE"
                    }
                };

                // Define key attributes:
                //  The key attributes "Author" and "Title" are string types
                List <AttributeDefinition> definitions = new List <AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "guid", AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Data", AttributeType = "S"
                    }
                };

                // Define table throughput:
                //  Table has capacity of 20 reads and 50 writes
                ProvisionedThroughput throughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits  = 20,
                    WriteCapacityUnits = 50
                };

                // Configure the CreateTable request
                CreateTableRequest request = new CreateTableRequest
                {
                    TableName             = "MDSSourceDynamoDBTest1",
                    KeySchema             = schema,
                    ProvisionedThroughput = throughput,
                    AttributeDefinitions  = definitions
                };


                // View new table properties
                var tableDescription = await client.CreateTableAsync(request);

                Console.WriteLine("Table name: {0}", tableDescription.TableDescription.TableName);
                Console.WriteLine("Creation time: {0}", tableDescription.TableDescription.CreationDateTime);
                Console.WriteLine("Item count: {0}", tableDescription.TableDescription.ItemCount);
                Console.WriteLine("Table size (bytes): {0}", tableDescription.TableDescription.TableSizeBytes);
                Console.WriteLine("Table status: {0}", tableDescription.TableDescription.TableStatus);
                //dbList.Add()

                Table  Catolog    = Table.LoadTable(client, tableDescription.TableDescription.TableName);
                string statusdest = null;
                // Let us wait until table is created. Call DescribeTable.
                do
                {
                    System.Threading.Thread.Sleep(3000); // Wait 5 seconds.
                    try
                    {
                        var res = await client.DescribeTableAsync(new DescribeTableRequest
                        {
                            TableName = "MDSSourceDynamoDBTest1"
                        });

                        Console.WriteLine("Table name: {0}, status: {1}",
                                          res.Table.TableName,
                                          res.Table.TableStatus);
                        statusdest = res.Table.TableStatus;
                    }
                    catch (ResourceNotFoundException)
                    {
                        // DescribeTable is eventually consistent. So you might
                        // get resource not found. So we handle the potential exception.
                    }
                } while (statusdest != "ACTIVE");
                Console.WriteLine("\n*** listing tables ***");

                var data = new Document();
                data["guid"]           = Guid.NewGuid().ToString();
                data["Data"]           = mdtexttest;
                data["RSMappedValues"] = "CORP";
                data["timestamp"]      = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                data["UniqueRow"]      = Convert.ToInt64(String.Format("{0:d9}", (DateTime.Now.Ticks / 10) % 1000000000));
                data["Error"]          = "RS Mapping Missing";
                Document response = await Catolog.PutItemAsync(data);

                var context       = new TestLambdaContext();
                var function      = new Function();
                var responseFinal = await function.FunctionHandler(null, context);

                Assert.Equal(responseFinal, null);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 15
0
 private async Task DropTable()
 {
     await _dynamoClient.DeleteTableAsync(TableName);
 }
Exemplo n.º 16
0
        public async Task InitializeAsync()
        {
            var listTablesResponse = await _client.ListTablesAsync();

            if (listTablesResponse.TableNames.Contains(OutboxTableName))
            {
                await _client.DeleteTableAsync(OutboxTableName);
            }

            var tableDescription = await GetTableStatus(OutboxTableName);

            while (tableDescription == null || tableDescription.TableStatus != "NOT FOUND")
            {
                await Task.Delay(100);

                tableDescription = await GetTableStatus(OutboxTableName);
            }

            if (listTablesResponse.TableNames.Contains(OrgsTableName))
            {
                await _client.DeleteTableAsync(OrgsTableName);
            }
            tableDescription = await GetTableStatus(OrgsTableName);

            while (tableDescription == null || tableDescription.TableStatus != "NOT FOUND")
            {
                await Task.Delay(100);

                tableDescription = await GetTableStatus(OrgsTableName);
            }

            var createOutBoxTableRequest = new CreateTableRequest
            {
                TableName = OutboxTableName,
                KeySchema = new List <KeySchemaElement>
                {
                    new KeySchemaElement("Id", KeyType.HASH),
                    new KeySchemaElement("Created", KeyType.RANGE)
                },
                AttributeDefinitions = new List <AttributeDefinition>
                {
                    new AttributeDefinition("Id", ScalarAttributeType.S),
                    new AttributeDefinition("Created", ScalarAttributeType.N),
                },
                BillingMode         = BillingMode.PAY_PER_REQUEST,
                StreamSpecification = new StreamSpecification
                {
                    StreamEnabled  = true,
                    StreamViewType = StreamViewType.NEW_IMAGE
                }
            };
            await _client.CreateTableAsync(createOutBoxTableRequest);

            var describeTableResponse = await _client.DescribeTableAsync(OutboxTableName);

            _tableLatestStreamArn = describeTableResponse.Table.LatestStreamArn;

            var updateTimeToLiveRequest = new UpdateTimeToLiveRequest
            {
                TableName = OutboxTableName,
                TimeToLiveSpecification = new TimeToLiveSpecification
                {
                    AttributeName = "Expiration", // Must be epoch seconds
                    Enabled       = true
                }
            };
            await _client.UpdateTimeToLiveAsync(updateTimeToLiveRequest);

            var createOrgsTableRequest = new CreateTableRequest
            {
                TableName = OrgsTableName,
                KeySchema = new List <KeySchemaElement>
                {
                    new KeySchemaElement("Id", KeyType.HASH),
                    new KeySchemaElement("Name", KeyType.RANGE)
                },
                AttributeDefinitions = new List <AttributeDefinition>
                {
                    new AttributeDefinition("Id", ScalarAttributeType.N),
                    new AttributeDefinition("Name", ScalarAttributeType.S),
                },
                BillingMode = BillingMode.PAY_PER_REQUEST,
            };
            await _client.CreateTableAsync(createOrgsTableRequest);
        }
        public void DeleteTable()
        {
            var client = new AmazonDynamoDBClient(RegionEndpoint.EUWest1);

            client.DeleteTableAsync(TableName).Wait(30.Seconds());
        }
        public async Task TearDownResourcesAsync()
        {
            using (var cfClient = new AmazonCloudFormationClient())
            {
                var request = new DeleteStackRequest
                {
                    StackName = this.FrontendCloudFormationStack
                };

                try
                {
                    await cfClient.DeleteStackAsync(request);

                    Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} was not deleted: {e.Message}");
                }
            }

            using (var lambdaClient = new AmazonLambdaClient())
            {
                var request = new DeleteFunctionRequest
                {
                    FunctionName = this.DynanmoDBStreamLambdaFunction
                };

                try
                {
                    await lambdaClient.DeleteFunctionAsync(request);

                    Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} was not deleted: {e.Message}");
                }
            }

            using (var cognitoClient = new AmazonCognitoIdentityProviderClient())
            {
                var userPool = (await cognitoClient.ListUserPoolsAsync(new ListUserPoolsRequest {
                    MaxResults = 60
                })).UserPools
                               .FirstOrDefault(x => string.Equals(this.CognitoUserPool, x.Name));

                if (userPool != null)
                {
                    var request = new DeleteUserPoolRequest
                    {
                        UserPoolId = userPool.Id
                    };

                    try
                    {
                        await cognitoClient.DeleteUserPoolAsync(request);

                        Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} is deleted");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} was not deleted: {e.Message}");
                    }
                }
            }

            using (var ssmClient = new AmazonSimpleSystemsManagementClient())
            {
                try
                {
                    var parameters = (await ssmClient.GetParametersByPathAsync(new GetParametersByPathRequest
                    {
                        Path = this.ParameterStorePrefix,
                        Recursive = true
                    })).Parameters;

                    Console.WriteLine($"Found {parameters.Count} SSM parameters starting with {this.ParameterStorePrefix}");

                    foreach (var parameter in parameters)
                    {
                        try
                        {
                            await ssmClient.DeleteParameterAsync(new DeleteParameterRequest { Name = parameter.Name });

                            Console.WriteLine($"Parameter {parameter.Name} is deleted");
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"Parameter {parameter.Name} was not deleted: {e.Message}");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error deleting SSM Parameters: {e.Message}");
                }
            }

            using (var ddbClient = new AmazonDynamoDBClient())
            {
                var request = new DeleteTableRequest
                {
                    TableName = this.DynamoDBTableName
                };

                try
                {
                    await ddbClient.DeleteTableAsync(request);

                    Console.WriteLine($"Table {this.DynamoDBTableName} is deleted");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Table {this.DynamoDBTableName} was not deleted: {e.Message}");
                }
            }
        }
Exemplo n.º 19
0
 private void DeleteTable()
 {
     client.DeleteTableAsync(tableName).Wait();
     DynamoDBTests.WaitForTableStatus(client, tableName, null);
 }
Exemplo n.º 20
0
 private void DeleteTable(string name)
 {
     client.DeleteTableAsync(name).Wait();
     DynamoDBTests.WaitForTableStatus(client, name, null);
 }