Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java v2: Add hello sos examples to RDS Service #5737

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Loading