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
  • Loading branch information
shibd committed May 27, 2024
1 parent ba20e02 commit c25d7b2
Show file tree
Hide file tree
Showing 2 changed files with 270 additions and 76 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 @@ -317,6 +320,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 @@ -502,6 +506,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 @@ -525,7 +530,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 @@ -553,7 +558,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 @@ -581,7 +588,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 c25d7b2

Please sign in to comment.