Browse Source

Merge pull request #47 from provectus/feature/10-topic-messages-api-contract

Topic messages API. Contract
Anton Petrov 5 years ago
parent
commit
a0b4b6e1f0

+ 7 - 0
kafka-ui-api/src/main/java/com/provectus/kafka/ui/rest/MetricsRestController.java

@@ -11,6 +11,8 @@ import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 import reactor.core.publisher.Mono;
 
 
+import java.time.OffsetDateTime;
+
 import javax.validation.Valid;
 import javax.validation.Valid;
 
 
 @RestController
 @RestController
@@ -57,6 +59,11 @@ public class MetricsRestController implements ApiClustersApi {
         );
         );
     }
     }
 
 
+    @Override
+    public Mono<ResponseEntity<Flux<TopicMessage>>> getTopicMessages(String clusterName, String topicName, @Valid Integer partition, @Valid Long offset, @Valid OffsetDateTime timestamp, ServerWebExchange exchange) {
+        return Mono.error(new UnsupportedOperationException());
+    }
+
     @Override
     @Override
     public Mono<ResponseEntity<Topic>> createTopic(String clusterName, @Valid Mono<TopicFormData> topicFormData, ServerWebExchange exchange) {
     public Mono<ResponseEntity<Topic>> createTopic(String clusterName, @Valid Mono<TopicFormData> topicFormData, ServerWebExchange exchange) {
         return clusterService.createTopic(clusterName, topicFormData)
         return clusterService.createTopic(clusterName, topicFormData)

+ 72 - 1
kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml

@@ -169,6 +169,47 @@ paths:
                 items:
                 items:
                   $ref: '#/components/schemas/TopicConfig'
                   $ref: '#/components/schemas/TopicConfig'
 
 
+  /api/clusters/{clusterName}/topics/{topicName}/messages:
+    get:
+      tags:
+        - /api/clusters
+      summary: getTopicMessages
+      operationId: getTopicMessages
+      parameters:
+        - name: clusterName
+          in: path
+          required: true
+          schema:
+            type: string
+        - name: topicName
+          in: path
+          required: true
+          schema:
+            type: string
+        - name: partition
+          in: query
+          schema:
+            type: integer
+        - name: offset
+          in: query
+          schema:
+            type: integer
+            format: int64
+        - name: timestamp
+          in: query
+          schema:
+            type: string
+            format: date-time
+      responses:
+        200:
+          description: OK
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/TopicMessage'
+
   /api/clusters/{clusterName}/consumerGroups:
   /api/clusters/{clusterName}/consumerGroups:
     get:
     get:
       tags:
       tags:
@@ -335,4 +376,34 @@ components:
         numConsumers:
         numConsumers:
             type: integer
             type: integer
         numTopics:
         numTopics:
-            type: integer
+            type: integer
+
+    TopicMessage:
+      type: object
+      properties:
+        partition:
+          type: integer
+        offset:
+          type: integer
+          format: int64
+        timestamp:
+          type: string
+          format: date-time
+        timestampType:
+          type: string
+          enum:
+            - NO_TIMESTAMP_TYPE
+            - CREATE_TIME
+            - LOG_APPEND_TIME
+        key:
+          type: string
+        headers:
+          type: object
+          additionalProperties:
+            type: string
+        content:
+          type: string
+      required:
+        - partition
+        - offset
+        - timestamp