use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.
the class MetadataHttpHandler method removeTag.
@DELETE
@Path("/**/metadata/tags/{tag}")
public void removeTag(HttpRequest request, HttpResponder responder, @PathParam("tag") String tag, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata/tags");
enforce(metadataEntity, StandardPermission.UPDATE);
metadataAdmin.removeTags(metadataEntity, Collections.singleton(tag), async ? ASYNC : SYNC);
responder.sendString(HttpResponseStatus.OK, String.format("Metadata tag %s for %s deleted successfully.", tag, metadataEntity));
}
use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.
the class MetadataHttpHandler method removeProperty.
@DELETE
@Path("/**/metadata/properties/{property}")
public void removeProperty(HttpRequest request, HttpResponder responder, @PathParam("property") String property, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata/properties");
enforce(metadataEntity, StandardPermission.UPDATE);
metadataAdmin.removeProperties(metadataEntity, Collections.singleton(property), async ? ASYNC : SYNC);
responder.sendString(HttpResponseStatus.OK, String.format("Metadata property %s for %s deleted successfully.", property, metadataEntity));
}
use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.
the class DataPipelineConnectionTest method testConnectionsRegistry.
@Test
public void testConnectionsRegistry() throws Exception {
// source -> sink
ETLBatchConfig conf1 = ETLBatchConfig.builder().addStage(new ETLStage("source", MockSource.getPluginUsingConnection("conn 1"))).addStage(new ETLStage("sink", MockSink.getPluginUsingConnection("conn 3"))).addConnection("source", "sink").build();
// 3 sources -> identity -> 2 sinks
ETLBatchConfig conf2 = ETLBatchConfig.builder().addStage(new ETLStage("src1", MockSource.getPluginUsingConnection("conn 1"))).addStage(new ETLStage("src2", MockSource.getPluginUsingConnection("conn 2"))).addStage(new ETLStage("src3", MockSource.getPluginUsingConnection("conn 3"))).addStage(new ETLStage("sink1", MockSink.getPluginUsingConnection("conn 4"))).addStage(new ETLStage("sink2", MockSink.getPluginUsingConnection("conn 5"))).addStage(new ETLStage("identity", IdentityTransform.getPlugin())).addConnection("src1", "identity").addConnection("src2", "identity").addConnection("src3", "identity").addConnection("identity", "sink1").addConnection("identity", "sink2").build();
// deploy apps
AppRequest<ETLBatchConfig> appRequest1 = new AppRequest<>(APP_ARTIFACT, conf1);
ApplicationId appId1 = NamespaceId.DEFAULT.app("app1");
ApplicationManager appManager1 = deployApplication(appId1, appRequest1);
AppRequest<ETLBatchConfig> appRequest2 = new AppRequest<>(APP_ARTIFACT, conf2);
ApplicationId appId2 = NamespaceId.DEFAULT.app("app2");
ApplicationManager appManager2 = deployApplication(appId2, appRequest2);
// Assert metadata
Metadata app1Actual = getMetadataAdmin().getMetadata(appId1.toMetadataEntity(), MetadataScope.SYSTEM);
Set<String> app1ExpectedTags = ImmutableSet.of("_conn_1", "_conn_3");
// here assert actual tags contain all the tags about connections
Assert.assertTrue(app1Actual.getTags(MetadataScope.SYSTEM).containsAll(app1ExpectedTags));
// user metadata should be empty
Assert.assertEquals(Metadata.EMPTY, getMetadataAdmin().getMetadata(appId1.toMetadataEntity(), MetadataScope.USER));
Metadata app2Actual = getMetadataAdmin().getMetadata(appId2.toMetadataEntity(), MetadataScope.SYSTEM);
Set<String> app2ExpectedTags = ImmutableSet.of("_conn_1", "_conn_2", "_conn_3", "_conn_4", "_conn_5");
// here assert actual tags contain all the tags about connections
Assert.assertTrue(app2Actual.getTags(MetadataScope.SYSTEM).containsAll(app2ExpectedTags));
// user metadata should be empty
Assert.assertEquals(Metadata.EMPTY, getMetadataAdmin().getMetadata(appId2.toMetadataEntity(), MetadataScope.USER));
// using search query to find out the related apps
Set<MetadataEntity> appsRelated = ImmutableSet.of(appId1.toMetadataEntity(), appId2.toMetadataEntity());
assertMetadataSearch(appsRelated, "tags:_conn_1");
assertMetadataSearch(Collections.singleton(appId2.toMetadataEntity()), "tags:_conn_2");
assertMetadataSearch(appsRelated, "tags:_conn_3");
assertMetadataSearch(Collections.singleton(appId2.toMetadataEntity()), "tags:_conn_4");
assertMetadataSearch(Collections.singleton(appId2.toMetadataEntity()), "tags:_conn_5");
}
use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.
the class RemoveMetadataPropertyCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
MetadataEntity metadataEntity = MetadataCommandHelper.toMetadataEntity(arguments.get(ArgumentName.ENTITY.toString()));
String property = arguments.get("property");
client.removeProperty(metadataEntity, property);
output.println("Successfully removed metadata property");
}
use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.
the class AddMetadataTagsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
MetadataEntity metadataEntity = MetadataCommandHelper.toMetadataEntity(arguments.get(ArgumentName.ENTITY.toString()));
Set<String> tags = ImmutableSet.copyOf(parseList(arguments.get("tags")));
client.addTags(metadataEntity, tags);
output.println("Successfully added metadata tags");
}
Aggregations