Amazon Forecast is no longer available to new customers. Existing customers of
Amazon Forecast can continue to use the service as normal.
Learn more"
Use DeleteForecast
with an AWS SDK
The following code example shows how to use DeleteForecast
.
- Java
-
- SDK for Java 2.x
-
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 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.