use of org.apache.pulsar.client.admin.PulsarAdminException in project incubator-pulsar by apache.
the class PersistentTopicsImpl method grantPermission.
@Override
public void grantPermission(String topic, String role, Set<AuthAction> actions) throws PulsarAdminException {
try {
TopicName tn = TopicName.get(topic);
WebTarget path = topicPath(tn, "permissions", role);
request(path).post(Entity.entity(actions, MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException in project incubator-pulsar by apache.
the class PersistentTopicsImpl method createSubscription.
@Override
public void createSubscription(String topic, String subscriptionName, MessageId messageId) throws PulsarAdminException {
try {
TopicName tn = validateTopic(topic);
String encodedSubName = Codec.encode(subscriptionName);
WebTarget path = topicPath(tn, "subscription", encodedSubName);
request(path).put(Entity.entity(messageId, MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException in project incubator-pulsar by apache.
the class PersistentTopicsImpl method getPermissions.
@Override
public Map<String, Set<AuthAction>> getPermissions(String topic) throws PulsarAdminException {
try {
TopicName tn = TopicName.get(topic);
WebTarget path = topicPath(tn, "permissions");
return request(path).get(new GenericType<Map<String, Set<AuthAction>>>() {
});
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException in project incubator-pulsar by apache.
the class ResourceQuotasImpl method getNamespaceBundleResourceQuota.
public ResourceQuota getNamespaceBundleResourceQuota(String namespace, String bundle) throws PulsarAdminException {
try {
NamespaceName ns = NamespaceName.get(namespace);
WebTarget path = namespacePath(ns, bundle);
return request(path).get(ResourceQuota.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException in project incubator-pulsar by apache.
the class FunctionsImpl method updateFunction.
@Override
public void updateFunction(FunctionConfig functionConfig, String fileName) throws PulsarAdminException {
try {
final FormDataMultiPart mp = new FormDataMultiPart();
if (fileName != null) {
mp.bodyPart(new FileDataBodyPart("data", new File(fileName), MediaType.APPLICATION_OCTET_STREAM_TYPE));
}
mp.bodyPart(new FormDataBodyPart("functionConfig", Utils.printJson(functionConfig), MediaType.APPLICATION_JSON_TYPE));
request(functions.path(functionConfig.getTenant()).path(functionConfig.getNamespace()).path(functionConfig.getName())).put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
Aggregations