public ProgressEvent handleRequest()

in aws-rekognition-project/src/main/java/software/amazon/rekognition/project/CreateHandler.java [19:61]


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

        final ResourceModel model = request.getDesiredResourceState();

        // Make sure the user is not trying to assign values to readOnly properties (e.g. ARN)
        if (hasReadOnlyProperties(model)) {
            throw new CfnInvalidRequestException("Attempting to set a ReadOnly Property.");
        }

        RekognitionClient rekognitionClient = RekognitionClient.create();
        CreateProjectRequest createProjectRequest = CreateProjectRequest.builder()
                .projectName(model.getProjectName())
                .build();

        CreateProjectResponse createProjectResponse = null;

        try {
            createProjectResponse = proxy.injectCredentialsAndInvokeV2(
                    createProjectRequest,
                    rekognitionClient::createProject);
        } catch (ResourceInUseException e) {
            final ResourceAlreadyExistsException resourceAlreadyExistsException =
                    new ResourceAlreadyExistsException(ResourceModel.TYPE_NAME, model.getProjectName(), e);

            logger.log(resourceAlreadyExistsException.getMessage());
            throw resourceAlreadyExistsException;
        }

        logger.log(String.format("Project: %s successfully created.", model.getProjectName()));
        ResourceModel responseResourceModel = ResourceModel.builder()
                .projectName(model.getProjectName())
                .arn(createProjectResponse.projectArn())
                .build();

        return ProgressEvent.<ResourceModel, CallbackContext>builder()
                .resourceModel(responseResourceModel)
                .status(OperationStatus.SUCCESS)
                .build();
    }