public ProgressEvent handleRequest()

in aws-codeguruprofiler-profilinggroup/src/main/java/software/amazon/codeguruprofiler/profilinggroup/ReadHandler.java [45:84]


    public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final Logger logger) {

        final ResourceModel model = request.getDesiredResourceState();
        final String awsAccountId = request.getAwsAccountId();

        try {
            String pgName = model.getProfilingGroupName();
            DescribeProfilingGroupRequest describeProfilingGroupRequest = DescribeProfilingGroupRequest.builder()
                    .profilingGroupName(pgName)
                    .build();

            DescribeProfilingGroupResponse response = proxy.injectCredentialsAndInvokeV2(describeProfilingGroupRequest, profilerClient::describeProfilingGroup);
            model.setProfilingGroupName(response.profilingGroup().name()); // This is not needed but making sure the response is the same as the request!
            model.setArn(response.profilingGroup().arn());
            model.setComputePlatform(response.profilingGroup().computePlatformAsString());
            model.setTags(new ArrayList<>(convertTagMapIntoSet(response.profilingGroup().tags())));

            NotificationConfiguration notificationConfiguration = getNotificationChannel(pgName, proxy, profilerClient).notificationConfiguration();
            model.setAnomalyDetectionNotificationConfiguration(convertNotificationConfigurationIntoChannelsList(notificationConfiguration));

            model.setAgentPermissions(AgentPermissions.builder().principals(getPrincipalsFunction.apply(proxy, pgName)).build());

            logger.log(String.format("%s [%s] for accountId [%s] has been successfully read!", ResourceModel.TYPE_NAME, model.getProfilingGroupName(), awsAccountId));

            return ProgressEvent.defaultSuccessHandler(model);

        } catch (ResourceNotFoundException e) {
            throw new CfnNotFoundException(e);
        } catch (InternalServerException e) {
            throw new CfnServiceInternalErrorException(e);
        } catch (ThrottlingException e) {
            throw new CfnThrottlingException(e);
        } catch (ValidationException e) {
            throw new CfnInvalidRequestException(ResourceModel.TYPE_NAME + e.getMessage(), e);
        }
    }