protected ProgressEvent handleRequest()

in aws-mwaa-environment/src/main/java/software/amazon/mwaa/environment/CreateHandler.java [28:69]


    protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
            final Proxies proxies,
            final ResourceHandlerRequest<ResourceModel> request,
            final CallbackContext callbackContext) {

        final ResourceModel model = request.getDesiredResourceState();

        if (callbackContext.isStabilizing()) {
            log("callback context indicates Stabilizing mode");
            final Optional<EnvironmentStatus> status = getEnvironmentStatus(
                    proxies.getMwaaClientProxy(),
                    model.getName());

            if (status.isPresent()) {
                if (status.get() == EnvironmentStatus.AVAILABLE) {
                    log("status is AVAILABLE, returning success");
                    return ProgressEvent.progress(model, callbackContext).then(
                            progress -> getEnvironmentDetails("Create::PostCreateRead", proxies, progress));
                }

                if (status.get() == EnvironmentStatus.CREATE_FAILED) {
                    log("status is CREATE_FAILED, returning failure");
                    return ProgressEvent.failed(
                            model,
                            null,
                            HandlerErrorCode.NotStabilized,
                            "Creation failed");
                }
            }

            log("status is {}, requesting a callback in {}", status, CALLBACK_DELAY);
            return ProgressEvent.<ResourceModel, CallbackContext>builder()
                    .resourceModel(model)
                    .callbackContext(callbackContext)
                    .callbackDelaySeconds((int) CALLBACK_DELAY.getSeconds())
                    .status(OperationStatus.IN_PROGRESS)
                    .build();
        }

        return ProgressEvent.progress(model, callbackContext)
                .then(progress -> startCreationTask(proxies, progress, callbackContext));
    }