Search in sources :

Example 6 with PluginSummary

use of co.cask.cdap.proto.artifact.PluginSummary in project cdap by caskdata.

the class ArtifactClient method getPluginSummaries.

/**
   * Gets all the plugins of the given type available to the given artifact.
   *
   * @param artifactId the id of the artifact to get
   * @param pluginType the type of plugins to get
   * @param scope the scope of the artifact
   * @return list of {@link PluginSummary}
   * @throws ArtifactNotFoundException if the given artifact does not exist
   * @throws IOException if a network error occurred
   * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
   */
public List<PluginSummary> getPluginSummaries(ArtifactId artifactId, String pluginType, ArtifactScope scope) throws IOException, UnauthenticatedException, ArtifactNotFoundException, UnauthorizedException {
    String path = String.format("artifacts/%s/versions/%s/extensions/%s?scope=%s", artifactId.getArtifact(), artifactId.getVersion(), pluginType, scope.name());
    URL url = config.resolveNamespacedURLV3(artifactId.getParent(), path);
    HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
    if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
        throw new ArtifactNotFoundException(artifactId);
    }
    return ObjectResponse.<List<PluginSummary>>fromJsonBody(response, PLUGIN_SUMMARIES_TYPE).getResponseObject();
}
Also used : HttpResponse(co.cask.common.http.HttpResponse) PluginSummary(co.cask.cdap.proto.artifact.PluginSummary) ArtifactNotFoundException(co.cask.cdap.common.ArtifactNotFoundException) URL(java.net.URL)

Aggregations

PluginSummary (co.cask.cdap.proto.artifact.PluginSummary)6 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)4 ArtifactRange (co.cask.cdap.api.artifact.ArtifactRange)3 PluginPropertyField (co.cask.cdap.api.plugin.PluginPropertyField)3 Id (co.cask.cdap.proto.Id)3 PluginInfo (co.cask.cdap.proto.artifact.PluginInfo)3 ArtifactId (co.cask.cdap.proto.id.ArtifactId)3 NamespaceId (co.cask.cdap.proto.id.NamespaceId)3 Manifest (java.util.jar.Manifest)3 Test (org.junit.Test)3 ArtifactVersion (co.cask.cdap.api.artifact.ArtifactVersion)2 PluginClass (co.cask.cdap.api.plugin.PluginClass)2 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)2 Plugin1 (co.cask.cdap.internal.app.runtime.artifact.plugin.Plugin1)2 Plugin2 (co.cask.cdap.internal.app.runtime.artifact.plugin.Plugin2)2 IOException (java.io.IOException)2 WordCountApp (co.cask.cdap.WordCountApp)1 ApplicationClass (co.cask.cdap.api.artifact.ApplicationClass)1 ArtifactClasses (co.cask.cdap.api.artifact.ArtifactClasses)1 ArtifactInfo (co.cask.cdap.api.artifact.ArtifactInfo)1