use of org.codehaus.httpcache4j.uri.URIBuilder in project akhq by tchiotludo.
the class SchemaController method list.
@Get("api/{cluster}/schema")
@Operation(tags = { "schema registry" }, summary = "List all schemas")
public ResultPagedList<Schema> list(HttpRequest<?> request, String cluster, Optional<String> search, Optional<Integer> page) throws IOException, RestClientException, ExecutionException, InterruptedException {
URIBuilder uri = URIBuilder.fromURI(request.getUri());
Pagination pagination = new Pagination(pageSize, uri, page.orElse(1));
return ResultPagedList.of(this.schemaRepository.list(cluster, pagination, search));
}
use of org.codehaus.httpcache4j.uri.URIBuilder in project akhq by tchiotludo.
the class TopicController method list.
@Get("api/{cluster}/topic")
@Operation(tags = { "topic" }, summary = "List all topics")
public ResultPagedList<Topic> list(HttpRequest<?> request, String cluster, Optional<String> search, Optional<TopicRepository.TopicListView> show, Optional<Integer> page) throws ExecutionException, InterruptedException {
URIBuilder uri = URIBuilder.fromURI(request.getUri());
Pagination pagination = new Pagination(pageSize, uri, page.orElse(1));
return ResultPagedList.of(this.topicRepository.list(cluster, pagination, show.orElse(TopicRepository.TopicListView.HIDE_INTERNAL), search));
}
use of org.codehaus.httpcache4j.uri.URIBuilder in project akhq by tchiotludo.
the class TopicController method data.
@Secured(Role.ROLE_TOPIC_DATA_READ)
@Get("api/{cluster}/topic/{topicName}/data")
@Operation(tags = { "topic data" }, summary = "Read datas from a topic")
public ResultNextList<Record> data(HttpRequest<?> request, String cluster, String topicName, Optional<String> after, Optional<Integer> partition, Optional<RecordRepository.Options.Sort> sort, Optional<String> timestamp, Optional<String> searchByKey, Optional<String> searchByValue, Optional<String> searchByHeaderKey, Optional<String> searchByHeaderValue) throws ExecutionException, InterruptedException {
Topic topic = this.topicRepository.findByName(cluster, topicName);
RecordRepository.Options options = dataSearchOptions(cluster, topicName, after, partition, sort, timestamp, searchByKey, searchByValue, searchByHeaderKey, searchByHeaderValue);
URIBuilder uri = URIBuilder.fromURI(request.getUri());
List<Record> data = this.recordRepository.consume(cluster, options);
return TopicDataResultNextList.of(data, options.after(data, uri), (options.getPartition() == null ? topic.getSize() : topic.getSize(options.getPartition())), this.isAllowed(Role.ROLE_TOPIC_DATA_DELETE) && topic.canDeleteRecords(cluster, configRepository));
}
use of org.codehaus.httpcache4j.uri.URIBuilder in project akhq by tchiotludo.
the class ConnectController method list.
@Get
@Operation(tags = { "connect" }, summary = "List all connect definitions")
public ResultPagedList<ConnectDefinition> list(HttpRequest<?> request, String cluster, String connectId, Optional<String> search, Optional<Integer> page) throws IOException, RestClientException, ExecutionException, InterruptedException {
URIBuilder uri = URIBuilder.fromURI(request.getUri());
Pagination pagination = new Pagination(pageSize, uri, page.orElse(1));
return ResultPagedList.of(this.connectRepository.getPaginatedDefinitions(cluster, connectId, pagination, search));
}
use of org.codehaus.httpcache4j.uri.URIBuilder in project akhq by tchiotludo.
the class RecordRepositoryTest method consumeAllRecord.
private List<Record> consumeAllRecord(RecordRepository.Options options) throws ExecutionException, InterruptedException {
boolean hasNext = true;
List<Record> all = new ArrayList<>();
do {
List<Record> datas = repository.consume(KafkaTestCluster.CLUSTER_ID, options);
all.addAll(datas);
datas.forEach(record -> log.debug("Records [Topic: {}] [Partition: {}] [Offset: {}] [Key: {}] [Value: {}]", record.getTopic(), record.getPartition(), record.getOffset(), record.getKey(), record.getValue()));
log.info("Consume {} records", datas.size());
URIBuilder after = options.after(datas, URIBuilder.empty());
if (datas.size() == 0) {
hasNext = false;
} else if (after != null) {
options.setAfter(after.getParametersByName("after").get(0).getValue());
}
} while (hasNext);
return all;
}
Aggregations