software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest Java Examples

The following examples show how to use software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoServiceIntegrationTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that we correctly parse JSON error responses into SdkServiceException.
 */
@Test
public void testErrorHandling() throws Exception {

    DeleteTableRequest request = DeleteTableRequest.builder().tableName("non-existent-table").build();
    try {
        dynamo.deleteTable(request);
        fail("Expected an exception to be thrown");
    } catch (AwsServiceException exception) {
        assertNotEmpty(exception.awsErrorDetails().errorCode());
        assertNotEmpty(exception.awsErrorDetails().errorMessage());
        assertNotEmpty(exception.requestId());
        assertNotEmpty(exception.awsErrorDetails().serviceName());
        assertTrue(exception.statusCode() >= 400);
        assertTrue(exception.statusCode() < 600);
    }
}
 
Example #2
Source File: DeleteTable.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void deleteDynamoDBTable(DynamoDbClient ddb, String tableName) {

        DeleteTableRequest request = DeleteTableRequest.builder()
                .tableName(tableName)
                .build();

        try {
            ddb.deleteTable(request);

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        // snippet-end:[dynamodb.java2.delete_table.main]
        System.out.println(tableName +" was successfully deleted!");
    }
 
Example #3
Source File: AsyncBasicCrudTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name"))
                                                           .build())
                            .join();
}
 
Example #4
Source File: TransactWriteItemsTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-1"))
                                                      .build());
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-2"))
                                                      .build());
}
 
Example #5
Source File: BatchGetItemTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-1"))
                                                      .build());
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-2"))
                                                      .build());
}
 
Example #6
Source File: AsyncTransactGetItemsTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-1"))
                                                           .build()).join();
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-2"))
                                                           .build()).join();
}
 
Example #7
Source File: AsyncTransactWriteItemsTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-1"))
                                                           .build()).join();
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-2"))
                                                           .build()).join();
}
 
Example #8
Source File: AsyncBasicQueryTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name"))
                                                           .build())
                            .join();
}
 
Example #9
Source File: BatchWriteItemTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-1"))
                                                      .build());
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-2"))
                                                      .build());
}
 
Example #10
Source File: AsyncIndexQueryTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name"))
                                                           .build())
                            .join();
}
 
Example #11
Source File: AsyncBatchGetItemTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-1"))
                                                           .build()).join();
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-2"))
                                                           .build()).join();
}
 
Example #12
Source File: TransactGetItemsTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-1"))
                                                      .build());
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name-2"))
                                                      .build());
}
 
Example #13
Source File: AsyncBatchWriteItemTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-1"))
                                                           .build()).join();
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name-2"))
                                                           .build()).join();
}
 
Example #14
Source File: DynamoDBIntegrationTestBase.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Quick utility method to delete all tables when we have too much capacity
 * reserved for the region.
 */
public static void deleteAllTables() {
    ListTablesResponse listTables = dynamo.listTables(ListTablesRequest.builder().build());
    for (String name : listTables.tableNames()) {
        dynamo.deleteTable(DeleteTableRequest.builder().tableName(name).build());
    }
}
 
Example #15
Source File: TableUtils.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes the table and ignores any errors if it doesn't exist.
 * @param dynamo The Dynamo client to use.
 * @param deleteTableRequest The delete table request.
 * @return True if deleted, false otherwise.
 */
public static boolean deleteTableIfExists(final DynamoDbClient dynamo, final DeleteTableRequest deleteTableRequest) {
    try {
        dynamo.deleteTable(deleteTableRequest);
        return true;
    } catch (final ResourceNotFoundException e) {
        if (log.isTraceEnabled()) {
            log.trace("Table " + deleteTableRequest.tableName() + " does not exist", e);
        }
    }
    return false;
}
 
Example #16
Source File: DynamoDBTableResource.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(boolean waitTillFinished) {
    log.info(() -> "Deleting " + this + "...");
    getClient().deleteTable(DeleteTableRequest.builder().tableName(getCreateTableRequest().tableName()).build());

    if (waitTillFinished) {
        log.info(() -> "Waiting for " + this + " to become deleted...");
        DynamoDBTestBase.waitForTableToBecomeDeleted(getClient(), getCreateTableRequest().tableName());
    }
}
 
Example #17
Source File: AsyncIndexScanTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name"))
                                                           .build()).join();
}
 
Example #18
Source File: BasicScanTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #19
Source File: FlattenTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #20
Source File: DynamoDBIOTestHelper.java    From beam with Apache License 2.0 4 votes vote down vote up
static void deleteTestTable(String tableName) {
  DeleteTableRequest request = DeleteTableRequest.builder().tableName(tableName).build();
  dynamoDBClient.deleteTable(request);
}
 
Example #21
Source File: VersionedRecordTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #22
Source File: AsyncBasicScanTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbAsyncClient().deleteTable(DeleteTableRequest.builder()
                                                           .tableName(getConcreteTableName("table-name"))
                                                           .build()).join();
}
 
Example #23
Source File: BasicCrudTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #24
Source File: BasicQueryTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #25
Source File: IndexQueryTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #26
Source File: IndexScanTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@After
public void deleteTable() {
    getDynamoDbClient().deleteTable(DeleteTableRequest.builder()
                                                      .tableName(getConcreteTableName("table-name"))
                                                      .build());
}
 
Example #27
Source File: PaginatorIntegrationTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void cleanUpFixture() {
    dynamo.deleteTable(DeleteTableRequest.builder().tableName(TABLE_NAME).build());
}