Use ListDatasetGroups with an AWS SDK or CLI - Amazon Forecast

Use ListDatasetGroups with an AWS SDK or CLI

The following code example shows how to use ListDatasetGroups.

SDK for Java 2.x

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

import; import; import; import; import; import; 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: * * */ 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); } } }

For a complete list of AWS SDK developer guides and code examples, see Using Forecast with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.