use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.
the class RemoveMetadataPropertyCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
String property = arguments.get("property");
client.removeProperty(entity, property);
output.println("Successfully removed metadata property");
}
use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.
the class AddMetadataPropertiesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
Map<String, String> properties = parseMap(arguments.get("properties"), "<properties>");
client.addProperties(entity, properties);
output.println("Successfully added metadata properties");
}
use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.
the class GetMetadataCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
String scope = arguments.getOptional(ArgumentName.METADATA_SCOPE.toString());
Set<MetadataRecord> metadata = scope == null ? client.getMetadata(entity) : client.getMetadata(entity, MetadataScope.valueOf(scope.toUpperCase()));
Table table = Table.builder().setHeader("entity", "tags", "properties", "scope").setRows(Iterables.transform(metadata, new Function<MetadataRecord, List<String>>() {
@Nullable
@Override
public List<String> apply(MetadataRecord record) {
return Lists.newArrayList(record.getEntityId().toString(), Joiner.on("\n").join(record.getTags()), Joiner.on("\n").withKeyValueSeparator(":").join(record.getProperties()), record.getScope().name());
}
})).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.
the class RemoveMetadataPropertiesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
client.removeProperties(entity);
output.println("Successfully removed metadata properties");
}
use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.
the class DatasetServiceClient method getInstance.
@Nullable
public DatasetMeta getInstance(String instanceName, @Nullable Iterable<? extends EntityId> owners) throws DatasetManagementException {
String query = "";
if (owners != null) {
Set<String> ownerParams = Sets.newHashSet();
for (EntityId owner : owners) {
ownerParams.add("owner=" + owner.toString());
}
query = ownerParams.isEmpty() ? "" : "?" + Joiner.on("&").join(ownerParams);
}
HttpResponse response = doGet("datasets/" + instanceName + query);
if (HttpResponseStatus.NOT_FOUND.code() == response.getResponseCode()) {
return null;
}
if (HttpResponseStatus.FORBIDDEN.code() == response.getResponseCode()) {
throw new DatasetManagementException(String.format("Failed to get dataset instance %s, details: %s", instanceName, response), new UnauthorizedException(response.getResponseBodyAsString()));
}
if (HttpResponseStatus.OK.code() != response.getResponseCode()) {
throw new DatasetManagementException(String.format("Cannot retrieve dataset instance %s info, details: %s", instanceName, response));
}
return GSON.fromJson(response.getResponseBodyAsString(), DatasetMeta.class);
}
Aggregations