use of io.confluent.kafkarest.response.CrnFactory in project kafka-rest by confluentinc.
the class ListAllBrokersConfigsAction method listBrokersConfigs.
@GET
@Produces(MediaType.APPLICATION_JSON)
@PerformanceMetric("v3.brokers.configs.list")
@ResourceName("api.v3.brokers-configs.list")
public void listBrokersConfigs(@Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) {
BrokerConfigManager resolvedBrokerConfigManager = brokerConfigManager.get();
CompletableFuture<ListBrokerConfigsResponse> response = brokerManager.get().listBrokers(clusterId).thenCompose(brokers -> resolvedBrokerConfigManager.listAllBrokerConfigs(clusterId, brokers.stream().map(Broker::getBrokerId).collect(Collectors.toList())).thenApply(configs -> ListBrokerConfigsResponse.create(BrokerConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf(urlFactory.create("v3", "clusters", clusterId, "brokers", "-", "configs")).build()).setData(configs.values().stream().flatMap(brokerConfigs -> brokerConfigs.stream().sorted(Comparator.comparing(BrokerConfig::getBrokerId))).map(brokerConfig -> BrokerConfigsResource.toBrokerConfigData(brokerConfig, crnFactory, urlFactory)).collect(Collectors.toList())).build())));
AsyncResponses.asyncResume(asyncResponse, response);
}
use of io.confluent.kafkarest.response.CrnFactory in project kafka-rest by confluentinc.
the class ListAllTopicsConfigsAction method listTopicConfigs.
@GET
@Produces(MediaType.APPLICATION_JSON)
@PerformanceMetric("v3.topics.configs.list")
@ResourceName("api.v3.topic-configs.list")
public void listTopicConfigs(@Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) {
// have to resolve dependencies here in request scope
TopicConfigManager resolvedTopicConfigManager = topicConfigManager.get();
CompletableFuture<ListTopicConfigsResponse> response = topicManager.get().listTopics(clusterId).thenCompose(topics -> resolvedTopicConfigManager.listTopicConfigs(clusterId, topics.stream().map(topic -> topic.getName()).collect(Collectors.toList())).thenApply(configs -> ListTopicConfigsResponse.create(TopicConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf(urlFactory.create("v3", "clusters", clusterId, "topics", "-", "configs")).build()).setData(configs.values().stream().flatMap(topicConfigs -> topicConfigs.stream().sorted(Comparator.comparing(TopicConfig::getName))).map(topicConfig -> TopicConfigsResource.toTopicConfigData(topicConfig, crnFactory, urlFactory)).collect(Collectors.toList())).build())));
AsyncResponses.asyncResume(asyncResponse, response);
}
Aggregations