use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getVersionedInfo.
public ApplicationDetail getVersionedInfo(ApplicationId appId) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s/versions/%s", getNamespacePath(appId.getNamespace()), appId.getApplication(), appId.getVersion()));
request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
MockResponder mockResponder = new MockResponder();
appLifecycleHttpHandler.getAppVersionInfo(request, mockResponder, appId.getNamespace(), appId.getApplication(), appId.getVersion());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Getting app version info failed");
return mockResponder.decodeResponseContent(new TypeToken<ApplicationDetail>() {
}.getType(), GSON);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method deployApplication.
public void deployApplication(ApplicationId appId, AppRequest appRequest) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, String.format("%s/apps/%s/versions/%s/create", getNamespacePath(appId.getNamespace()), appId.getApplication(), appId.getVersion()));
request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
HttpUtil.setTransferEncodingChunked(request, true);
MockResponder mockResponder = new MockResponder();
BodyConsumer bodyConsumer = appLifecycleHttpHandler.createAppVersion(request, mockResponder, appId.getNamespace(), appId.getApplication(), appId.getVersion());
Preconditions.checkNotNull(bodyConsumer, "BodyConsumer from deploy call should not be null");
bodyConsumer.chunk(Unpooled.copiedBuffer(GSON.toJson(appRequest), StandardCharsets.UTF_8), mockResponder);
bodyConsumer.finished(mockResponder);
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Failed to deploy app");
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getPlugins.
public List<PluginInstanceDetail> getPlugins(ApplicationId application) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s", getNamespacePath(application.getNamespace()), application.getApplication()));
request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
MockResponder mockResponder = new MockResponder();
appLifecycleHttpHandler.getPluginsInfo(request, mockResponder, application.getNamespace(), application.getApplication());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Getting app info failed");
return mockResponder.decodeResponseContent(new TypeToken<List<PluginInstanceDetail>>() {
}.getType(), GSON);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getWorkerInstances.
public Instances getWorkerInstances(String namespaceId, String appId, String workerId) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/worker/%s/instances", getNamespacePath(namespaceId), appId, workerId);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
programLifecycleHttpHandler.getWorkerInstances(request, responder, namespaceId, appId, workerId);
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Get worker instances failed");
return responder.decodeResponseContent(Instances.class);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getInfo.
public ApplicationDetail getInfo(ApplicationId appId) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s", getNamespacePath(appId.getNamespace()), appId.getApplication()));
request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
MockResponder mockResponder = new MockResponder();
appLifecycleHttpHandler.getAppInfo(request, mockResponder, appId.getNamespace(), appId.getApplication());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Getting app info failed");
return mockResponder.decodeResponseContent(new TypeToken<ApplicationDetail>() {
}.getType(), GSON);
}
Aggregations