Use DeleteForecast with an AWS SDK - AWS SDK Code Examples

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

Use DeleteForecast with an AWS SDK

The following code example shows how to use DeleteForecast.

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.DeleteDatasetRequest; import software.amazon.awssdk.services.forecast.model.ForecastException; /** * 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 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 DeleteForecast in AWS SDK for Java 2.x API Reference.