Monday 15 August 2022

Atlas Client: Delete one or more classifications associated with an entity by entity id

AtlasClientV2#deleteClassifications method is used to delete one or more classifications associated with an entity.

 

Signature

public void deleteClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException

  

For example, as you see below image, there are two classifications (classified, sensitive_data) are associated with the entity id 898c2aa1-d31a-4d0b-a1fd-7a76da6a4071.

 


Below snippet remove both the classifications of the entity.

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

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

atlasClient.deleteClassifications("898c2aa1-d31a-4d0b-a1fd-7a76da6a4071",Arrays.asList(sensitiveDataClassification, classifiedClassification));

 

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 DeleteClassificationsOfEntityById class.

 

DeleteClassificationsOfEntityById.java

 

package com.sample.app.classifications;

import java.util.Arrays;

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

public class DeleteClassificationsOfEntityById {
	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");

		atlasClient.deleteClassifications("898c2aa1-d31a-4d0b-a1fd-7a76da6a4071",
				Arrays.asList(sensitiveDataClassification, classifiedClassification));

	}

}

Run above application, you can observe that the classifications are removed from the entity.

 

 

 

 


Previous                                                    Next                                                    Home

No comments:

Post a Comment