in aws-sso-instanceaccesscontrolattributeconfiguration/src/main/java/software/amazon/sso/instanceaccesscontrolattributeconfiguration/ReadHandler.java [31:85]
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 proxy.initiate("sso::describeInstanceAccessControlAttributeConfiguration", proxyClient, request.getDesiredResourceState(), callbackContext)
.translateToServiceRequest(Translator::translateToDescribeRequest)
.makeServiceCall((describeRequest, client) -> {
DescribeInstanceAccessControlAttributeConfigurationResponse response = null;
int throttlingReadAttempts = MAX_RETRY;
int iseReadAttempts = MAX_RETRY;
while (throttlingReadAttempts > RETRY_ATTEMPTS_ZERO && iseReadAttempts > RETRY_ATTEMPTS_ZERO) {
try {
response = proxy.injectCredentialsAndInvokeV2(describeRequest,
client.client()::describeInstanceAccessControlAttributeConfiguration);
logger.log(String.format("%s has successfully been read.", ResourceModel.TYPE_NAME));
break;
} catch (ThrottlingException te) {
throttlingReadAttempts = decrementAndWait(throttlingReadAttempts);
continue;
} catch (InternalServerException ise) {
iseReadAttempts = decrementAndWait(iseReadAttempts);
continue;
}
}
if (response != null) {
return response;
} else if (throttlingReadAttempts == RETRY_ATTEMPTS_ZERO) {
throw ThrottlingException.builder().message(THROTTLE_MESSAGE).build();
} else {
throw InternalServerException.builder().message(ISE_MESSAGE).build();
}
})
.handleError((describeRequest, 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 ThrottlingException) {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.Throttling);
} else {
return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.InternalFailure);
}
})
.done((describeRequest, describeResponse, proxyInvocation, model, context) -> {
String instanceArn = describeRequest.instanceArn();
return ProgressEvent.defaultSuccessHandler(Translator.translateFromDescribeResponse(describeResponse, instanceArn));
});
}