Skip to content

Commit

Permalink
[fix][admin] Clearly define REST API on Open API for Topics (apache#2…
Browse files Browse the repository at this point in the history
…2782)

(cherry picked from commit c25d7b2)
(cherry picked from commit 08ed1e2)
  • Loading branch information
shibd authored and nikhil-ctds committed Jun 4, 2024
1 parent 6d239b5 commit c4cf7bf
Show file tree
Hide file tree
Showing 2 changed files with 264 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.broker.web.RestException;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.partition.PartitionedTopicMetadata;
import org.apache.pulsar.common.policies.data.EntryFilters;
import org.apache.pulsar.common.policies.data.NamespaceOperation;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.common.policies.data.Policies;
import org.apache.pulsar.common.policies.data.TopicOperation;
import org.apache.pulsar.common.policies.data.TopicStats;
Expand All @@ -74,7 +76,7 @@ public class NonPersistentTopics extends PersistentTopics {

@GET
@Path("/{tenant}/{namespace}/{topic}/partitions")
@ApiOperation(value = "Get partitioned topic metadata.")
@ApiOperation(value = "Get partitioned topic metadata.", response = PartitionedTopicMetadata.class)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to manage resources on this tenant"),
Expand Down Expand Up @@ -102,7 +104,7 @@ public void getPartitionedMetadata(

@GET
@Path("{tenant}/{namespace}/{topic}/internalStats")
@ApiOperation(value = "Get the internal stats for the topic.")
@ApiOperation(value = "Get the internal stats for the topic.", response = PersistentTopicInternalStats.class)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to manage resources on this tenant"),
Expand Down Expand Up @@ -145,6 +147,7 @@ public void getInternalStats(
@ApiOperation(value = "Create a partitioned topic.",
notes = "It needs to be called before creating a producer on a partitioned topic.")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Operation successful"),
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to manage resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
Expand Down Expand Up @@ -306,6 +309,7 @@ public void getPartitionedStats(
@Path("/{tenant}/{namespace}/{topic}/unload")
@ApiOperation(value = "Unload a topic")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Operation successful"),
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "This operation requires super-user access"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
Expand Down Expand Up @@ -491,6 +495,7 @@ public void getListFromBundle(
@ApiOperation(value = "Truncate a topic.",
notes = "NonPersistentTopic does not support truncate.")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Operation successful"),
@ApiResponse(code = 412, message = "NonPersistentTopic does not support truncate.")
})
public void truncateTopic(
Expand All @@ -514,7 +519,7 @@ protected void validateAdminOperationOnTopic(TopicName topicName, boolean author

@GET
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Get entry filters for a topic.")
@ApiOperation(value = "Get entry filters for a topic.", response = EntryFilters.class)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Tenants or Namespace doesn't exist") })
public void getEntryFilters(@Suspended AsyncResponse asyncResponse,
Expand Down Expand Up @@ -542,7 +547,9 @@ public void getEntryFilters(@Suspended AsyncResponse asyncResponse,
@POST
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Set entry filters for specified topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Operation successful"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Tenant or namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
Expand Down Expand Up @@ -570,7 +577,9 @@ public void setEntryFilters(@Suspended final AsyncResponse asyncResponse,
@DELETE
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Remove entry filters for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Operation successful"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Tenant or namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
Expand Down
Loading

0 comments on commit c4cf7bf

Please sign in to comment.