Saturday, 18 June 2022

Apache Atlas: Hard delete an entity

In this post, I am going to explain how to hard delete an entity.

 

Below command is used to hard delete an entity.

 

curl -i -X PUT  -H 'Content-Type: application/json' \

-H 'Accept: application/json' \

-u admin:admin 'http://localhost:21000/api/atlas/admin/purge/' \

-d '["GUID"]'

 

When you delete an entity in Atlas, it is soft deleted by default. Let’s confirm the same by creating an entity.

 

Step 1: Create an instance of DataSet.

{
  "entity": {
    "typeName": "DataSet",
    "attributes": {
      "owner": "Ram Gurram",
      "qualifiedName": "/sales/22/sensitive_data_202212312",
      "description": "sensitive file",
      "name": "sensitive_data_202212312.txt"
    }
  }
}

Execute below command to create above instance.

 

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 @sampleDataSet.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 @sampleDataSet.json
{"mutatedEntities":{"CREATE":[{"typeName":"DataSet","attributes":{"owner":"Ram Gurram","qualifiedName":"/sales/22/sensitive_data_202212312","name":"sensitive_data_202212312.txt","description":"sensitive file"},"guid":"b8e9794c-898c-40ba-b02e-a88e87085fc5","status":"ACTIVE","displayText":"sensitive_data_202212312.txt","classificationNames":[],"classifications":[],"meaningNames":[],"meanings":[],"isIncomplete":false,"labels":[]}]},"guidAssignments":{"-43426249823821":"b8e9794c-898c-40ba-b02e-a88e87085fc5"}}

From the output, I can confirm that an unique guid "b8e9794c-898c-40ba-b02e-a88e87085fc5" is assigned to this entity.


Confirm the same from UI

 


 

Step 2: Delete the entity by executing below command.


 

curl -X DELETE -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/b8e9794c-898c-40ba-b02e-a88e87085fc5

 

$curl -X DELETE -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/b8e9794c-898c-40ba-b02e-a88e87085fc5
{"mutatedEntities":{"DELETE":[{"typeName":"DataSet","attributes":{"owner":"Ram Gurram","qualifiedName":"/sales/22/sensitive_data_202212312","name":"sensitive_data_202212312.txt","description":"sensitive file"},"guid":"b8e9794c-898c-40ba-b02e-a88e87085fc5","status":"ACTIVE","displayText":"sensitive_data_202212312.txt","classificationNames":[],"meaningNames":[],"meanings":[],"isIncomplete":false,"labels":[]}]}}

 

Let’s confirm by reloading the UI. You form url like below.

http://localhost:21000/index.html#!/detailPage/{GUID_OF_ENTITY}

 

Example

http://localhost:21000/index.html#!/detailPage/b8e9794c-898c-40ba-b02e-a88e87085fc5

 

 


As you see above screenshot, entity is marked as deleted, but not hard deleted.

 

Step 3: Hard delete the entity by executing below command.

curl -i -X PUT  -H 'Content-Type: application/json' \

-H 'Accept: application/json' \

-u admin:admin 'http://localhost:21000/api/atlas/admin/purge/' \

-d '["b8e9794c-898c-40ba-b02e-a88e87085fc5"]'

 

$curl -i -X PUT  -H 'Content-Type: application/json' \
> -H 'Accept: application/json' \
> -u admin:admin 'http://localhost:21000/api/atlas/admin/purge/' \
> -d '["b8e9794c-898c-40ba-b02e-a88e87085fc5"]'
HTTP/1.1 200 OK
Date: Sat, 29 Jan 2022 13:31:44 GMT
Set-Cookie: ATLASSESSIONID=node0jgftmpdlom0mt8tdnhlgvdln20.node0; Path=/; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Type: application/json;charset=utf-8
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: data:; connect-src 'self'; img-src 'self' blob: data:; style-src 'self' 'unsafe-inline';font-src 'self' data:
Server: Apache Atlas
Transfer-Encoding: chunked

{"mutatedEntities":{"PURGE":[{"typeName":"DataSet","attributes":{"owner":"Ram Gurram","qualifiedName":"/sales/22/sensitive_data_202212312","name":"sensitive_data_202212312.txt","description":"sensitive file"},"guid":"b8e9794c-898c-40ba-b02e-a88e87085fc5","status":"DELETED","displayText":"sensitive_data_202212312.txt","classificationNames":[],"classifications":[],"meaningNames":[],"meanings":[],"isIncomplete":false,"labels":[]}]}}

 

Now reload the ui ‘http://localhost:21000/index.html#!/detailPage/b8e9794c-898c-40ba-b02e-a88e87085fc5

 

You will see error messages like entity not found.

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment