protected ProgressEvent handleRequest()

in aws-kendra-index/src/main/java/software/amazon/kendra/index/CreateHandler.java [69:114]


    protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
            final AmazonWebServicesClientProxy proxy,
            final ResourceHandlerRequest<ResourceModel> request,
            final CallbackContext callbackContext,
            final ProxyClient<KendraClient> proxyClient,
            final Logger logger) {

        this.logger = logger;

        // TODO: Adjust Progress Chain according to your implementation
        // https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/src/main/java/software/amazon/cloudformation/proxy/CallChain.java

        return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)

                // STEP 1 [check if resource already exists]
                // if target API does not support 'ResourceAlreadyExistsException' then following check is required
                // for more information -> https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html
                //.then(progress -> checkForPreCreateResourceExistence(proxy, request, progress))

                // STEP 2 [create progress chain - required for resource creation]
                .then(progress ->
                        // If your service API throws 'ResourceAlreadyExistsException' for create requests then CreateHandler can return just proxy.initiate construction
                        // STEP 2.0 [initialize a proxy context]
                        proxy.initiate("AWS-Kendra-Index::Create", proxyClient, request.getDesiredResourceState(), callbackContext)
                                .translateToServiceRequest(Translator::translateToCreateRequest)
                                .makeServiceCall(this::createIndex)
                                .done(this::setId)
                )
                // stabilize
                .then(progress -> stabilize(proxy, proxyClient, progress, "AWS-Kendra-Index::PostCreateStabilize"))
                // STEP 3 [TODO: post create and stabilize update]
                .then(progress ->
                        // If your resource is provisioned through multiple API calls, you will need to apply each subsequent update
                        // STEP 3.0 [initialize a proxy context]
                        proxy.initiate("AWS-Kendra-Index::PostCreateUpdate", proxyClient, request.getDesiredResourceState(), callbackContext)
                                // STEP 3.1 [TODO: construct a body of a request]
                                .translateToServiceRequest(this::translateToPostCreateUpdateIndexRequest)
                                // STEP 3.2 [TODO: make an api call]
                                .makeServiceCall(this::postCreate)
                                .progress()
                )
                // stabilize again because VCU changes can cause the index to enter UPDATING state
                .then(progress -> stabilize(proxy, proxyClient, progress, "AWS-Kendra-Index::PostCreateUpdateStabilize"))
                // STEP 4 [TODO: describe call/chain to return the resource model]
                .then(progress -> new ReadHandler(indexArnBuilder).handleRequest(proxy, request, callbackContext, proxyClient, logger));
    }