public ProgressEvent handleRequest()

in aws-applicationinsights-application/src/main/java/software/amazon/applicationinsights/application/DeleteHandler.java [19:58]


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

        final ResourceModel model = request.getDesiredResourceState();

        logger.log(String.format("Delete Handler called with resourceGroupName %s", model.getResourceGroupName()));
        final CallbackContext newCallbackContext = callbackContext == null ?
                CallbackContext.builder().stabilizationRetriesRemaining(STATUS_POLL_RETRIES).build() :
                callbackContext;

        if (callbackContext == null) {
            if (!HandlerHelper.doesApplicationExist(model.getResourceGroupName(), proxy, applicationInsightsClient)) {
                // if the application does not exit, fail the delete
                final Exception ex = ResourceNotFoundException.builder()
                        .message("Application does not exit for resource group " + model.getResourceGroupName())
                        .build();
                return ProgressEvent.defaultFailureHandler(ex, ExceptionMapper.mapToHandlerErrorCode(ex));
            } else {
                HandlerHelper.deleteApplicationInsightsApplication(model, proxy, applicationInsightsClient);
            }
        }

        if (newCallbackContext.getStabilizationRetriesRemaining() == 0) {
            throw new RuntimeException(TIMED_OUT_MESSAGE);
        }

        if (!HandlerHelper.doesApplicationExist(model.getResourceGroupName(), proxy, applicationInsightsClient)) {
            return ProgressEvent.defaultSuccessHandler(null);
        } else {
            return ProgressEvent.defaultInProgressHandler(
                    CallbackContext.builder()
                            .stabilizationRetriesRemaining(newCallbackContext.getStabilizationRetriesRemaining() - 1)
                            .build(),
                    CALLBACK_DELAY_SECONDS,
                    model);
        }
    }