Thursday, 9 June 2022

Apache Atlas: Create and attach classification to an entity

Step 1: Create classification

sensitiveClassification.json

{
  "classificationDefs": [
    {
      "category": "CLASSIFICATION",
      "name": "sensitive",
      "description": "Represent a sensitive data"
    }
  ]
}

 

Execute below command to define classification.

curl -X POST -u admin:admin -H 'accept: application/json'  -H 'cache-control: no-cache'  -H 'content-type: application/json'  http://localhost:21000/api/atlas/v2/types/typedefs -d @sensitiveClassification.json

$ curl -X POST -u admin:admin -H 'accept: application/json'  -H 'cache-control: no-cache'  -H 'content-type: application/json'  http://localhost:21000/api/atlas/v2/types/typedefs -d @sensitiveClassification.json
{"enumDefs":[],"structDefs":[],"classificationDefs":[{"category":"CLASSIFICATION","guid":"1c2842c6-e44b-4f1c-a50f-f799786468c1","createdBy":"admin","updatedBy":"admin","createTime":1643380845551,"updateTime":1643380845551,"version":1,"name":"sensitive","description":"Represent a sensitive data","typeVersion":"1.0","attributeDefs":[],"superTypes":[],"entityTypes":[],"subTypes":[]}],"entityDefs":[],"relationshipDefs":[],"businessMetadataDefs":[]}

 

You can confirm the same from Atlas UI.

 


Step 2: Create a DataSet instance.

 

sensitiveData.json

{
  "entity": {
    "typeName": "DataSet",
    "attributes": {
      "owner": "Krishna Maj",
      "qualifiedName": "/sales/21/sensitive_data_201112312",
      "description": "sensitive file",
      "name": "sensitive_data_201112312.txt"
    }
  }
}

Execute below command to create dataset.

 

curl -X POST -u admin:admin -H 'accept: application/json'  -H 'cache-control: no-cache'  -H 'content-type: application/json'  http://localhost:21000/api/atlas/v2/entity -d @sensitiveData.json

$ curl -X POST -u admin:admin -H 'accept: application/json'  -H 'cache-control: no-cache'  -H 'content-type: application/json'  http://localhost:21000/api/atlas/v2/entity -d @sensitiveData.json
{"mutatedEntities":{"CREATE":[{"typeName":"DataSet","attributes":{"owner":"Krishna Maj","qualifiedName":"/sales/21/sensitive_data_201112312","name":"sensitive_data_201112312.txt","description":"sensitive file"},"guid":"a2543025-d4ac-4624-8abd-dc138c97dc39","status":"ACTIVE","displayText":"sensitive_data_201112312.txt","classificationNames":[],"classifications":[],"meaningNames":[],"meanings":[],"isIncomplete":false,"labels":[]}]},"guidAssignments":{"-17597882765337":"a2543025-d4ac-4624-8abd-dc138c97dc39"}}

Attach sensitive classification to dataset

Using the api ‘api/atlas/v2/entity/guid/{guid}/classifications’, we can attach classifications to an entity.

 

attachClassification.json

[ {
  "propagate" : true,
  "removePropagationsOnEntityDelete" : true,
  "typeName" : "sensitive"
} ]

Execute below command to attach sensitive classification to the dataset "sensitive_data_201112312.txt".

 

curl -X POST -u admin:admin -H 'accept: application/json'  -H 'cache-control: no-cache'  -H 'content-type: application/json'  http://localhost:21000/api/atlas/v2/entity/guid/a2543025-d4ac-4624-8abd-dc138c97dc39/classifications -d @attachClassification.json

 

'a2543025-d4ac-4624-8abd-dc138c97dc39' is the guid of the entity.

 

You can confirm the same from Atlas UI.

 


 

You can download application examples from this link.



Previous                                                    Next                                                    Home

No comments:

Post a Comment