Search in sources :

Example 6 with PulsarAdminException

use of com.yahoo.pulsar.client.admin.PulsarAdminException in project pulsar by yahoo.

the class NamespacesImpl method grantPermissionOnNamespace.

@Override
public void grantPermissionOnNamespace(String namespace, String role, Set<AuthAction> actions) throws PulsarAdminException {
    try {
        NamespaceName ns = new NamespaceName(namespace);
        request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName()).path("permissions").path(role)).post(Entity.entity(actions, MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Example 7 with PulsarAdminException

use of com.yahoo.pulsar.client.admin.PulsarAdminException in project pulsar by yahoo.

the class PersistentTopicsImpl method grantPermission.

@Override
public void grantPermission(String destination, String role, Set<AuthAction> actions) throws PulsarAdminException {
    try {
        DestinationName ds = DestinationName.get(destination);
        request(persistentTopics.path(ds.getNamespace()).path(ds.getLocalName()).path("permissions").path(role)).post(Entity.entity(actions, MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) ServerErrorException(javax.ws.rs.ServerErrorException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 8 with PulsarAdminException

use of com.yahoo.pulsar.client.admin.PulsarAdminException in project pulsar by yahoo.

the class PersistentTopicsImpl method revokePermissions.

@Override
public void revokePermissions(String destination, String role) throws PulsarAdminException {
    try {
        DestinationName ds = DestinationName.get(destination);
        request(persistentTopics.path(ds.getNamespace()).path(ds.getLocalName()).path("permissions").path(role)).delete(ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) ServerErrorException(javax.ws.rs.ServerErrorException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 9 with PulsarAdminException

use of com.yahoo.pulsar.client.admin.PulsarAdminException in project pulsar by yahoo.

the class PersistentTopicsImpl method resetCursor.

@Override
public void resetCursor(String destination, String subName, long timestamp) throws PulsarAdminException {
    try {
        DestinationName ds = validateTopic(destination);
        String encodedSubName = Codec.encode(subName);
        request(persistentTopics.path(ds.getNamespace()).path(ds.getEncodedLocalName()).path("subscription").path(encodedSubName).path("resetcursor").path(String.valueOf(timestamp))).post(Entity.entity("", MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) ExecutionException(java.util.concurrent.ExecutionException) ServerErrorException(javax.ws.rs.ServerErrorException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 10 with PulsarAdminException

use of com.yahoo.pulsar.client.admin.PulsarAdminException in project pulsar by yahoo.

the class NamespacesImpl method createNamespace.

@Override
public void createNamespace(String namespace, BundlesData bundlesData) throws PulsarAdminException {
    try {
        NamespaceName ns = new NamespaceName(namespace);
        request(namespaces.path(ns.getProperty()).path(ns.getCluster()).path(ns.getLocalName())).put(Entity.entity(bundlesData, MediaType.APPLICATION_JSON), ErrorData.class);
    } catch (Exception e) {
        throw getApiException(e);
    }
}
Also used : NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException)

Aggregations

PulsarAdminException (com.yahoo.pulsar.client.admin.PulsarAdminException)45 NamespaceName (com.yahoo.pulsar.common.naming.NamespaceName)30 Test (org.testng.annotations.Test)12 PulsarServerException (com.yahoo.pulsar.broker.PulsarServerException)7 MockedPulsarServiceBaseTest (com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)7 NotFoundException (com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException)7 NamespaceBundle (com.yahoo.pulsar.common.naming.NamespaceBundle)7 ClusterData (com.yahoo.pulsar.common.policies.data.ClusterData)7 WebApplicationException (javax.ws.rs.WebApplicationException)7 PreconditionFailedException (com.yahoo.pulsar.client.admin.PulsarAdminException.PreconditionFailedException)6 RestException (com.yahoo.pulsar.broker.web.RestException)5 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 Path (javax.ws.rs.Path)5 SubscriptionBusyException (com.yahoo.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException)4 Consumer (com.yahoo.pulsar.client.api.Consumer)4 Producer (com.yahoo.pulsar.client.api.Producer)4 NamespaceBundles (com.yahoo.pulsar.common.naming.NamespaceBundles)4 PropertyAdmin (com.yahoo.pulsar.common.policies.data.PropertyAdmin)4 ClientErrorException (javax.ws.rs.ClientErrorException)4