in aws-codeguruprofiler-profilinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/ListHandler.java [43:88]
public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final Logger logger) {
final List<ResourceModel> models = new ArrayList<>();
final String awsAccountId = request.getAwsAccountId();
try {
ListProfilingGroupsRequest listProfilingGroupsRequest = ListProfilingGroupsRequest.builder()
.includeDescription(true)
.maxResults(100)
.nextToken(request.getNextToken())
.build();
ListProfilingGroupsResponse response = proxy.injectCredentialsAndInvokeV2(listProfilingGroupsRequest, profilerClient::listProfilingGroups);
response.profilingGroups().forEach(pg -> {
NotificationConfiguration notificationConfiguration = getNotificationChannel(pg.name(), proxy, profilerClient).notificationConfiguration();
models.add(
ResourceModel.builder()
.profilingGroupName(pg.name())
.computePlatform(pg.computePlatformAsString())
.tags(new ArrayList<>(convertTagMapIntoSet(pg.tags())))
.anomalyDetectionNotificationConfiguration(convertNotificationConfigurationIntoChannelsList(notificationConfiguration))
.arn(pg.arn())
.agentPermissions(AgentPermissions.builder().principals(getPrincipalsFunction.apply(proxy, pg.name())).build())
.build()
);
});
logger.log(String.format("%d \"%s\" for accountId [%s] has been successfully listed for token %s!", models.size(), ResourceModel.TYPE_NAME, awsAccountId, request.getNextToken()));
return ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModels(models)
.nextToken(response.nextToken())
.status(OperationStatus.SUCCESS)
.build();
} catch (InternalServerException e) {
throw new CfnServiceInternalErrorException(e);
} catch (ThrottlingException e) {
throw new CfnThrottlingException(e);
}
}