Search in sources :

Example 71 with ArtifactId

use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.

the class MetadataHttpHandler method getArtifactTags.

@GET
@Path("/namespaces/{namespace-id}/artifacts/{artifact-name}/versions/{artifact-version}/metadata/tags")
public void getArtifactTags(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("artifact-name") String artifactName, @PathParam("artifact-version") String artifactVersionStr, @QueryParam("scope") String scope) throws BadRequestException, NotFoundException {
    ArtifactId artifactId = new ArtifactId(namespaceId, artifactName, artifactVersionStr);
    responder.sendJson(HttpResponseStatus.OK, getTags(artifactId, scope));
}
Also used : ArtifactId(co.cask.cdap.proto.id.ArtifactId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 72 with ArtifactId

use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.

the class SetArtifactPropertiesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
    String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString());
    String scopeStr = arguments.get(ArgumentName.SCOPE.toString());
    ArtifactScope scope = ArtifactScope.valueOf(scopeStr.toUpperCase());
    NamespaceId namespace = scope == ArtifactScope.SYSTEM ? NamespaceId.SYSTEM : cliConfig.getCurrentNamespace();
    ArtifactId artifactId = namespace.artifact(artifactName, artifactVersion);
    String propertiesFilePath = arguments.get(ArgumentName.LOCAL_FILE_PATH.toString());
    File propertiesFile = resolver.resolvePathToFile(propertiesFilePath);
    try (Reader reader = new FileReader(propertiesFile)) {
        ArtifactProperties properties;
        try {
            properties = GSON.fromJson(reader, ArtifactProperties.class);
        } catch (Exception e) {
            throw new RuntimeException("Error parsing file contents. Please check that it is a valid JSON object, " + "and that it contains a 'properties' key whose value is a JSON object of the " + "artifact properties.", e);
        }
        artifactClient.writeProperties(artifactId, properties.properties);
    }
}
Also used : ArtifactScope(co.cask.cdap.api.artifact.ArtifactScope) ArtifactId(co.cask.cdap.proto.id.ArtifactId) Reader(java.io.Reader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) NamespaceId(co.cask.cdap.proto.id.NamespaceId) File(java.io.File)

Example 73 with ArtifactId

use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.

the class DeleteArtifactCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
    String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString());
    ArtifactId artifactId = cliConfig.getCurrentNamespace().artifact(artifactName, artifactVersion);
    artifactClient.delete(artifactId);
    output.printf("Successfully deleted artifact\n");
}
Also used : ArtifactId(co.cask.cdap.proto.id.ArtifactId)

Example 74 with ArtifactId

use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.

the class DescribeArtifactCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
    String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString());
    ArtifactId artifactId = cliConfig.getCurrentNamespace().artifact(artifactName, artifactVersion);
    String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
    ArtifactInfo info;
    if (scopeStr == null) {
        info = artifactClient.getArtifactInfo(artifactId);
    } else {
        ArtifactScope scope = ArtifactScope.valueOf(scopeStr.toUpperCase());
        info = artifactClient.getArtifactInfo(artifactId, scope);
    }
    Table table = Table.builder().setHeader("name", "version", "scope", "app classes", "plugin classes", "properties", "parents").setRows(ImmutableList.of((List<String>) ImmutableList.of(info.getName(), info.getVersion(), info.getScope().name(), GSON.toJson(info.getClasses().getApps()), GSON.toJson(info.getClasses().getPlugins()), GSON.toJson(info.getProperties()), Joiner.on('/').join(info.getParents())))).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : ArtifactScope(co.cask.cdap.api.artifact.ArtifactScope) Table(co.cask.cdap.cli.util.table.Table) ArtifactId(co.cask.cdap.proto.id.ArtifactId) ArtifactInfo(co.cask.cdap.api.artifact.ArtifactInfo)

Example 75 with ArtifactId

use of co.cask.cdap.proto.id.ArtifactId in project cdap by caskdata.

the class DescribeArtifactPluginCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
    String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString());
    ArtifactId artifactId = cliConfig.getCurrentNamespace().artifact(artifactName, artifactVersion);
    String pluginType = arguments.get(ArgumentName.PLUGIN_TYPE.toString());
    String pluginName = arguments.get(ArgumentName.PLUGIN_NAME.toString());
    List<PluginInfo> pluginInfos;
    String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
    if (scopeStr == null) {
        pluginInfos = artifactClient.getPluginInfo(artifactId, pluginType, pluginName);
    } else {
        pluginInfos = artifactClient.getPluginInfo(artifactId, pluginType, pluginName, ArtifactScope.valueOf(scopeStr.toUpperCase()));
    }
    Table table = Table.builder().setHeader("type", "name", "classname", "description", "properties", "artifact").setRows(pluginInfos, new RowMaker<PluginInfo>() {

        @Override
        public List<?> makeRow(PluginInfo object) {
            return Lists.newArrayList(object.getType(), object.getName(), object.getClassName(), object.getDescription(), GSON.toJson(object.getProperties()), object.getArtifact().toString());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) ArtifactId(co.cask.cdap.proto.id.ArtifactId) RowMaker(co.cask.cdap.cli.util.RowMaker) PluginInfo(co.cask.cdap.proto.artifact.PluginInfo)

Aggregations

ArtifactId (co.cask.cdap.proto.id.ArtifactId)82 Test (org.junit.Test)35 NamespaceId (co.cask.cdap.proto.id.NamespaceId)31 Id (co.cask.cdap.proto.Id)24 IOException (java.io.IOException)24 Path (javax.ws.rs.Path)24 ApplicationId (co.cask.cdap.proto.id.ApplicationId)23 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)16 ProgramId (co.cask.cdap.proto.id.ProgramId)16 AppRequest (co.cask.cdap.proto.artifact.AppRequest)13 PluginClass (co.cask.cdap.api.plugin.PluginClass)11 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)11 File (java.io.File)10 ArtifactVersion (co.cask.cdap.api.artifact.ArtifactVersion)9 ArtifactDetail (co.cask.cdap.internal.app.runtime.artifact.ArtifactDetail)8 DELETE (javax.ws.rs.DELETE)8 GET (javax.ws.rs.GET)8 ArtifactRange (co.cask.cdap.api.artifact.ArtifactRange)7 BadRequestException (co.cask.cdap.common.BadRequestException)7 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)6