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));
}
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);
}
}
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");
}
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);
}
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);
}
Aggregations