Search in sources :

Example 1 with PluginInstanceDetail

use of co.cask.cdap.proto.PluginInstanceDetail in project cdap by caskdata.

the class ApplicationLifecycleService method getPlugins.

/**
 * Get detail about the plugin in the specified application
 *
 * @param appId the id of the application
 * @return list of plugins in the application
 * @throws ApplicationNotFoundException if the specified application does not exist
 */
public List<PluginInstanceDetail> getPlugins(ApplicationId appId) throws ApplicationNotFoundException {
    ApplicationSpecification appSpec = store.getApplication(appId);
    if (appSpec == null) {
        throw new ApplicationNotFoundException(appId);
    }
    List<PluginInstanceDetail> pluginInstanceDetails = new ArrayList<>();
    for (Map.Entry<String, Plugin> entry : appSpec.getPlugins().entrySet()) {
        pluginInstanceDetails.add(new PluginInstanceDetail(entry.getKey(), entry.getValue()));
    }
    return pluginInstanceDetails;
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) ArrayList(java.util.ArrayList) PluginInstanceDetail(co.cask.cdap.proto.PluginInstanceDetail) Map(java.util.Map) HashMap(java.util.HashMap) Plugin(co.cask.cdap.api.plugin.Plugin)

Example 2 with PluginInstanceDetail

use of co.cask.cdap.proto.PluginInstanceDetail 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);
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TypeToken(com.google.gson.reflect.TypeToken) PluginInstanceDetail(co.cask.cdap.proto.PluginInstanceDetail)

Aggregations

PluginInstanceDetail (co.cask.cdap.proto.PluginInstanceDetail)2 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 Plugin (co.cask.cdap.api.plugin.Plugin)1 ApplicationNotFoundException (co.cask.cdap.common.ApplicationNotFoundException)1 TypeToken (com.google.gson.reflect.TypeToken)1 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)1 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1