Does the RestEmitter in Java support delete via a ...
# ingestion
o
Does the RestEmitter in Java support delete via a MetadataChangeProposal? My analysis of the code tells me the below type of code should work, but I'm not seeing the delete happen:
DataMap dataMap = new DataMap();
dataMap.put("entityType", "dataset");
dataMap.put("entityUrn", "urn:li:dataset:(urn:li:dataPlatform:myDp,myDB.myTable,DEV)");
dataMap.put("changeType", "UPSERT");
dataMap.put("aspectName", "status");
DataMap aspectMap = new DataMap();
DataMap aspectValueMap = new DataMap();
aspectValueMap.put("removed", true);
aspectMap.put("value", aspectValueMap);
aspectMap.put("contentType", "application/json");
dataMap.put("aspect", aspectMap);
MetadataChangeProposal mcp = new MetadataChangeProposal(dataMap);
RestEmitter client = RestEmitter.create(b -> b.server("<http://localhost:8080>"));
client.emit(mcp, callback);
My alternative would be to fallback to the OpenAPI endpoint (https://demo.datahubproject.io/openapi/swagger-ui/index.html#/Entities/deleteEntities), but I'd rather use RestEmitter and avoid doing raw Http myself. Thanks.
m
There is a simpler way using the
MetadataChangeProposalWrapper
class as shown here: https://datahubproject.io/docs/metadata-integration/java/as-a-library/#usage
o
Thanks! That works. Is it possible to do a Hard Delete via this Rest approach? My current code looks like this: MetadataChangeProposalWrapper mcpw = new MetadataChangeProposalWrapperBuilder() .entityType("dataset") .entityUrn("urnlidataset:(urnlidataPlatform:myDp,myDb.myTable,DEV)") .upsert() .aspect(new Status().setRemoved(true)) .aspectName("status") .build();