public ProgressEvent handleRequest()

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


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

        final String awsAccountId = request.getAwsAccountId();
        final ResourceModel model = request.getDesiredResourceState();
        final String pgName = model.getProfilingGroupName();
        final Map<String, String> tags = tagsFromModel(model);
        final String computePlatform = model.getComputePlatform();

        final CreateProfilingGroupRequest createProfilingGroupRequest =
            getCreateProfilingGroupRequest(
                pgName,
                computePlatform,
                request.getClientRequestToken(),
                tags
            );

        safelyInvokeApi(() -> {
            proxy.injectCredentialsAndInvokeV2(createProfilingGroupRequest, profilerClient::createProfilingGroup);
        });

        if (tags.isEmpty()) {
            logger.log(format("%s [%s] for accountId [%s] has been successfully created!", ResourceModel.TYPE_NAME, pgName, awsAccountId));
        } else {
            logger.log(format("%s [%s] for accountId [%s] with tags [%s] has been successfully created!", ResourceModel.TYPE_NAME, pgName, awsAccountId, tags));
        }

        Optional<List<String>> principals = principalsForAgentPermissionsFrom(model);
        if (principals.isPresent()) {
            putAgentPermissions(proxy, logger, pgName, principals.get(), awsAccountId);
            logger.log(format("%s [%s] for accountId [%s] has been successfully updated with agent permissions!",
                ResourceModel.TYPE_NAME, pgName, awsAccountId));
        }

        Optional<List<Channel>> anomalyDetectionNotificationConfiguration = anomalyDetectionNotificationConfiguration(model);
        if (anomalyDetectionNotificationConfiguration.isPresent()) {
            putChannelNotifications(proxy, logger, pgName, awsAccountId, anomalyDetectionNotificationConfiguration.get());
            logger.log(format("%s [%s] for accountId [%s] has successfully added a Notification Channel!",
                    ResourceModel.TYPE_NAME, pgName, awsAccountId));
        }

        return ProgressEvent.defaultSuccessHandler(model);
    }