software.amazon.awssdk.services.dynamodb.model.ListTablesRequest Java Examples
The following examples show how to use
software.amazon.awssdk.services.dynamodb.model.ListTablesRequest.
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: DynamoDBAsync.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws InterruptedException { // Creates a default async client with credentials and regions loaded from the environment DynamoDbAsyncClient client = DynamoDbAsyncClient.create(); CompletableFuture<ListTablesResponse> response = client.listTables(ListTablesRequest.builder() .build()); // Map the response to another CompletableFuture containing just the table names CompletableFuture<List<String>> tableNames = response.thenApply(ListTablesResponse::tableNames); // When future is complete (either successfully or in error) handle the response tableNames.whenComplete((tables, err) -> { try { if (tables != null) { tables.forEach(System.out::println); } else { // Handle error err.printStackTrace(); } } finally { // Lets the application shut down. Only close the client when you are completely done with it. client.close(); } }); tableNames.join(); }
Example #2
Source File: AsyncPagination.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
private static void useThirdPartySubscriber() { // snippet-start:[dynamodb.java2.async_pagination.async] System.out.println("running AutoPagination - using third party subscriber...\n"); DynamoDbAsyncClient asyncClient = DynamoDbAsyncClient.create(); ListTablesPublisher publisher = asyncClient.listTablesPaginator(ListTablesRequest.builder() .build()); // The Flowable class has many helper methods that work with any reactive streams compatible publisher implementation List<String> tables = Flowable.fromPublisher(publisher) .flatMapIterable(ListTablesResponse::tableNames) .toList() .blockingGet(); System.out.println(tables); // snippet-end:[dynamodb.java2.async_pagination.async] }
Example #3
Source File: SyncPagination.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void manualPagination(DynamoDbClient client) { System.out.println("running ManualPagination...\n"); ListTablesRequest listTablesRequest = ListTablesRequest.builder().limit(3).build(); boolean done = false; while (!done) { ListTablesResponse listTablesResponse = client.listTables(listTablesRequest); System.out.println(listTablesResponse.tableNames()); if (listTablesResponse.lastEvaluatedTableName() == null) { done = true; } listTablesRequest = listTablesRequest.toBuilder() .exclusiveStartTableName(listTablesResponse.lastEvaluatedTableName()) .build(); } }
Example #4
Source File: SyncPagination.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void autoPaginationWithResume(DynamoDbClient client) { System.out.println("running AutoPagination with resume in case of errors...\n"); ListTablesRequest listTablesRequest = ListTablesRequest.builder().limit(3).build(); ListTablesIterable responses = client.listTablesPaginator(listTablesRequest); ListTablesResponse lastSuccessfulPage = null; try { for (ListTablesResponse response : responses) { response.tableNames().forEach(System.out::println); lastSuccessfulPage = response; } } catch (DynamoDbException exception) { if (lastSuccessfulPage != null) { System.out.println(exception.getMessage()); } } }
Example #5
Source File: SecurityManagerIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * Basic smoke test that the SDK works with a security manager when given appropriate * permissions */ @Test public void securityManagerEnabled() { System.setProperty(JAVA_SECURITY_POLICY_PROPERTY, getPolicyUrl()); SecurityManager securityManager = new SecurityManager(); System.setSecurityManager(securityManager); DynamoDbClient ddb = DynamoDbClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).build(); assertNotNull(ddb.listTables(ListTablesRequest.builder().build())); }
Example #6
Source File: DynamoDBIntegrationTestBase.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * 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 #7
Source File: GlobalRequestHandlerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private void callApi(DynamoDbClient client) { try { client.listTables(ListTablesRequest.builder().build()); } catch (SdkException expected) { // Ignored or expected. } }
Example #8
Source File: AsyncPagination.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
private static void useThirdPartySubscriber_Reactor() { System.out.println("running AutoPagination - using third party subscriber...\n"); DynamoDbAsyncClient asyncClient = DynamoDbAsyncClient.create(); ListTablesPublisher publisher = asyncClient.listTablesPaginator(ListTablesRequest.builder() .build()); // The Flux class has many helper methods that work with any reactive streams compatible publisher implementation List<String> tables = Flux.from(publisher) .flatMapIterable(ListTablesResponse::tableNames) .collectList() .block(); System.out.println(tables); }
Example #9
Source File: TracingInterceptorTest.java From aws-xray-sdk-java with Apache License 2.0 | 4 votes |
@Test public void testResponseDescriptors() throws Exception { String responseBody = "{\"LastEvaluatedTableName\":\"baz\",\"TableNames\":[\"foo\",\"bar\",\"baz\"]}"; SdkHttpResponse mockResponse = SdkHttpResponse.builder() .statusCode(200) .putHeader("x-amzn-requestid", "1111-2222-3333-4444") .putHeader("Content-Length", "84") .putHeader("Content-Type", "application/x-amz-json-1.0") .build(); SdkHttpClient mockClient = mockSdkHttpClient(mockResponse, responseBody); DynamoDbClient client = DynamoDbClient.builder() .httpClient(mockClient) .endpointOverride(URI.create("http://example.com")) .region(Region.of("us-west-42")) .credentialsProvider(StaticCredentialsProvider.create( AwsSessionCredentials.create("key", "secret", "session") )) .overrideConfiguration(ClientOverrideConfiguration.builder() .addExecutionInterceptor(new TracingInterceptor()) .build() ) .build(); Segment segment = AWSXRay.getCurrentSegment(); client.listTables(ListTablesRequest.builder() .limit(3) .build() ); Assert.assertEquals(1, segment.getSubsegments().size()); Subsegment subsegment = segment.getSubsegments().get(0); Map<String, Object> awsStats = subsegment.getAws(); @SuppressWarnings("unchecked") Map<String, Object> httpResponseStats = (Map<String, Object>) subsegment.getHttp().get("response"); Assert.assertEquals("ListTables", awsStats.get("operation")); Assert.assertEquals(3, awsStats.get("limit")); Assert.assertEquals("1111-2222-3333-4444", awsStats.get("request_id")); Assert.assertEquals(3, awsStats.get("table_count")); Assert.assertEquals("us-west-42", awsStats.get("region")); Assert.assertEquals(0, awsStats.get("retries")); Assert.assertEquals(84L, httpResponseStats.get("content_length")); Assert.assertEquals(200, httpResponseStats.get("status")); Assert.assertEquals(false, subsegment.isInProgress()); }
Example #10
Source File: BaseResultIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Test public void responseMetadataInBaseResultIsSameAsMetadataCache() { ListTablesRequest request = ListTablesRequest.builder().build(); ListTablesResponse result = dynamoDB.listTables(request); assertThat(result.sdkHttpResponse().headers()).isNotNull(); }
Example #11
Source File: BaseResultIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
@Test public void httpMetadataInBaseResultIsValid() { ListTablesResponse result = dynamoDB.listTables(ListTablesRequest.builder().build()); assertThat(result.sdkHttpResponse().statusCode()).isEqualTo(200); assertThat(result.sdkHttpResponse().headers()).containsKey("x-amz-crc32"); }