Amazon Forecast tidak lagi tersedia untuk pelanggan baru. Pelanggan Amazon Forecast yang ada dapat terus menggunakan layanan seperti biasa. Pelajari lebih lanjut”
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan ListDatasetGroups
dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanListDatasetGroups
.
- Java
-
- SDK untuk Java 2.x
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.
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);
}
}
}
Untuk daftar lengkap panduan pengembang AWS SDK dan contoh kode, lihatMenggunakan Forecast dengan AWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang versi SDK sebelumnya.