Tuesday, 16 August 2022

Atlas Client: Delete classification of entity by unique attributes

AtlasClientV2#removeClassification method is used to delete the classifications of entity by unique attributes.

 

Signature

public void removeClassification(String typeName, Map<String, String> uniqAttributes, String classificationName) throws AtlasServiceException

For example, as you see below image, the classification ‘classified’ is associated with the entity CreateEntity_DEMO1.


Below snippet removes the classified classification.

String typeName = "DemoType1";
Map<String, String> uniqueAttributes = new HashMap<>();
uniqueAttributes.put("qualifiedName", "CreateEntity_DEMO1");

atlasClient.removeClassification(typeName, uniqueAttributes, "classified");

 

Find the below working application.

 

Create atlas-application.properties file under src/main/resources folder.

 

atlas-application.properties

 

atlas.client.readTimeoutMSecs=30000
atlas.client.connectTimeoutMSecs=30000

 

Define DeleteClassificationByUniqueAttribute class.

 

DeleteClassificationByUniqueAttribute.java
package com.sample.app.classifications;

import java.util.HashMap;
import java.util.Map;

import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.model.instance.AtlasClassification;

public class DeleteClassificationByUniqueAttribute {
	public static void main(String[] args) throws AtlasServiceException {
		AtlasClientV2 atlasClient = new AtlasClientV2(new String[] { "http://localhost:21000" },
				new String[] { "admin", "admin" });

		AtlasClassification sensitiveDataClassification = new AtlasClassification();
		sensitiveDataClassification.setTypeName("sensitive_data");

		AtlasClassification classifiedClassification = new AtlasClassification();
		classifiedClassification.setTypeName("classified");

		String typeName = "DemoType1";
		Map<String, String> uniqueAttributes = new HashMap<>();
		uniqueAttributes.put("qualifiedName", "CreateEntity_DEMO1");

		atlasClient.removeClassification(typeName, uniqueAttributes, "classified");

	}

}

 


 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment