private ProgressEvent checkForPreCreateResourceExistence()

in aws-devopsguru-notificationchannel/src/main/java/software/amazon/devopsguru/notificationchannel/CreateHandler.java [83:99]


    private ProgressEvent<ResourceModel, CallbackContext> checkForPreCreateResourceExistence(
            final ResourceHandlerRequest<ResourceModel> request,
            final ProgressEvent<ResourceModel, CallbackContext> progressEvent,
            final ProxyClient<DevOpsGuruClient> proxyClient) {
        final ResourceModel model = progressEvent.getResourceModel();
        final CallbackContext callbackContext = progressEvent.getCallbackContext();
        String topicArn = model.getConfig().getSns().getTopicArn();

        ListNotificationChannelsResponse listNotificationChannelsResponse = listNotificationChannel(Translator.translateToListNotificationChannelRequest(model), proxyClient);
        for (NotificationChannel channel : listNotificationChannelsResponse.channels()) {
            if (channel.config().sns().topicArn().equals(topicArn)) {
                throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, topicArn);
            }
        }

        return ProgressEvent.progress(model, callbackContext);
    }