Use ListDatasetGroups with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListDatasetGroups with an AWS SDK or CLI

The following code example shows how to use ListDatasetGroups.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.forecast.ForecastClient; import software.amazon.awssdk.services.forecast.model.DatasetGroupSummary; import software.amazon.awssdk.services.forecast.model.ListDatasetGroupsRequest; import software.amazon.awssdk.services.forecast.model.ListDatasetGroupsResponse; import software.amazon.awssdk.services.forecast.model.ForecastException; import java.util.List; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListDataSetGroups { public static void main(String[] args) { Region region = Region.US_WEST_2; ForecastClient forecast = ForecastClient.builder() .region(region) .build(); listDataGroups(forecast); forecast.close(); } public static void listDataGroups(ForecastClient forecast) { try { ListDatasetGroupsRequest group = ListDatasetGroupsRequest.builder() .maxResults(10) .build(); ListDatasetGroupsResponse response = forecast.listDatasetGroups(group); List<DatasetGroupSummary> groups = response.datasetGroups(); for (DatasetGroupSummary myGroup : groups) { System.out.println("The Data Set name is " + myGroup.datasetGroupName()); } } catch (ForecastException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }