Search in sources :

Example 96 with ApiOperation

use of io.swagger.annotations.ApiOperation in project swagger-core by swagger-api.

the class ResourceWithValidation method getTestSwaggerAnd303.

@GET
@Path("/swagger-and-303")
@ApiOperation(value = "Get", httpMethod = "GET")
public Response getTestSwaggerAnd303(@ApiParam(value = "sample param data", required = false, allowableValues = "range[7, infinity]") @QueryParam("id") @NotNull @Min(5) Integer id) throws WebApplicationException {
    Sample out = new Sample();
    out.setName("foo");
    out.setValue("bar");
    return Response.ok().entity(out).build();
}
Also used : Sample(io.swagger.models.Sample) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 97 with ApiOperation

use of io.swagger.annotations.ApiOperation in project pulsar by yahoo.

the class BrokerStats method getBrokerResourceAvailability.

@GET
@Path("/broker-resource-availability/{property}/{cluster}/{namespace}")
@ApiOperation(value = "Broker availability report", notes = "This API gives the current broker availability in percent, each resource percentage usage is calculated and then" + "sum of all of the resource usage percent is called broker-resource-availability" + "<br/><br/>THIS API IS ONLY FOR USE BY TESTING FOR CONFIRMING NAMESPACE ALLOCATION ALGORITHM", response = ResourceUnit.class, responseContainer = "Map")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public Map<Long, Collection<ResourceUnit>> getBrokerResourceAvailability(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) throws Exception {
    try {
        NamespaceName ns = new NamespaceName(property, cluster, namespace);
        SimpleLoadManagerImpl lm = (SimpleLoadManagerImpl) (pulsar().getLoadManager());
        return lm.getResourceAvailabilityFor(ns).asMap();
    } catch (Exception e) {
        log.error("Unable to get Resource Availability - [{}]", e);
        throw new RestException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) SimpleLoadManagerImpl(com.yahoo.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) RestException(com.yahoo.pulsar.broker.web.RestException) RestException(com.yahoo.pulsar.broker.web.RestException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 98 with ApiOperation

use of io.swagger.annotations.ApiOperation in project pulsar by yahoo.

the class Brokers method getActiveBrokers.

@GET
@Path("/{cluster}")
@ApiOperation(value = "Get the list of active brokers (web service addresses) in the cluster.", response = String.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Cluster doesn't exist") })
public Set<String> getActiveBrokers(@PathParam("cluster") String cluster) throws Exception {
    validateSuperUserAccess();
    validateClusterOwnership(cluster);
    try {
        // Add Native brokers
        return pulsar().getLocalZkCache().getChildren(SimpleLoadManagerImpl.LOADBALANCE_BROKERS_ROOT);
    } catch (Exception e) {
        LOG.error(String.format("[%s] Failed to get active broker list: cluster=%s", clientAppId(), cluster), e);
        throw new RestException(e);
    }
}
Also used : RestException(com.yahoo.pulsar.broker.web.RestException) RestException(com.yahoo.pulsar.broker.web.RestException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 99 with ApiOperation

use of io.swagger.annotations.ApiOperation in project pulsar by yahoo.

the class Brokers method getOwnedNamespaes.

@GET
@Path("/{cluster}/{broker}/ownedNamespaces")
@ApiOperation(value = "Get the list of namespaces served by the specific broker", response = NamespaceOwnershipStatus.class, responseContainer = "Map")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Cluster doesn't exist") })
public Map<String, NamespaceOwnershipStatus> getOwnedNamespaes(@PathParam("cluster") String cluster, @PathParam("broker") String broker) throws Exception {
    validateSuperUserAccess();
    validateClusterOwnership(cluster);
    validateBrokerName(broker);
    try {
        // now we validated that this is the broker specified in the request
        return pulsar().getNamespaceService().getOwnedNameSpacesStatus();
    } catch (Exception e) {
        LOG.error("[{}] Failed to get the namespace ownership status. cluster={}, broker={}", clientAppId(), cluster, broker);
        throw new RestException(e);
    }
}
Also used : RestException(com.yahoo.pulsar.broker.web.RestException) RestException(com.yahoo.pulsar.broker.web.RestException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 100 with ApiOperation

use of io.swagger.annotations.ApiOperation in project pulsar by yahoo.

the class Namespaces method unsubscribeNamespace.

@POST
@Path("/{property}/{cluster}/{namespace}/unsubscribe/{subscription}")
@ApiOperation(value = "Unsubscribes the given subscription on all destinations on a namespace.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Namespace does not exist") })
public void unsubscribeNamespace(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace, @PathParam("subscription") String subscription, @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateAdminAccessOnProperty(property);
    NamespaceName nsName = new NamespaceName(property, cluster, namespace);
    try {
        NamespaceBundles bundles = pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(nsName);
        Exception exception = null;
        for (NamespaceBundle nsBundle : bundles.getBundles()) {
            try {
                // check if the bundle is owned by any broker, if not then there are no subscriptions
                if (pulsar().getNamespaceService().getOwner(nsBundle).isPresent()) {
                    // TODO: make this admin call asynchronous
                    pulsar().getAdminClient().namespaces().unsubscribeNamespaceBundle(nsName.toString(), nsBundle.getBundleRange(), subscription);
                }
            } catch (Exception e) {
                if (exception == null) {
                    exception = e;
                }
            }
        }
        if (exception != null) {
            if (exception instanceof PulsarAdminException) {
                throw new RestException((PulsarAdminException) exception);
            } else {
                throw new RestException(exception.getCause());
            }
        }
    } catch (WebApplicationException wae) {
        throw wae;
    } catch (Exception e) {
        throw new RestException(e);
    }
    log.info("[{}] Successfully unsubscribed {} on all the bundles for namespace {}", clientAppId(), subscription, nsName.toString());
}
Also used : NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) WebApplicationException(javax.ws.rs.WebApplicationException) NamespaceBundles(com.yahoo.pulsar.common.naming.NamespaceBundles) RestException(com.yahoo.pulsar.broker.web.RestException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) RestException(com.yahoo.pulsar.broker.web.RestException) WebApplicationException(javax.ws.rs.WebApplicationException) SubscriptionBusyException(com.yahoo.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException) KeeperException(org.apache.zookeeper.KeeperException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)680 ApiResponses (io.swagger.annotations.ApiResponses)499 Path (javax.ws.rs.Path)409 Produces (javax.ws.rs.Produces)280 Timed (com.codahale.metrics.annotation.Timed)255 GET (javax.ws.rs.GET)237 POST (javax.ws.rs.POST)149 Consumes (javax.ws.rs.Consumes)134 TimedResource (org.killbill.commons.metrics.TimedResource)112 Counted (com.codahale.metrics.annotation.Counted)107 AuditEvent (org.graylog2.audit.jersey.AuditEvent)99 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)94 ApiResponse (io.swagger.annotations.ApiResponse)87 PUT (javax.ws.rs.PUT)84 Response (javax.ws.rs.core.Response)81 DELETE (javax.ws.rs.DELETE)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)68 URI (java.net.URI)62 UUID (java.util.UUID)62 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58