lhotari commented on code in PR #24991:
URL: https://github.com/apache/pulsar/pull/24991#discussion_r2657775277


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java:
##########
@@ -5131,5 +5131,95 @@ public void getMessageIDByIndex(@Suspended final 
AsyncResponse asyncResponse,
                 });
     }
 
+    @POST
+    @Path("/{tenant}/{namespace}/{topic}/customMetricLabels")
+    @ApiOperation(value = "Set custom metric labels for a topic")
+    @ApiResponses(value = {
+            @ApiResponse(code = 204, message = "Operation successful"),
+            @ApiResponse(code = 403, message = "Don't have admin permission"),
+            @ApiResponse(code = 404, message = "Topic doesn't exist"),
+            @ApiResponse(code = 405, message = "Topic level policy is 
disabled"),
+            @ApiResponse(code = 412, message = "Feature is disabled or invalid 
label keys/values"),
+            @ApiResponse(code = 409, message = "Concurrent modification")})
+    public void setCustomMetricLabels(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("tenant") String tenant,
+            @PathParam("namespace") String namespace,
+            @PathParam("topic") @Encoded String encodedTopic,
+            @QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
+            @QueryParam("authoritative") @DefaultValue("false") boolean 
authoritative,
+            @ApiParam(value = "Custom metric labels") Map<String, String> 
labels) {
+        validateTopicName(tenant, namespace, encodedTopic);
+        validateTopicPolicyOperationAsync(topicName, 
PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE)
+                .thenCompose(__ -> preValidation(authoritative))
+                .thenCompose(__ -> internalSetCustomMetricLabels(labels, 
isGlobal))
+                .thenAccept(__ -> 
asyncResponse.resume(Response.noContent().build()))
+                .exceptionally(ex -> {
+                    handleTopicPolicyException("setCustomMetricLabels", ex, 
asyncResponse);
+                    return null;
+                });
+    }
+
+    @GET
+    @Path("/{tenant}/{namespace}/{topic}/customMetricLabels")
+    @ApiOperation(value = "Get custom metric labels for a topic", response = 
Map.class)
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "OK"),
+            @ApiResponse(code = 403, message = "Don't have admin permission"),
+            @ApiResponse(code = 404, message = "Topic does not exist"),
+            @ApiResponse(code = 405, message = "Topic level policy is 
disabled"),
+            @ApiResponse(code = 412, message = "Feature is disabled"),
+            @ApiResponse(code = 409, message = "Concurrent modification")})
+    public void getCustomMetricLabels(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("tenant") String tenant,
+            @PathParam("namespace") String namespace,
+            @PathParam("topic") @Encoded String encodedTopic,
+            @QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
+            @QueryParam("authoritative") @DefaultValue("false") boolean 
authoritative) {
+        validateTopicName(tenant, namespace, encodedTopic);
+        validateTopicPolicyOperationAsync(topicName, 
PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.READ)

Review Comment:
   Why is `PolicyName.MAX_SUBSCRIPTIONS` used?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to