Search in sources :

Example 1 with PluginInstanceDetail

use of io.cdap.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(io.cdap.cdap.proto.PluginInstanceDetail)

Example 2 with PluginInstanceDetail

use of io.cdap.cdap.proto.PluginInstanceDetail in project cdap by cdapio.

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(io.cdap.cdap.proto.PluginInstanceDetail)

Example 3 with PluginInstanceDetail

use of io.cdap.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(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationNotFoundException(io.cdap.cdap.common.ApplicationNotFoundException) ArrayList(java.util.ArrayList) PluginInstanceDetail(io.cdap.cdap.proto.PluginInstanceDetail) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Plugin(io.cdap.cdap.api.plugin.Plugin)

Example 4 with PluginInstanceDetail

use of io.cdap.cdap.proto.PluginInstanceDetail in project cdap by cdapio.

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(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationNotFoundException(io.cdap.cdap.common.ApplicationNotFoundException) ArrayList(java.util.ArrayList) PluginInstanceDetail(io.cdap.cdap.proto.PluginInstanceDetail) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Plugin(io.cdap.cdap.api.plugin.Plugin)

Aggregations

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