/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pulsar.broker.admin.v2;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.apache.pulsar.broker.admin.impl.ResourceQuotasBase;
import org.apache.pulsar.common.policies.data.ResourceQuota;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@Path("/resource-quotas")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Api(value = "/resource-quotas", description = "Quota admin APIs", tags = "resource-quotas")
public class ResourceQuotas extends ResourceQuotasBase {

    @GET
    @ApiOperation(value = "Get the default quota", response = String.class, responseContainer = "Set")
    @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
    public ResourceQuota getDefaultResourceQuota() throws Exception {
        return super.getDefaultResourceQuota();
    }

    @POST
    @ApiOperation(value = "Set the default quota", response = String.class, responseContainer = "Set")
    @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
    public void setDefaultResourceQuota(ResourceQuota quota) throws Exception {
        super.setDefaultResourceQuota(quota);
    }

    @GET
    @Path("/{tenant}/{namespace}/{bundle}")
    @ApiOperation(value = "Get resource quota of a namespace bundle.")
    @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 ResourceQuota getNamespaceBundleResourceQuota(@PathParam("tenant") String tenant,
            @PathParam("namespace") String namespace, @PathParam("bundle") String bundleRange) {
        validateNamespaceName(tenant, namespace);
        return internalGetNamespaceBundleResourceQuota(bundleRange);
    }

    @POST
    @Path("/{tenant}/{namespace}/{bundle}")
    @ApiOperation(value = "Set resource quota on a namespace.")
    @ApiResponses(value = {
            @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
            @ApiResponse(code = 403, message = "Don't have admin permission"),
            @ApiResponse(code = 409, message = "Concurrent modification") })
    public void setNamespaceBundleResourceQuota(@PathParam("tenant") String tenant,
            @PathParam("namespace") String namespace, @PathParam("bundle") String bundleRange, ResourceQuota quota) {
        validateNamespaceName(tenant, namespace);
        internalSetNamespaceBundleResourceQuota(bundleRange, quota);
    }

    @DELETE
    @Path("/{tenant}/{namespace}/{bundle}")
    @ApiOperation(value = "Remove resource quota for a namespace.")
    @ApiResponses(value = {
            @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
            @ApiResponse(code = 403, message = "Don't have admin permission"),
            @ApiResponse(code = 409, message = "Concurrent modification") })
    public void removeNamespaceBundleResourceQuota(@PathParam("tenant") String tenant,
            @PathParam("namespace") String namespace, @PathParam("bundle") String bundleRange) {
        validateNamespaceName(tenant, namespace);
        internalRemoveNamespaceBundleResourceQuota(bundleRange);
    }
}

@@ -1231,16 +1231,56 @@
 ns.Api;%0A
+import io.swagger.annotations.ApiParam;%0A
 import i
@@ -1315,16 +1315,16 @@
 ration;%0A
-
 import i
@@ -2240,16 +2240,73 @@
 ceQuota(
+%0A            @ApiParam(value = %22Default resource quota%22) 
 Resource
@@ -2854,97 +2854,299 @@
 ota(
-@PathParam(%22tenant%22) String tenant,%0A            @PathParam(%22namespace%22) String namespace,
+%0A            @ApiParam(value = %22Tenant name%22)%0A            @PathParam(%22tenant%22) String tenant,%0A            @ApiParam(value = %22Namespace name within the specified tenant%22)%0A            @PathParam(%22namespace%22) String namespace,%0A            @ApiParam(value = %22Namespace bundle range%22)%0A           
  @Pa
@@ -3759,138 +3759,416 @@
 ota(
-@PathParam(%22tenant%22) String tenant,%0A            @PathParam(%22namespace%22) String namespace, @PathParam(%22bundle%22) String bundleRange,
+%0A            @ApiParam(value = %22Tenant name%22)%0A            @PathParam(%22tenant%22) String tenant,%0A            @ApiParam(value = %22Namespace name within the specified tenant%22)%0A            @PathParam(%22namespace%22) String namespace,%0A            @ApiParam(value = %22Namespace bundle range%22)%0A            @PathParam(%22bundle%22) String bundleRange,%0A            @ApiParam(value = %22Resource quota for the specified namespace%22)
  Res
@@ -4770,97 +4770,299 @@
 ota(
-@PathParam(%22tenant%22) String tenant,%0A            @PathParam(%22namespace%22) String namespace,
+%0A            @ApiParam(value = %22Tenant name%22)%0A            @PathParam(%22tenant%22) String tenant,%0A            @ApiParam(value = %22Namespace name within the specified tenant%22)%0A            @PathParam(%22namespace%22) String namespace,%0A            @ApiParam(value = %22Namespace bundle range%22)%0A           
  @Pa

Extend REST API for resource quotas with swagger annotations (#7125)