private ProgressEvent createIntegration()

in aws-customerprofiles-integration/src/main/java/software/amazon/customerprofiles/integration/CreateHandler.java [91:152]


    private ProgressEvent<ResourceModel, CallbackContext> createIntegration(
            final AmazonWebServicesClientProxy proxy,
            final ResourceHandlerRequest<ResourceModel> request,
            final Logger logger
    ) {
        final ResourceModel model = request.getDesiredResourceState();

        Map<String, String> resourceTag;
        if (request.getDesiredResourceTags() == null) {
            resourceTag = null;
        } else if (request.getDesiredResourceTags().isEmpty()) {
            resourceTag = null;
        } else {
            resourceTag = request.getDesiredResourceTags();
        }
        PutIntegrationRequest putIntegrationRequest = PutIntegrationRequest.builder()
                .domainName(model.getDomainName())
                .objectTypeName(model.getObjectTypeName())
                .tags(resourceTag)
                .flowDefinition(buildServiceFlowDefinition(model.getFlowDefinition()))
                .uri(model.getUri())
                .objectTypeNames(Translator.mapListToObjectTypeNames(model.getObjectTypeNames()))
                .build();

        final PutIntegrationResponse putIntegrationResponse;
        try {
            putIntegrationResponse = proxy.injectCredentialsAndInvokeV2(putIntegrationRequest, client::putIntegration);
            logger.log(String.format("Integration Created with domainName = %s", model.getDomainName()));
        } catch (BadRequestException e) {
            // throw CfnAlreadyExistsException if a flow with the desired flow name already exists
            if (model.getFlowDefinition() != null && model.getFlowDefinition().getFlowName() != null) {
                String flowName = model.getFlowDefinition().getFlowName();
                if (e.getMessage() != null && e.getMessage().contains(String.format(FLOW_ALREADY_EXISTS_MESSAGE, flowName))) {
                    throw new CfnAlreadyExistsException(e);
                }
            }

            throw new CfnInvalidRequestException(e);
        } catch (AccessDeniedException e) {
            throw new CfnAccessDeniedException(e);
        } catch (ThrottlingException e) {
            throw new CfnThrottlingException(e);
        } catch (InternalServerException e) {
            throw new CfnServiceInternalErrorException(e);
        } catch (ResourceNotFoundException e) {
            throw new CfnNotFoundException(e);
        } catch (Exception e) {
            throw new CfnGeneralServiceException(e);
        }

        final ResourceModel responseModel = ResourceModel.builder()
                .createdAt(putIntegrationResponse.createdAt().toString())
                .domainName(putIntegrationResponse.domainName())
                .lastUpdatedAt(putIntegrationResponse.lastUpdatedAt().toString())
                .objectTypeName(putIntegrationResponse.objectTypeName())
                .tags(Translator.mapTagsToList(putIntegrationResponse.tags()))
                .uri(putIntegrationResponse.uri())
                .objectTypeNames(Translator.mapObjectTypeNamesToList(putIntegrationResponse.objectTypeNames()))
                .build();

        return ProgressEvent.defaultSuccessHandler(responseModel);
    }