Use DeleteDataset with an AWS SDK or CLI - Amazon Forecast

Use DeleteDataset with an AWS SDK or CLI

The following code example shows how to use DeleteDataset.

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; /** * 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 DeleteDataset { public static void main(String[] args) { final String usage = """ Usage: <datasetARN>\s Where: datasetARN - The ARN of the data set to delete.\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String datasetARN = args[0]; Region region = Region.US_WEST_2; ForecastClient forecast = ForecastClient.builder() .region(region) .build(); deleteForecastDataSet(forecast, datasetARN); forecast.close(); } public static void deleteForecastDataSet(ForecastClient forecast, String myDataSetARN) { try { DeleteDatasetRequest deleteRequest = DeleteDatasetRequest.builder() .datasetArn(myDataSetARN) .build(); forecast.deleteDataset(deleteRequest); System.out.println("The Data Set was deleted"); } catch (ForecastException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
  • For API details, see DeleteDataset in AWS SDK for Java 2.x API Reference.

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.