in aws-sso-instanceaccesscontrolattributeconfiguration/src/main/java/software/amazon/sso/instanceaccesscontrolattributeconfiguration/DeleteHandler.java [30:83]
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<SsoAdminClient> proxyClient,
final Logger logger) {
this.logger = logger;
return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
.then(progress ->
proxy.initiate("sso::deleteInstanceAccessControlAttributeConfiguration", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToDeleteRequest)
.makeServiceCall((deleteRequest, client) -> proxy.injectCredentialsAndInvokeV2(deleteRequest,
client.client()::deleteInstanceAccessControlAttributeConfiguration))
.stabilize((deleteRequest, deleteResponse, client, model, context) -> {
DescribeInstanceAccessControlAttributeConfigurationRequest describeRequest = DescribeInstanceAccessControlAttributeConfigurationRequest
.builder()
.instanceArn(deleteRequest.instanceArn())
.build();
try {
proxy.injectCredentialsAndInvokeV2(describeRequest,
client.client()::describeInstanceAccessControlAttributeConfiguration);
} catch (ResourceNotFoundException e) {
logger.log("InstanceAccessControlAttributeConfiguration was deleted ");
return true;
} catch (ThrottlingException | InternalServerException e) {
context.decrementRetryAttempts();
return false;
}
logger.log(String.format("Failed to delete InstanceAccessControlAttributeConfiguration. RequestId: %s", deleteResponse.responseMetadata().requestId()));
throw new CfnGeneralServiceException("Fail to delete InstanceAccessControlAttributeConfiguration");
})
.handleError((deleteRequest, exception, client, model, context) -> {
if (exception instanceof ResourceNotFoundException) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.NotFound);
} else if (exception instanceof AccessDeniedException) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.AccessDenied);
} else if (exception instanceof ValidationException) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.InvalidRequest);
} else if (exception instanceof ConflictException) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.ResourceConflict);
} else if (exception instanceof ThrottlingException || exception instanceof InternalServerException) {
if (context.getRetryAttempts() == RETRY_ATTEMPTS_ZERO) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.GeneralServiceException);
}
context.decrementRetryAttempts();
return ProgressEvent.defaultInProgressHandler(context, getRetryTime(exception), model);
} else {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.GeneralServiceException);
}
})
.done((deleteRequest, deleteResponse, client, model, context) -> ProgressEvent.defaultSuccessHandler(null)));
}