use of io.apiman.gateway.engine.beans.Client in project apiman by apiman.
the class SharedGlobalDataRegistry method unregisterClient.
@Override
public void unregisterClient(Client client, IAsyncResultHandler<Void> resultHandler) {
String clientIndex = getClientIndex(client);
objectMap.get(clientIndex, handleSuccessfulResult(resultHandler, oldClientRaw -> {
Client oldClient = (Client) oldClientRaw;
if (oldClient == null) {
Exception ex = new ClientNotFoundException(Messages.i18n.format("InMemoryRegistry.ClientNotFound"));
resultHandler.handle(AsyncResultImpl.create(ex));
} else {
Future<Object> future1 = Future.future();
Future<Object> future2 = Future.future();
objectMap.remove(clientIndex, future1.completer());
objectMap.remove(oldClient.getApiKey(), future2.completer());
CompositeFuture.all(future1, future2).setHandler(handleCompositeResult(resultHandler));
}
}));
}
use of io.apiman.gateway.engine.beans.Client in project apiman by apiman.
the class RateLimitingPolicyTest method createTestContract.
/**
* @return a test contract
*/
private ApiContract createTestContract() {
Api api = new Api();
api.setOrganizationId("ApiOrg");
api.setApiId("Api");
api.setVersion("1.0");
Client app = new Client();
app.setApiKey("12345");
app.setOrganizationId("AppOrg");
app.setClientId("App");
app.setVersion("1.0");
return new ApiContract(api, app, "Gold", null);
}
use of io.apiman.gateway.engine.beans.Client in project apiman by apiman.
the class EBRegistryProxyHandler method listenProxyHandler.
@SuppressWarnings("nls")
default void listenProxyHandler(IAsyncResultHandler<Void> startupHandler) {
log().info("Setting up a listener on: {0}", address());
MessageConsumer<JsonObject> consumer = vertx().eventBus().consumer(address(), (Message<JsonObject> message) -> {
String inboundUuid = message.body().getString("uuid");
log().debug("[{0}] Handling command from inbound UUID: {1} {2}", uuid(), inboundUuid, message);
if (shouldIgnore(inboundUuid))
return;
String type = message.body().getString("type");
String action = message.body().getString("action");
String body = message.body().getString("body");
switch(type) {
case "client":
Client app = Json.decodeValue(body, Client.class);
if (action.equals("register")) {
registerClient(app);
} else if (action.equals("unregister")) {
unregisterClient(app);
}
break;
case "api":
Api api = Json.decodeValue(body, Api.class);
if (action.equals("publish")) {
publishApi(api);
} else if (action.equals("retire")) {
retireApi(api);
}
break;
default:
throw new IllegalStateException("Unknown type: " + type);
}
});
consumer.completionHandler(complete -> {
if (complete.succeeded()) {
startupHandler.handle(AsyncResultImpl.create((Void) null));
} else {
startupHandler.handle(AsyncResultImpl.create(complete.cause()));
}
});
consumer.exceptionHandler(ex -> {
log().error("[{0}] An exception occurred: {1}", uuid(), ex);
ex.printStackTrace();
});
}
use of io.apiman.gateway.engine.beans.Client in project apiman by apiman.
the class CachingEsRegistry method getClient.
/**
* @see io.apiman.gateway.engine.jdbc.JdbcRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler)
*/
@Override
public void getClient(String apiKey, IAsyncResultHandler<Client> handler) {
try {
Client client = getClient(apiKey);
handler.handle(AsyncResultImpl.create(client));
} catch (IOException e) {
handler.handle(AsyncResultImpl.create(e, Client.class));
}
}
use of io.apiman.gateway.engine.beans.Client in project apiman by apiman.
the class EsRegistry method getClient.
/**
* @see io.apiman.gateway.engine.IRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler)
*/
@Override
public void getClient(String apiKey, IAsyncResultHandler<Client> handler) {
String id = apiKey;
try {
Client client = getClient(id);
handler.handle(AsyncResultImpl.create(client));
} catch (IOException e) {
handler.handle(AsyncResultImpl.create(e, Client.class));
}
}
Aggregations