in aws-kendra-index/src/main/java/software/amazon/kendra/index/ReadHandler.java [38:77]
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<KendraClient> proxyClient,
final Logger logger) {
this.logger = logger;
final ResourceModel model = request.getDesiredResourceState();
final DescribeIndexRequest describeIndexRequest = Translator.translateToReadRequest(model);
DescribeIndexResponse describeIndexResponse;
try {
describeIndexResponse = proxyClient.injectCredentialsAndInvokeV2(
describeIndexRequest, proxyClient.client()::describeIndex);
} catch (ResourceNotFoundException e) {
throw new CfnNotFoundException(ResourceModel.TYPE_NAME, describeIndexRequest.id(), e);
} catch (final AwsServiceException e) { // ResourceNotFoundException
/*
* While the handler contract states that the handler must always return a progress event,
* you may throw any instance of BaseHandlerException, as the wrapper map it to a progress event.
* Each BaseHandlerException maps to a specific error code, and you should map service exceptions as closely as possible
* to more specific error codes
*/
throw new CfnGeneralServiceException(DESCRIBE_INDEX, e); // e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/commit/2077c92299aeb9a68ae8f4418b5e932b12a8b186#diff-5761e3a9f732dc1ef84103dc4bc93399R56-R63
}
String indexArn = indexArnBuilder.build(request);
final ListTagsForResourceRequest listTagsForResourceRequest = Translator.translateToListTagsRequest(indexArn);
ListTagsForResourceResponse listTagsForResourceResponse;
try {
listTagsForResourceResponse = proxyClient.injectCredentialsAndInvokeV2(listTagsForResourceRequest,
proxyClient.client()::listTagsForResource);
} catch (ResourceInUseException e) {
throw new CfnGeneralServiceException(LIST_TAGS_FOR_RESOURCE, e);
}
return constructResourceModelFromResponse(describeIndexResponse, listTagsForResourceResponse, indexArn);
}