in preparedstatement/src/main/java/software/amazon/athena/preparedstatement/DeleteHandler.java [19:66]
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<AthenaClient> proxyClient,
final Logger logger) {
this.logger = logger;
return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
.then(progress ->
proxy.initiate("AWS-Athena-PreparedStatement::Create::PreExistanceCheck",
proxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToReadRequest)
.makeServiceCall((awsRequest, client) -> {
GetPreparedStatementResponse awsResponse = client.injectCredentialsAndInvokeV2(
awsRequest, client.client()::getPreparedStatement);
logger.log(String.format("%s has successfully been read.", ResourceModel.TYPE_NAME));
return awsResponse;
})
.handleError((awsRequest, exception, client, model, context) -> {
if (exception instanceof ResourceNotFoundException) {
return ProgressEvent.failed(model, context, HandlerErrorCode.NotFound,
exception.getMessage());
}
throw exception;
})
.progress()
)
.then(progress ->
proxy.initiate("AWS-Athena-PreparedStatement::Delete", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToDeleteRequest)
.makeServiceCall((awsRequest, client) -> {
DeletePreparedStatementResponse awsResponse;
try {
awsResponse = client.injectCredentialsAndInvokeV2(
awsRequest, client.client()::deletePreparedStatement);
} catch (final AwsServiceException e) {
throw new CfnGeneralServiceException(ResourceModel.TYPE_NAME, e);
}
logger.log(String.format("%s successfully deleted.", ResourceModel.TYPE_NAME));
return awsResponse;
})
.progress()
)
.then(progress -> ProgressEvent.defaultSuccessHandler(null));
}