Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Atlas REST API?

avatar
Super Collaborator

Hello Guys,

Programming Step:

1) I want to automate tagging mechanism of Apache Atlas by using java code.Right now I am fetching GUIDS for only hive_table.

2) Once I get the GUID then I will check whether this tag is already tagged or not?

3) if not then,then tag it with currently/newly created Trait/tag (Automatically).

Questions:

1) How to get GUID'S of all entities(includes hive tables,columns etc) in atlas(Using REST API)?

2) How to identify whether entity has been already tagged with some traits/tag or not?

3) How to get details/list of all tag/traits which are currently present in apache atlas(Using REST API)?

I hope above written information is complete.

Please help me.I have attached my java code.

Till now in java code I am just getting all GUID for hive table only.table.txt

Thanks in advance

1 ACCEPTED SOLUTION

avatar
Guru

@Manoj Dhake

Assuming you are on Sandbox 2.5 accessing Atlas 0.7, you will need to use the -u with the credentials for Atlas. On versions earlier that 0.7, you do not need to provide credentials.

1. To get all entities of a particular type:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types

Atlas should return all of the types

{"results":["Asset","Process","hive_column","storm_node","storm_bolt","falcon_process","hive_serde","falcon_feed_replication","hbase_table","kafka_topic","hive_table","hive_storagedesc","sqoop_dbdatastore","fs_permissions","hive_principal_type","jms_topic","hive_process","falcon_cluster","storm_spout","Referenceable","falcon_feed_creation","falcon_feed","hdfs_path","sqoop_process","Infrastructure","storm_topology","hive_order","DataSet","Taxonomy","fs_path","hive_db","file_action"],"count":32,"requestId":"qtp86996017-77 - d3edd2c6-229c-4344-8745-1a4337856a1f"}

Now, request all entities of hive_table type

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities?type=hive_table

Atlas will respond with an array of GUIDs of entities that are typed as hive_table

{"requestId":"qtp86996017-144 - 8974d5b6-18fe-41c4-bb86-54f07861560f","typeName":"hive_table","results":["63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2","563e7954-7d4c-45a6-9237-3e94e4d23f68","7751030c-d902-41fd-992d-f209a8e5278e","a9d45d64-0aea-4d18-abcd-919f6a3ae1e7","405079e5-dd29-41dc-98e8-49dc6f70f36d"],"count":5}

To view the entire instance of any of the above entities

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities/63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2

Atlas will respond with the entire entity definition. You can apply the previous steps to find and view any entity type and instance.

2. Issue the following request once you have identified the entity from which you want to determine applied tags

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities/63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2/traits

Atlas will respond with:

{"requestId":"qtp86996017-76 - 6a8faae6-627f-4f77-a6b2-21d74f1cacca","results":[],"count":0}

If the count is greater than 0 and the results field has a reference to a tag (trait) instance, then the entity has been tagged.

3. To get all defined tags (traits), make the following request:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types?type=TRAIT

Atlas will respond with:

{"results":["publish"],"count":1,"requestId":"qtp86996017-248 - 16e3295b-9ed3-4c3f-9910-826218e93d89"}

The payload should contain the names of each tag that has been created. In this example, you can view the details of the publish tag (trait) as follows:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types/publish

Atlas will respond with:

{"typeName":"publish","definition":{"enumTypes":[],"structTypes":[],"traitTypes":[{"superTypes":[],"hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.TraitType","typeName":"publish","typeDescription":"","attributeDefinitions":[]}],"classTypes":[]},"requestId":"qtp86996017-11 - 68f0d5af-05da-4254-b299-06e3d1dfa881"}

View solution in original post

3 REPLIES 3

avatar
Master Guru

@Manoj Dhake Have you review Atlas Api here?

avatar
Guru

@Manoj Dhake

Assuming you are on Sandbox 2.5 accessing Atlas 0.7, you will need to use the -u with the credentials for Atlas. On versions earlier that 0.7, you do not need to provide credentials.

1. To get all entities of a particular type:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types

Atlas should return all of the types

{"results":["Asset","Process","hive_column","storm_node","storm_bolt","falcon_process","hive_serde","falcon_feed_replication","hbase_table","kafka_topic","hive_table","hive_storagedesc","sqoop_dbdatastore","fs_permissions","hive_principal_type","jms_topic","hive_process","falcon_cluster","storm_spout","Referenceable","falcon_feed_creation","falcon_feed","hdfs_path","sqoop_process","Infrastructure","storm_topology","hive_order","DataSet","Taxonomy","fs_path","hive_db","file_action"],"count":32,"requestId":"qtp86996017-77 - d3edd2c6-229c-4344-8745-1a4337856a1f"}

Now, request all entities of hive_table type

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities?type=hive_table

Atlas will respond with an array of GUIDs of entities that are typed as hive_table

{"requestId":"qtp86996017-144 - 8974d5b6-18fe-41c4-bb86-54f07861560f","typeName":"hive_table","results":["63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2","563e7954-7d4c-45a6-9237-3e94e4d23f68","7751030c-d902-41fd-992d-f209a8e5278e","a9d45d64-0aea-4d18-abcd-919f6a3ae1e7","405079e5-dd29-41dc-98e8-49dc6f70f36d"],"count":5}

To view the entire instance of any of the above entities

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities/63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2

Atlas will respond with the entire entity definition. You can apply the previous steps to find and view any entity type and instance.

2. Issue the following request once you have identified the entity from which you want to determine applied tags

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/entities/63683ca8-e5a9-4c4c-b02e-3fe01bfda2a2/traits

Atlas will respond with:

{"requestId":"qtp86996017-76 - 6a8faae6-627f-4f77-a6b2-21d74f1cacca","results":[],"count":0}

If the count is greater than 0 and the results field has a reference to a tag (trait) instance, then the entity has been tagged.

3. To get all defined tags (traits), make the following request:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types?type=TRAIT

Atlas will respond with:

{"results":["publish"],"count":1,"requestId":"qtp86996017-248 - 16e3295b-9ed3-4c3f-9910-826218e93d89"}

The payload should contain the names of each tag that has been created. In this example, you can view the details of the publish tag (trait) as follows:

curl -u admin:admin -X GET http://sandbox.hortonworks.com:21000/api/atlas/types/publish

Atlas will respond with:

{"typeName":"publish","definition":{"enumTypes":[],"structTypes":[],"traitTypes":[{"superTypes":[],"hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.TraitType","typeName":"publish","typeDescription":"","attributeDefinitions":[]}],"classTypes":[]},"requestId":"qtp86996017-11 - 68f0d5af-05da-4254-b299-06e3d1dfa881"}

avatar
Super Collaborator

Thank you Vadim,

Do you know how to delete tag which are present on Atlas UI using REST API.