private ProgressEvent deleteCanary()

in aws-synthetics-canary/src/main/java/com/amazon/synthetics/canary/DeleteHandler.java [62:88]


    private ProgressEvent<ResourceModel, CallbackContext> deleteCanary(Canary canary) {
        // The canary will be deleted once DeleteCanary returns.
        log("Deleting canary.");

        try {
            proxy.injectCredentialsAndInvokeV2(
                DeleteCanaryRequest.builder()
                    .name(canary.name())
                    .build(),
                syntheticsClient::deleteCanary);
        } catch (ResourceNotFoundException e) {
            // Handle race condition where an external process calls DeleteCanary before we do.
            return ProgressEvent.defaultSuccessHandler(null);
        } catch (ConflictException e) {
            // Handle race condition where an external process is mutating the canary while we
            // are trying to delete it.
            throw new CfnResourceConflictException(
                ResourceModel.TYPE_NAME,
                canary.name(),
                "The canary state changed unexpectedly.",
                e);
        }

        context.setCanaryDeleteStarted(true);
        log("Deleted canary.");
        return confirmCanaryDeleted();
    }