Search in sources :

Example 1 with URIBuilder

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));
}
Also used : Pagination(org.akhq.utils.Pagination) URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder) Operation(io.swagger.v3.oas.annotations.Operation)

Example 2 with URIBuilder

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));
}
Also used : Pagination(org.akhq.utils.Pagination) URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder) Operation(io.swagger.v3.oas.annotations.Operation)

Example 3 with URIBuilder

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));
}
Also used : URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder) Secured(io.micronaut.security.annotation.Secured) Operation(io.swagger.v3.oas.annotations.Operation)

Example 4 with URIBuilder

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));
}
Also used : Pagination(org.akhq.utils.Pagination) URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder) Get(io.micronaut.http.annotation.Get) Operation(io.swagger.v3.oas.annotations.Operation)

Example 5 with URIBuilder

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;
}
Also used : Record(org.akhq.models.Record) URIBuilder(org.codehaus.httpcache4j.uri.URIBuilder)

Aggregations

URIBuilder (org.codehaus.httpcache4j.uri.URIBuilder)7 Operation (io.swagger.v3.oas.annotations.Operation)5 Pagination (org.akhq.utils.Pagination)4 Get (io.micronaut.http.annotation.Get)1 Secured (io.micronaut.security.annotation.Secured)1 File (java.io.File)1 Connection (org.akhq.configs.Connection)1 Record (org.akhq.models.Record)1 Configuration (org.sourcelab.kafka.connect.apiclient.Configuration)1 KafkaConnectClient (org.sourcelab.kafka.connect.apiclient.KafkaConnectClient)1