Search in sources :

Example 1 with UrlFactory

use of io.confluent.kafkarest.response.UrlFactory 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);
}
Also used : PathParam(javax.ws.rs.PathParam) Provider(javax.inject.Provider) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) CrnFactory(io.confluent.kafkarest.response.CrnFactory) CompletableFuture(java.util.concurrent.CompletableFuture) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) Inject(javax.inject.Inject) ResourceCollection(io.confluent.kafkarest.entities.v3.ResourceCollection) UrlFactory(io.confluent.kafkarest.response.UrlFactory) MediaType(javax.ws.rs.core.MediaType) Objects.requireNonNull(java.util.Objects.requireNonNull) BrokerConfig(io.confluent.kafkarest.entities.BrokerConfig) Broker(io.confluent.kafkarest.entities.Broker) AsyncResponses(io.confluent.kafkarest.resources.AsyncResponses) AsyncResponse(javax.ws.rs.container.AsyncResponse) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) Collectors(java.util.stream.Collectors) Suspended(javax.ws.rs.container.Suspended) BrokerConfigManager(io.confluent.kafkarest.controllers.BrokerConfigManager) BrokerManager(io.confluent.kafkarest.controllers.BrokerManager) Comparator(java.util.Comparator) BrokerConfigDataList(io.confluent.kafkarest.entities.v3.BrokerConfigDataList) Broker(io.confluent.kafkarest.entities.Broker) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) BrokerConfigManager(io.confluent.kafkarest.controllers.BrokerConfigManager) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) Produces(javax.ws.rs.Produces) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) GET(javax.ws.rs.GET)

Example 2 with UrlFactory

use of io.confluent.kafkarest.response.UrlFactory 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);
}
Also used : ListTopicConfigsResponse(io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse) PathParam(javax.ws.rs.PathParam) AsyncResponses(io.confluent.kafkarest.resources.AsyncResponses) Provider(javax.inject.Provider) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) AsyncResponse(javax.ws.rs.container.AsyncResponse) Path(javax.ws.rs.Path) CrnFactory(io.confluent.kafkarest.response.CrnFactory) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) CompletableFuture(java.util.concurrent.CompletableFuture) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) Collectors(java.util.stream.Collectors) Suspended(javax.ws.rs.container.Suspended) TopicConfigManager(io.confluent.kafkarest.controllers.TopicConfigManager) Inject(javax.inject.Inject) ResourceCollection(io.confluent.kafkarest.entities.v3.ResourceCollection) UrlFactory(io.confluent.kafkarest.response.UrlFactory) MediaType(javax.ws.rs.core.MediaType) TopicManager(io.confluent.kafkarest.controllers.TopicManager) TopicConfig(io.confluent.kafkarest.entities.TopicConfig) Objects.requireNonNull(java.util.Objects.requireNonNull) Comparator(java.util.Comparator) TopicConfigDataList(io.confluent.kafkarest.entities.v3.TopicConfigDataList) TopicConfigManager(io.confluent.kafkarest.controllers.TopicConfigManager) ListTopicConfigsResponse(io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) Produces(javax.ws.rs.Produces) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) GET(javax.ws.rs.GET)

Aggregations

ResourceCollection (io.confluent.kafkarest.entities.v3.ResourceCollection)2 ResourceName (io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName)2 AsyncResponses (io.confluent.kafkarest.resources.AsyncResponses)2 CrnFactory (io.confluent.kafkarest.response.CrnFactory)2 UrlFactory (io.confluent.kafkarest.response.UrlFactory)2 PerformanceMetric (io.confluent.rest.annotations.PerformanceMetric)2 Comparator (java.util.Comparator)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Provider (javax.inject.Provider)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 PathParam (javax.ws.rs.PathParam)2 Produces (javax.ws.rs.Produces)2 AsyncResponse (javax.ws.rs.container.AsyncResponse)2 Suspended (javax.ws.rs.container.Suspended)2 MediaType (javax.ws.rs.core.MediaType)2 BrokerConfigManager (io.confluent.kafkarest.controllers.BrokerConfigManager)1