Skip to content

Commit

Permalink
[REST API]Annotate the APIs that may throw 307 temporary redirect exc…
Browse files Browse the repository at this point in the history
…eption (apache#6227)

Many of the existing REST API returns 307 temporary redirects without annotating them explicitly. This PR checks all occurrences of redirect exception and annotates them out.
  • Loading branch information
yjshen authored Feb 10, 2020
1 parent 9b46930 commit 739cdcb
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class BrokersBase extends AdminResource {
responseContainer = "Set")
@ApiResponses(
value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve this cluster"),
@ApiResponse(code = 401, message = "Authentication required"),
@ApiResponse(code = 403, message = "This operation requires super-user access"),
@ApiResponse(code = 404, message = "Cluster does not exist: cluster={clustername}") })
Expand All @@ -101,6 +102,7 @@ public Set<String> getActiveBrokers(@PathParam("cluster") String cluster) throws
@Path("/{clusterName}/{broker-webserviceurl}/ownedNamespaces")
@ApiOperation(value = "Get the list of namespaces served by the specific broker", response = NamespaceOwnershipStatus.class, responseContainer = "Map")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the cluster"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Cluster doesn't exist") })
public Map<String, NamespaceOwnershipStatus> getOwnedNamespaces(@PathParam("clusterName") String cluster,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public FunctionConfig getFunctionInfo(
response = FunctionStatus.FunctionInstanceStatus.FunctionInstanceStatusData.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this function"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions"),
@ApiResponse(code = 404, message = "The Pulsar Function doesn't exist")
Expand All @@ -356,6 +357,7 @@ public FunctionStatus.FunctionInstanceStatus.FunctionInstanceStatusData getFunct
response = FunctionStatus.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this function"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions"),
@ApiResponse(code = 404, message = "The Pulsar Function doesn't exist")
Expand All @@ -378,6 +380,7 @@ public FunctionStatus getFunctionStatus(
response = FunctionStats.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this function"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions"),
@ApiResponse(code = 404, message = "The Pulsar Function doesn't exist")
Expand All @@ -400,6 +403,7 @@ public FunctionStats getFunctionStats(
response = FunctionStats.FunctionInstanceStats.FunctionInstanceStatsData.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this function"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions"),
@ApiResponse(code = 404, message = "The Pulsar Function doesn't exist")
Expand Down Expand Up @@ -513,6 +517,7 @@ public void putFunctionState(final @PathParam("tenant") String tenant,
@POST
@ApiOperation(value = "Restart an instance of a Pulsar Function", response = Void.class)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this function"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 404, message = "The Pulsar Function does not exist"),
@ApiResponse(code = 500, message = "Internal server error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public SinkConfig getSinkInfo(@ApiParam(value = "The tenant of a Pulsar Sink")
response = SinkStatus.SinkInstanceStatus.SinkInstanceStatusData.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this sink"),
@ApiResponse(code = 400, message = "The Pulsar Sink instance does not exist"),
@ApiResponse(code = 404, message = "The Pulsar Sink does not exist"),
@ApiResponse(code = 500, message = "Internal Server Error (got exception while getting status, etc.)"),
Expand All @@ -302,6 +303,7 @@ public SinkStatus.SinkInstanceStatus.SinkInstanceStatusData getSinkInstanceStatu
response = SinkStatus.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this sink"),
@ApiResponse(code = 400, message = "Invalid get status request"),
@ApiResponse(code = 401, message = "The client is not authorized to perform this operation"),
@ApiResponse(code = 404, message = "The Pulsar Sink does not exist"),
Expand Down Expand Up @@ -341,6 +343,7 @@ public List<String> listSinks(@ApiParam(value = "The tenant of a Pulsar Sink")
@POST
@ApiOperation(value = "Restart an instance of a Pulsar Sink", response = Void.class)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this sink"),
@ApiResponse(code = 400, message = "Invalid restart request"),
@ApiResponse(code = 401, message = "The client is not authorized to perform this operation"),
@ApiResponse(code = 404, message = "The Pulsar Sink does not exist"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public SourceConfig getSourceInfo(
response = SourceStatus.SourceInstanceStatus.SourceInstanceStatusData.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this source"),
@ApiResponse(code = 500, message = "Internal Server Error"),
@ApiResponse(code = 503, message = "Function worker service is now initializing. Please try again later.")
})
Expand All @@ -281,6 +282,7 @@ public SourceStatus.SourceInstanceStatus.SourceInstanceStatusData getSourceInsta
response = SourceStatus.class
)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this source"),
@ApiResponse(code = 500, message = "Internal Server Error"),
@ApiResponse(code = 503, message = "Function worker service is now initializing. Please try again later.")
})
Expand Down Expand Up @@ -321,6 +323,7 @@ public List<String> listSources(
@POST
@ApiOperation(value = "Restart an instance of a Pulsar Source", response = Void.class)
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this source"),
@ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 401, message = "Client is not authorize to perform operation"),
@ApiResponse(code = 404, message = "Not Found(The Pulsar Source doesn't exist)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ public void createNamespace(@PathParam("property") String property, @PathParam("
@DELETE
@Path("/{property}/{cluster}/{namespace}")
@ApiOperation(hidden = true, value = "Delete a namespace and all the topics under it.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
@ApiResponse(code = 409, message = "Namespace is not empty") })
public void deleteNamespace(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
Expand All @@ -202,7 +204,9 @@ public void deleteNamespace(@Suspended final AsyncResponse asyncResponse, @PathP
@DELETE
@Path("/{property}/{cluster}/{namespace}/{bundle}")
@ApiOperation(hidden = true, value = "Delete a namespace bundle and all the topics under it.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
@ApiResponse(code = 409, message = "Namespace bundle is not empty") })
public void deleteNamespaceBundle(@PathParam("property") String property,
Expand Down Expand Up @@ -411,7 +415,9 @@ public BundlesData getBundlesData(@PathParam("property") String property, @PathP
+ "their persistent store). During that operation, the namespace is marked as tentatively unavailable until the"
+ "broker completes the unloading action. This operation requires strictly super user privileges, since it would"
+ "result in non-persistent message loss and unexpected connection closure to the clients.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
@ApiResponse(code = 412, message = "Namespace is already unloaded or Namespace has bundles activated") })
public void unloadNamespace(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
Expand All @@ -429,7 +435,9 @@ public void unloadNamespace(@Suspended final AsyncResponse asyncResponse, @PathP
@PUT
@Path("/{property}/{cluster}/{namespace}/{bundle}/unload")
@ApiOperation(hidden = true, value = "Unload a namespace bundle")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void unloadNamespaceBundle(@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("bundle") String bundleRange,
@QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
Expand All @@ -440,7 +448,9 @@ public void unloadNamespaceBundle(@PathParam("property") String property, @PathP
@PUT
@Path("/{property}/{cluster}/{namespace}/{bundle}/split")
@ApiOperation(hidden = true, value = "Split a namespace bundle")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void splitNamespaceBundle(@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("bundle") String bundleRange,
@QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
Expand Down Expand Up @@ -596,7 +606,9 @@ public void setPersistence(@PathParam("property") String property, @PathParam("c
@POST
@Path("/{property}/{cluster}/{namespace}/persistence/bookieAffinity")
@ApiOperation(hidden = true, value = "Set the bookie-affinity-group to namespace-local policy.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist"),
@ApiResponse(code = 409, message = "Concurrent modification") })
public void setBookieAffinityGroup(@PathParam("property") String property, @PathParam("cluster") String cluster,
Expand All @@ -608,7 +620,9 @@ public void setBookieAffinityGroup(@PathParam("property") String property, @Path
@GET
@Path("/{property}/{cluster}/{namespace}/persistence/bookieAffinity")
@ApiOperation(hidden = true, value = "Get the bookie-affinity-group from namespace-local policy.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist"),
@ApiResponse(code = 409, message = "Concurrent modification") })
public BookieAffinityGroupData getBookieAffinityGroup(@PathParam("property") String property,
Expand All @@ -620,7 +634,9 @@ public BookieAffinityGroupData getBookieAffinityGroup(@PathParam("property") Str
@DELETE
@Path("/{property}/{cluster}/{namespace}/persistence/bookieAffinity")
@ApiOperation(hidden = true, value = "Delete the bookie-affinity-group from namespace-local policy.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist"),
@ApiResponse(code = 409, message = "Concurrent modification") })
public void deleteBookieAffinityGroup(@PathParam("property") String property, @PathParam("cluster") String cluster,
Expand Down Expand Up @@ -663,7 +679,9 @@ public void clearNamespaceBacklog(@Suspended final AsyncResponse asyncResponse,
@POST
@Path("/{property}/{cluster}/{namespace}/{bundle}/clearBacklog")
@ApiOperation(hidden = true, value = "Clear backlog for all topics on a namespace bundle.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist") })
public void clearNamespaceBundleBacklog(@PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
Expand Down Expand Up @@ -695,7 +713,9 @@ public void clearNamespaceBacklogForSubscription(@Suspended final AsyncResponse
@POST
@Path("/{property}/{cluster}/{namespace}/{bundle}/clearBacklog/{subscription}")
@ApiOperation(hidden = true, value = "Clear backlog for a given subscription on all topics on a namespace bundle.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist") })
public void clearNamespaceBundleBacklogForSubscription(@PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
Expand Down
Loading

0 comments on commit 739cdcb

Please sign in to comment.