in aws-applicationinsights-application/src/main/java/software/amazon/applicationinsights/application/HandlerHelper.java [769:816]
public static ResourceModel generateReadModel(
String resourceGroupName,
ResourceModel model,
ResourceHandlerRequest<ResourceModel> request,
AmazonWebServicesClientProxy proxy,
ApplicationInsightsClient applicationInsightsClient) {
ResourceModel readModel = ResourceModel.builder().build();
readModel.setResourceGroupName(resourceGroupName);
readModel.setApplicationARN(String.format("arn:%s:applicationinsights:%s:%s:application/resource-group/%s",
request.getAwsPartition(),
request.getRegion(),
request.getAwsAccountId(),
resourceGroupName));
// set readModel application level attributes
DescribeApplicationResponse describeApplicationResponse = describeApplicationInsightsApplication(resourceGroupName, proxy, applicationInsightsClient);
readModel.setCWEMonitorEnabled(model == null ? describeApplicationResponse.applicationInfo().cweMonitorEnabled() :
getReadModelBooleanFromModel(model.getCWEMonitorEnabled(), describeApplicationResponse.applicationInfo().cweMonitorEnabled()));
readModel.setOpsCenterEnabled(model == null ? describeApplicationResponse.applicationInfo().opsCenterEnabled() :
getReadModelBooleanFromModel(model.getOpsCenterEnabled(), describeApplicationResponse.applicationInfo().opsCenterEnabled()));
readModel.setOpsItemSNSTopicArn(describeApplicationResponse.applicationInfo().opsItemSNSTopicArn());
// set readModel tags attribute
List<Tag> appTags = getApplicationTags(readModel.getApplicationARN(), proxy, applicationInsightsClient);
if (appTags != null && !appTags.isEmpty()) {
readModel.setTags(new ArrayList<>(translateSdkTagsToModelTags(appTags)));
}
// set readModel customComponents attribute
List<ApplicationComponent> appComponents = listApplicationComponents(resourceGroupName, proxy, applicationInsightsClient);
List<ApplicationComponent> appCustomComponents = appComponents.stream()
.filter(component -> component.resourceType().equals("CustomComponent"))
.collect(Collectors.toList());
if (appCustomComponents != null && !appCustomComponents.isEmpty()) {
readModel.setCustomComponents(tanslateSdkCustomComponentsToModelCustomComponents(appCustomComponents, resourceGroupName, proxy, applicationInsightsClient));
}
// set readModel logPatternSets attribute
ListLogPatternsResponse listLogPatternsResponse = listLogPatterns(resourceGroupName, proxy, applicationInsightsClient);
List<LogPatternSet> appLogPatternSets = translateSdkLogPatternsToModelLogPatternSets(listLogPatternsResponse.logPatterns());
if (appLogPatternSets != null && !appLogPatternSets.isEmpty()) {
readModel.setLogPatternSets(appLogPatternSets);
}
return readModel;
}