Skip to content

Commit

Permalink
Java v2: Add hello sos examples to RDS Service (awsdocs#5737)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon authored and meyertst-aws committed Jan 4, 2024
1 parent 13f1d97 commit 63b55f2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .doc_gen/metadata/aurora_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ aurora_Hello:
synopsis: get started using &AUR;.
category: Hello
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/rds
sdkguide:
excerpts:
- description:
snippet_tags:
- rds.java2.hello.main
.NET:
versions:
- sdk_version: 3
Expand Down
9 changes: 9 additions & 0 deletions .doc_gen/metadata/rds_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ rds_Hello:
synopsis: get started using &RDS;.
category: Hello
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/rds
sdkguide:
excerpts:
- description:
snippet_tags:
- rds.java2.describe_instances.main
.NET:
versions:
- sdk_version: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

package com.example.rds;

// snippet-start:[rds.java2.describe_instances.main]
// snippet-start:[rds.java2.describe_instances.import]
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.rds.RdsClient;
import software.amazon.awssdk.services.rds.model.DescribeDbInstancesResponse;
Expand All @@ -28,20 +28,16 @@
public class DescribeDBInstances {

public static void main(String[] args) {

Region region = Region.US_EAST_1;
RdsClient rdsClient = RdsClient.builder()
.region(region)
.credentialsProvider(ProfileCredentialsProvider.create())
.build();

describeInstances(rdsClient) ;
rdsClient.close();
}

// snippet-start:[rds.java2.describe_instances.main]
public static void describeInstances(RdsClient rdsClient) {

try {
DescribeDbInstancesResponse response = rdsClient.describeDBInstances();
List<DBInstance> instanceList = response.dbInstances();
Expand Down
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]

0 comments on commit 63b55f2

Please sign in to comment.