#' Subscribe Apache Kafka consumer to a topic using Confluent's REST Proxy API #' #' \code{SubscribeKafkaTopic} subscribes an Apache Kafka consumer to a topic #' using the rest proxy api provided by Confluent. #' #' @param consumer.base.uri The URI of the consumer created by \code{\link{CreateKafkaConsumer}}. #' @param topic A chr object with the topic to subscribe to. #' #' @return If the operation succeeds, returns the response, which can be discarded. #' If the operation fails, it might help out understanding what happened. #' SubscribeKafkaTopic <- function(consumer.base.uri, topic) { response <- POST(url=paste(consumer.base.uri, "subscription", sep="/"), content_type("application/vnd.kafka.v2+json"), body = paste0('{"topics":["', topic, '"]}') ) if(response$status_code == 204) { return(response) } else stop(response) }