private Boolean stabilize()

in aws-cloudformation-moduleversion/src/main/java/software/amazon/cloudformation/moduleversion/CreateHandler.java [102:142]


    private Boolean stabilize(
            final RegisterTypeRequest registerTypeRequest,
            final RegisterTypeResponse registerTypeResponse,
            final ProxyClient<CloudFormationClient> proxyClient,
            final ResourceModel model,
            final CallbackContext callbackContext) {

        final String registrationToken = callbackContext.getRegistrationToken();

        final DescribeTypeRegistrationResponse dtrResponse = describeModuleRegistration(
                Translator.translateToDescribeTypeRegistrationRequest(registrationToken), proxyClient, model);

        final String typeVersionArn = dtrResponse.typeVersionArn();
        if (typeVersionArn != null) {
            if (model.getArn() != null && !model.getArn().equals(typeVersionArn)) {
                final String message = String.format("ARN changed during stabilization, module=%s arn_before=%s arn_after=%s",
                        model.getModuleName(), model.getArn(), typeVersionArn);
                logger.log(message);
                throw new CfnGeneralServiceException(message);
            }
            model.setArn(typeVersionArn);
        } else {
            throw new CfnGeneralServiceException(String.format("ARN not provided during stabilization, module=%s arn=%s",
                    model.getModuleName(), model.getArn()));
        }

        logger.log(String.format("Polled registration status, status=%s module=%s arn=%s registration_token=%s registration_description=%s",
                dtrResponse.progressStatus(), model.getModuleName(), model.getArn(), registrationToken, dtrResponse.description()));
        switch (dtrResponse.progressStatus()) {
            case COMPLETE:
                return true;
            case IN_PROGRESS:
                return false;
            case FAILED:
                throw new CfnNotStabilizedException(ResourceModel.TYPE_NAME, model.getArn());
            default:
                logger.log(String.format("Unexpected registration status, status=%s module=%s arn=%s registration_token=%s registration_description=%s",
                        dtrResponse.progressStatus(), model.getModuleName(), model.getArn(), registrationToken, dtrResponse.description()));
                throw new CfnGeneralServiceException(String.format("received unexpected module registration status: %s", dtrResponse.progressStatus()));
        }
    }