use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method scheduleStatus.
public String scheduleStatus(String namespaceId, String appId, String schedId, int expectedResponseCode) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/schedules/%s/status", getNamespacePath(namespaceId), appId, schedId);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
try {
programLifecycleHttpHandler.getStatus(request, responder, namespaceId, appId, "schedules", schedId);
} catch (NotFoundException e) {
return "NOT_FOUND";
}
verifyResponse(HttpResponseStatus.valueOf(expectedResponseCode), responder.getStatus(), "Get schedules status failed");
Map<String, String> json = responder.decodeResponseContent(MAP_TYPE);
return json.get("status");
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method deleteApplication.
public void deleteApplication(ApplicationId appId) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, 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.deleteApp(request, mockResponder, appId.getNamespace(), appId.getApplication());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Deleting app failed");
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method listAppVersions.
public Collection<String> listAppVersions(ApplicationId appId) throws Exception {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s/versions", getNamespacePath(appId.getNamespace()), appId.getApplication()));
request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
MockResponder mockResponder = new MockResponder();
appLifecycleHttpHandler.listAppVersions(request, mockResponder, appId.getNamespace(), appId.getApplication());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Failed to list application versions");
return mockResponder.decodeResponseContent(new TypeToken<Collection<String>>() {
}.getType(), GSON);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getFlowletInstances.
public Instances getFlowletInstances(String namespaceId, String applicationId, String flowName, String flowletName) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/flows/%s/flowlets/%s/instances", getNamespacePath(namespaceId), applicationId, flowName, flowletName);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
programLifecycleHttpHandler.getFlowletInstances(request, responder, namespaceId, applicationId, flowName, flowletName);
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Get flowlet instances failed");
return responder.decodeResponseContent(Instances.class);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method deleteSchedule.
public void deleteSchedule(ScheduleId scheduleId) throws Exception {
MockResponder responder = new MockResponder();
ApplicationId application = scheduleId.getParent();
String uri = String.format("%s/apps/%s/versions/%s/schedules/%s", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule());
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, uri);
programLifecycleHttpHandler.deleteSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule());
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Delete schedule failed");
}
Aggregations