forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java v2: Add hello sos examples to RDS Service (awsdocs#5737)
- Loading branch information
1 parent
13f1d97
commit 63b55f2
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
javav2/example_code/rds/src/main/java/com/example/rds/DescribeDbClusters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//snippet-sourcedescription:[DescribeDbClusters.java describes existing Amazon Aurora DB clusters.] | ||
//snippet-keyword:[AWS SDK for Java v2] | ||
//snippet-service:[Amazon Relational Database Service] | ||
|
||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.example.rds; | ||
|
||
// snippet-start:[rds.java2.hello.main] | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.rds.RdsClient; | ||
import software.amazon.awssdk.services.rds.paginators.DescribeDBClustersIterable; | ||
|
||
public class DescribeDbClusters { | ||
public static void main(String[] args) { | ||
Region region = Region.US_EAST_1; | ||
RdsClient rdsClient = RdsClient.builder() | ||
.region(region) | ||
.build(); | ||
|
||
describeClusters(rdsClient); | ||
rdsClient.close(); | ||
} | ||
|
||
public static void describeClusters( RdsClient rdsClient) { | ||
DescribeDBClustersIterable clustersIterable = rdsClient.describeDBClustersPaginator(); | ||
clustersIterable.stream() | ||
.flatMap(r -> r.dbClusters().stream()) | ||
.forEach(cluster -> System.out.println("Database name: " + cluster.databaseName() + " Arn = " + cluster.dbClusterArn())); | ||
} | ||
} | ||
// snippet-end:[rds.java2.hello.main] |