protected ProgressEvent preExistanceCheck()

in aws-wafv2-loggingconfiguration/src/main/java/software/amazon/wafv2/loggingconfiguration/CreateHandler.java [58:81]


    protected ProgressEvent<ResourceModel, CallbackContext> preExistanceCheck(final AmazonWebServicesClientProxy proxy,
            final ProxyClient<Wafv2Client> proxyClient,
            final ResourceModel model,
            final CallbackContext callbackContext) {

        return proxy.initiate("AWS-WAFv2-LoggingConfiguration::Create::PreExistanceCheck", proxyClient, model, callbackContext)
                .translateToServiceRequest(Translator::translateToReadRequest)
                .makeServiceCall((cbRequest, cbProxyClient) -> cbProxyClient.injectCredentialsAndInvokeV2(cbRequest, cbProxyClient.client()::getLoggingConfiguration))
                .handleError((cbRequest, cbException, cbProxyClient, cbModel, cbContext) -> {
                     if (cbException instanceof WafNonexistentItemException)
                         return ProgressEvent.progress(cbModel, cbContext);
                     throw cbException;
                })
                .done((cbRequest, cbResponse, cbProxyClient, cbModel, cbContext) -> {
                    if(cbResponse.loggingConfiguration() != null && cbResponse.loggingConfiguration().hasLogDestinationConfigs()) {
                        return ProgressEvent.<ResourceModel, CallbackContext>builder()
                            .status(OperationStatus.FAILED)
                            .errorCode(HandlerErrorCode.AlreadyExists)
                            .message(String.format("Logging Configuration for %s already exists", cbModel.getResourceArn()))
                            .build();
                    }
                    return ProgressEvent.progress(cbModel, cbContext);
                });
    }