Thursday, 23 June 2022

Atlas client: Get all the type definitions

getAllTypeDefs() method is used to retrieve all the type definitions.

 

Example

AtlasTypesDef atlasTypesDef = atlasClient.getAllTypeDefs(searchFilter);
List<AtlasBusinessMetadataDef> businessMetadataDefs = atlasTypesDef.getBusinessMetadataDefs();

Once you got AtlasTypesDef instance, you can get respective type definitions by category wise using below snippet.

List<AtlasClassificationDef> classificationDefs = atlasTypesDef.getClassificationDefs();
List<AtlasEntityDef> entityDefs = atlasTypesDef.getEntityDefs();
List<AtlasEnumDef> enumDefs = atlasTypesDef.getEnumDefs();
List<AtlasRelationshipDef> relationshipDefs = atlasTypesDef.getRelationshipDefs();
List<AtlasStructDef> structDefs = atlasTypesDef.getStructDefs();

 


Find the below working application.

 

Step 1: Define atlas-application.properties file under src/main/resources folder.

 

atlas-application.properties

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

Step 2: Define GetAllTypes class.

 

GetAllTypes.java

package com.sample.app.types;

import java.util.List;

import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;

import com.fasterxml.jackson.core.JsonProcessingException;

public class GetAllTypes {

	private static <T extends AtlasBaseTypeDef> void printTypeDefs(List<T> typeDefs, String message) {

		System.out.println("__________________________________________________");
		System.out.println(message);
		System.out.println("Typename \t guid \t\t\t\t\t createdBy");
		for (AtlasBaseTypeDef atlasBaseTypeDef : typeDefs) {
			String typeName = atlasBaseTypeDef.getName();
			String guid = atlasBaseTypeDef.getGuid();
			String createdBy = atlasBaseTypeDef.getCreatedBy();

			System.out.println(typeName + "\t" + guid + "\t" + createdBy);

		}

		System.out.println("\n\n");

	}

	public static void main(String[] args) throws AtlasServiceException, JsonProcessingException {

		AtlasClientV2 atlasClient = new AtlasClientV2(new String[] { "http://localhost:21000" },
				new String[] { "admin", "admin" });

		SearchFilter searchFilter = new SearchFilter();
		AtlasTypesDef atlasTypesDef = atlasClient.getAllTypeDefs(searchFilter);

		List<AtlasBusinessMetadataDef> businessMetadataDefs = atlasTypesDef.getBusinessMetadataDefs();
		printTypeDefs(businessMetadataDefs, "businessMetadataDefs");

		List<AtlasClassificationDef> classificationDefs = atlasTypesDef.getClassificationDefs();
		printTypeDefs(classificationDefs, "classificationDefs");

		List<AtlasEntityDef> entityDefs = atlasTypesDef.getEntityDefs();
		printTypeDefs(entityDefs, "entityDefs");

		List<AtlasEnumDef> enumDefs = atlasTypesDef.getEnumDefs();
		printTypeDefs(enumDefs, "enumDefs");

		List<AtlasRelationshipDef> relationshipDefs = atlasTypesDef.getRelationshipDefs();
		printTypeDefs(relationshipDefs, "relationshipDefs");

		List<AtlasStructDef> structDefs = atlasTypesDef.getStructDefs();
		printTypeDefs(structDefs, "structDefs");

	}
}

Output

__________________________________________________
businessMetadataDefs
Typename 	 guid 					 createdBy



__________________________________________________
classificationDefs
Typename 	 guid 					 createdBy
classified	23558f0d-1818-4e16-b583-9160927e07db	admin



__________________________________________________
entityDefs
Typename 	 guid 					 createdBy
DataSet	5d312f85-95b2-40c8-aaa3-b42643d950f0	krishna
hive_table	c77bc3d0-3d67-4e4b-82d5-0456536005e8	krishna
ozone_volume	1403afca-ae65-49d0-9200-b87f080dfc7e	krishna
spark_column	d6522923-0aa1-4f3a-8a8b-72eabc9162db	krishna
gcp_storage_child	e62db8cf-dac7-406b-be55-10b79b1bccae	krishna
storm_node	eefc3812-18e1-4870-b73f-c8d45526bb87	krishna
Referenceable	a4bb02ae-6881-4e1f-8735-0d88478515bd	krishna
spark_table	a9896548-087b-4991-aa85-87f90c1395a4	krishna
rdbms_column	0b7e0c44-d87c-4522-be73-09b177e9113d	krishna
Asset	89d41a70-03d7-402b-8c0e-b6c3153156a7	krishna
avro_collection	5bdf31ef-b411-4a89-80f8-4e1a294c0829	krishna
adls_gen2_parent	f50bdcc0-f305-4ceb-ac6a-ec8564c02d75	krishna
hive_column	3aa860d2-8ce3-4770-b669-621e6ee1e439	krishna
aws_s3_v2_object	efb10236-5185-468e-9c04-1678144a7ede	krishna
spark_column_lineage	7b5ff335-b933-471f-a8e5-933421bd83a8	krishna
ml_model_deployment	c086b91f-6391-41ef-ba14-46f7031ab693	krishna
flink_application	3aaa04f8-6c3c-4428-bba0-e3fdc3deae9c	krishna
__AtlasUserSavedSearch	ca00aacc-cc80-4e90-b8cd-f1694089bc6d	krishna
adls_gen2_account	276816fc-e698-46bb-af2c-277d07df72f3	krishna
gcp_storage_object	4a1b7f04-aef8-43c5-9741-6af11a59dfa8	krishna
spark_ml_model	1d43b607-d0a3-478e-8600-8d57da4d878d	krishna
__internal	88ff4d1f-eea9-4cb0-86cb-a1363e618ded	krishna
ml_project	cee6ea59-ff32-4b51-9986-8e8f25631635	krishna
avro_type	bef07225-171c-4a52-b1c8-34a55ab3e0aa	krishna
aws_s3_object	7d678f3d-cc27-4aef-90e3-8d23a0fc2647	krishna
aws_s3_bucket	c8d0b84c-2958-4b47-9a7c-584d8f0b95f5	krishna
fs_path	f8e5d3a0-e7ab-4924-89a3-11a7292beba1	krishna
spark_storagedesc	f9119088-6a2c-4909-a530-80dba3dcbbb6	krishna
falcon_feed_replication	53d828aa-60d2-4b69-a622-f1fd3956a4b8	krishna
rdbms_foreign_key	d1275d60-ec28-44f2-8afa-fd29c0393731	krishna
aws_s3_v2_bucket	42dbd8aa-a1d0-477b-846b-23958bc27bc6	krishna
map_reduce_process	75233c8d-ed05-4c30-92df-d492eca675f3	admin
avro_fixed	05b200ed-c1cf-4db8-bdd9-46433ecae665	krishna
falcon_feed_creation	5d91e80f-1361-46fc-901e-fc7648370267	krishna
gcp_storage_bucket	347ce8d7-4b9e-4261-bfc1-73ef92a4d75b	krishna
impala_process_execution	76a58e30-39c0-4a8c-b32f-c313fb119e71	krishna
adls_gen2_child	baf1f325-4ff6-4921-8127-4b7cc69da94f	krishna
hive_db_ddl	720584f8-6163-4d5a-adcf-8fc1c6828ae6	krishna
ml_model_train_build_process	a7fcfd59-816e-45b1-b228-451a857328a1	krishna
__AtlasUserProfile	d9a275e4-b709-4a8d-8a1a-f9016745bb14	krishna
jdbc_column	625d5cca-9513-4038-a69c-4c5d1074bbb1	admin
aws_s3_pseudo_dir	ab163905-3a7f-454a-87eb-2b9114d581fc	krishna
hbase_namespace	08e0952b-1b41-4d1c-ba54-cdd7fa38d730	krishna
sqoop_dbdatastore	54886906-9d82-4583-8276-57a0c4ec9e73	krishna
ml_project_create_process	56a1e2cf-4f76-4bff-8897-eccacc46631d	krishna
hive_process	2e7334df-ac6d-457f-abf1-dadf540cbdc0	krishna
impala_process	8557d7d3-16fb-4d20-9999-35613ceec279	krishna
rdbms_instance	5d710042-5455-4ea0-8b9a-20eb13702a65	krishna
ozone_child	a68baae4-a84d-4a29-a0dc-11e4920e37dc	krishna
Infrastructure	51a0384f-cf51-45d8-a401-23b3da61ceca	krishna
storm_spout	7072ef6a-6435-4bb0-b401-e2ad43acd880	krishna
hive_table_ddl	be20b430-e815-4557-b50f-c1647280fa8f	krishna
Path	ef0ffa61-0da9-49a8-825f-232880e86a1b	krishna
kafka_topic	91fc1d08-644c-4d4d-8309-7cc2b0fc29e9	krishna
ozone_bucket	038482fa-7969-4250-a6f5-f11f43050dbd	krishna
ml_model_deploy_process	fd79a42e-a670-4aaf-b722-844eb28f9e7e	krishna
AtlasGlossaryTerm	11e7cd27-c247-4b7f-9b50-9f3c0fa8d3ed	krishna
hive_column_lineage	936e5bed-d92d-43dc-96fa-33b308618ed1	krishna
rdbms_index	6d6a06d0-82c0-4d18-a2b5-643395e8c62e	krishna
aws_s3_v2_directory	ce4bea91-705c-4ef2-b6af-e7b5da104a1f	krishna
ml_model_build	23be60b3-9213-4408-b0a5-af4252a25076	krishna
adls_gen2_container	67b69f4b-f070-4cf8-853b-af7605bfe248	krishna
__ExportImportAuditEntry	a04ae327-5b44-4101-af27-1e7c712f573d	krishna
aws_s3_v2_container	ff3d1cd7-7d1e-45d0-9dd4-1a42a78df4a2	krishna
jdbc_table	c0be5b47-359c-4066-a699-805aa8bf0cf9	admin
Process	35674ebd-aaba-427c-9fc7-04860c258503	krishna
avro_primitive	32eaab3e-363d-4ef6-8aca-f07a6c17813f	krishna
aws_s3_v2_contained	cfee0e2e-0383-4e67-becb-487551ebe9a9	krishna
impala_column_lineage	147240a8-e95a-46ea-9e12-f4c4b9f86a09	krishna
falcon_feed	c793102d-d1c9-4f17-a6e6-58da4d2d7944	krishna
jms_topic	2ca018eb-40bc-4633-b9c4-d862334d0316	krishna
hbase_column_family	6b28ea35-0d71-4ce7-9209-a7ca65b493b5	krishna
hive_process_execution	ba0a8968-79ab-4925-9a94-3c7d3ec19dad	krishna
avro_schema	9240a3c8-9999-46a9-b3a4-ceee74a4c1ef	krishna
merger_process	ad30d9bd-26a4-46d4-91e0-08271b03353b	admin
flink_process	afd500e2-5b37-4c84-93e6-bc97acf6c541	krishna
avro_record	2c844693-9479-4471-ad5d-34498b1dc64a	krishna
spark_ml_pipeline	00298f2e-f3a3-4728-9d32-ca8569f1a6be	krishna
spark_process	e4e6aa1c-8594-4232-bd7b-9930e4410e8f	krishna
aws_s3_v2_base	eed2f48f-ab1c-4778-8374-69c72d06ea3f	krishna
adls_gen2_directory	70234fca-7241-4e57-86b2-f219d8161ff8	krishna
gcp_storage_parent	ed55fb73-220c-48a8-8661-52c87b90eff3	krishna
spark_application	d8fc244a-863b-4d4e-ba93-bcb69efa4335	krishna
__AtlasAuditEntry	feb4a31f-2939-4d7c-baa1-6d883cb44539	krishna
storm_bolt	2d613098-8f4a-48e5-ba9c-226760cb9d87	krishna
falcon_cluster	b0afcd80-0e1e-411a-bea6-57611c610eb1	krishna
falcon_process	f44cc6b4-369e-4416-a96e-ccbfb077e0fc	krishna
gcp_storage_base	bb7dbc10-f575-4819-b013-5d377c7470dd	krishna
spark_ml_directory	1fac9b64-c1b0-41b6-b138-d7bdee2ee686	krishna
AtlasGlossaryCategory	ad9b546e-b4c9-4f2a-8cc2-40d35f811842	krishna
avro_field	6c6de2ed-811d-4878-bde6-0d7a3da1c987	krishna
hive_db	4b515b9e-9ed2-4ad3-a2f2-dad748ea6763	krishna
jdbc_db	bd9b88bc-b3b3-4e38-829c-80522eab7b3e	admin
hbase_column	e4ded7eb-43cb-4005-b2af-f4ba9d3ab90d	krishna
AtlasServer	580367ac-7e22-45f9-a535-dff8ef7491ad	krishna
gcp_storage_virtual_directory	676b31f3-6362-412a-a66f-6f70bb893288	krishna
hbase_table	f8f2778c-7115-4be6-a26b-f280e657d279	krishna
ProcessExecution	f5a27c0d-bff8-49e0-810d-cc3d32687bc9	krishna
rdbms_table	f294898e-de16-4011-b5c6-d1e8bdd2af47	krishna
storm_topology	253eaa53-3ecf-4354-9754-551baddd3c5b	krishna
rdbms_db	5fd317ba-77e9-479b-ba7c-c229c37af3b4	krishna
flink_application_processes	e0b5e2c9-e144-4ec1-a3b1-f27878e11ace	krishna
adls_gen2_blob	b77b91b4-ef98-44bd-a5e9-dde9b74c5fde	krishna
ddl	6e6cfec3-6a08-443a-b832-5ddef37c7c32	krishna
AtlasGlossary	9fd7d111-8c1a-4ddc-bb1e-eb6dd5753b97	krishna
hive_storagedesc	fb930d84-52f9-4a49-a148-b9f4e887a6dc	krishna
hdfs_path	d7b4c84c-64c9-4d3f-bac1-1776a93a5dbe	krishna
sqoop_process	ea8531d9-251d-4e32-b5bf-5df106705a28	krishna
ozone_parent	bf88a0b9-f5ec-40b6-b6bd-029ced73c9df	krishna
ozone_key	bfe083a1-fd40-4202-bd54-3427baeafeda	krishna
avro_enum	570063a1-4c2d-4a15-b289-405cffa72559	krishna
spark_db	38840472-5966-4816-ab51-4d890a5a32d7	krishna



__________________________________________________
enumDefs
Typename 	 guid 					 createdBy
AtlasGlossaryTermRelationshipStatus	342bb2b8-a81e-4f5a-97dc-794a468ed7b3	krishna
atlas_operation	a467a32c-cd24-4958-a372-339edd3a0478	krishna
adls_gen2_authentication_method	63d0c20f-25fa-4fe1-97dd-d0dda6cd80e1	krishna
file_action	3a523419-f516-4278-90df-e5b5539b58fd	krishna
ml_model_deployment_status	07baf244-076f-496f-b0db-01526b21d67d	krishna
AtlasGlossaryTermAssignmentStatus	71a0c5bc-2aa7-4c00-a97a-a7588d58fb05	krishna
hive_principal_type	985a083b-fa68-4585-8f58-f81dd3990e5d	krishna
ozone_storage_type	c993d8de-ac60-4bb6-b8fd-c7b1a43d8705	krishna
adls_gen2_replication	e58829a3-e183-402b-9b7d-69280c4abab7	krishna
ozone_replication_type	c46b5e5f-9a15-4996-98c6-c033be96832b	krishna
adls_gen2_performance	be1320b3-8713-4d88-a362-a298aa1f718b	krishna
adls_gen2_access_tier	8deab667-c06f-45aa-a87c-14f01b9fc6e2	krishna



__________________________________________________
relationshipDefs
Typename 	 guid 					 createdBy
storm_topology_nodes	39da7479-c386-428c-89fd-4d81fbb5cba4	krishna
avro_schema_associatedEntities	f1b10fc8-3e26-4f60-b77c-13d1db10b75a	krishna
falcon_feed_cluster	7e04e32f-9d5b-4b04-816e-89ff3c879a12	krishna
hive_db_ddl_queries	568d512a-c2ae-4f88-8ad1-c84ae220df93	krishna
hive_process_column_lineage	9ab1247f-fa9a-435c-a510-b480e89a904f	krishna
ml_build_deployment	e3663da5-a95e-4f0e-9af7-814e1bbe6414	krishna
avro_record_fields	047646dd-adc6-47f9-b497-de8bb4e6ac11	krishna
rdbms_table_foreign_key	4a1fd029-6d76-4938-95ee-f0a3841f8b30	krishna
AtlasGlossarySynonym	689e6f66-38af-400d-86bc-f5eddf1cfafc	krishna
hbase_column_family_columns	45dcedff-bbbd-411b-94c8-e6bd4ae962f7	krishna
AtlasGlossaryReplacementTerm	fffd0be0-36eb-4bf7-b228-9954ec809b47	krishna
ozone_volume_buckets	dd948971-5f1c-41d1-bc63-f28022a1fb26	krishna
rdbms_foreign_key_key_columns	ed95d1f1-e98a-4227-8ed7-fe566b5ed661	krishna
spark_table_columns	f985ca14-9be2-4cbd-9cd3-3eb45be8207d	krishna
spark_ml_model_ml_directory	bda1bb3c-b4c7-4aa7-ae7d-18f8c5687b93	krishna
jdbc_db_to_table	f6aaaada-018d-40fd-9501-91ebdbefc843	admin
adls_gen2_parent_children	98036787-cfd7-4f23-91d2-d831e8dc1dbe	krishna
__AtlasUserProfile_savedsearches	3b1dad21-c242-43a0-bac8-f1f3a5a7f108	krishna
falcon_cluster_feed_creation	073552d2-41a3-4aeb-a037-e6a947b621f8	krishna
rdbms_foreign_key_table_references	a6637a94-4f18-4207-be7d-8fd1e087d925	krishna
rdbms_foreign_key_column_references	ce22542d-a797-4df4-8c01-d4c8497db211	krishna
spark_ml_model_dataset	4ebe3209-ad3c-4ef8-93de-37e340668f1b	krishna
hbase_table_namespace	5ae9f2ef-3e36-4f0c-9002-747adbab8990	krishna
rdbms_db_tables	5e57c0aa-23e8-40c0-94ad-6d31d3552ddb	krishna
ozone_parent_children	7a463fdd-6b54-4de9-ab66-6ddc3614b4b3	krishna
avro_field_types	cf4f9082-807e-483e-a254-92356be2e38c	krishna
falcon_cluster_process	8bf4018e-08af-4b0c-a238-3865336e2104	krishna
hive_table_storagedesc	5edafdf4-9af0-480d-807d-b17c0aaf878e	krishna
hive_table_columns	b9e988cc-ac1e-4d7e-8904-9168c6ead786	krishna
hive_table_partitionkeys	3755b336-e230-4ce5-a6f0-8946d15410c0	krishna
rdbms_table_columns	d759935e-33d8-4032-83d1-edd53f1a218c	krishna
spark_application_processes	d61fbe23-e5be-48e1-8f34-1179b604f356	krishna
jdbc_table_to_column	89508d7c-5f22-4e7a-ad20-eeeb88bfdabe	admin
impala_process_column_lineage	c246eb7e-a54d-4c80-b84b-6970bfc2d35d	krishna
AtlasGlossaryTranslation	1213da93-3000-4cfb-8930-8e3ea9add73e	krishna
adls_gen2_account_containers	d21024ec-a528-4a53-a9a5-21094762d559	krishna
AtlasGlossaryCategoryHierarchyLink	7a7ce20b-fbd6-4ce8-b471-3c13923c187a	krishna
aws_s3_bucket_aws_s3_pseudo_dirs	d89f8102-5bd3-4681-8747-40ecc8faf461	krishna
hive_db_location	96aebd41-0a1f-4da8-ac82-95f944958b6e	krishna
AtlasGlossaryTermAnchor	5a916ec4-3dbe-401b-8a93-de20f7c21d2d	krishna
AtlasGlossaryCategoryAnchor	e3ed7f71-670d-405b-8fe0-3cc880f5f031	krishna
hbase_table_column_families	d8a97218-f04d-4c14-ae90-691191e4042a	krishna
AtlasGlossaryValidValue	f0ce10fd-3acc-4109-afb1-c06f77928c6f	krishna
ml_project_model_build	0a709481-a53e-4a7c-a763-d66e99ede370	krishna
AtlasGlossaryAntonym	d092874d-78bb-402b-8a47-c77ef281322d	krishna
AtlasGlossaryPreferredTerm	d56a1eee-94a6-4048-80df-207d562b47f9	krishna
aws_s3_object_avro_schema	7cee2fbf-55c1-40f5-bfac-b9044b2a48f5	krishna
kafka_topic_avroSchema	213e3347-80e8-4c3f-92ef-463720b794e6	krishna
rdbms_table_indexes	e693c12e-08c0-4676-ac87-d9deb26d3828	krishna
AtlasGlossarySemanticAssignment	f013a50b-c277-4617-9ee9-ac3835d8178a	krishna
aws_s3_pseudo_dir_avro_schema	2b32385e-395e-4a12-b323-5789c18792ac	krishna
AtlasGlossaryRelatedTerm	d6e0664f-0137-4605-9ec6-2fd2dcc8b3de	krishna
spark_ml_pipeline_ml_directory	46e2ccf1-3de3-4c81-8ce8-0dde1e0188d2	krishna
gcp_storage_parent_children	a84b2b3d-2e56-46f3-a815-1f6de6f3c139	krishna
process_dataset_outputs	68108585-ddf0-4236-80e5-62f5326c9172	krishna
spark_ml_pipeline_dataset	cfaa6d60-b53c-4a5b-abe1-4bfd35d4e528	krishna
dataset_process_inputs	0fa05b22-cc37-4a07-ba3e-22475ac5f094	krishna
aws_s3_v2_container_contained	7d70f4d0-1b12-463b-80a2-958e3739e096	krishna
aws_s3_pseudo_dir_aws_objects	06144bee-44af-4a6c-b99d-b25fab56f31e	krishna
hive_table_ddl_queries	bbadab1d-44c4-4b20-b385-b294f17e40af	krishna
rdbms_instance_databases	0e8dbefc-47a8-4028-89f8-2ec1e78b9b5b	krishna
spark_table_db	a712b0a9-318b-4e3b-b3d9-27be60f5d271	krishna
spark_table_storagedesc	0f64813f-d408-43a7-85e8-1869d9f39fa7	krishna
impala_process_process_executions	6ab6bb2e-1272-40b3-9072-9a9b46b32ee0	krishna
hive_process_process_executions	4c58f6f7-6fa5-4c62-a6f4-5d11a3af2517	krishna
AtlasGlossaryIsARelationship	439d4f62-78e1-4b9c-ad87-b628398bb896	krishna
rdbms_index_columns	ed7eed06-2c8c-4789-bb4f-11cc0979912c	krishna
spark_process_column_lineages	0093698b-abbf-454b-8ad3-b7fa932266a1	krishna
AtlasGlossaryTermCategorization	b80dcb8d-24fd-42b1-8bfa-043442225968	krishna
hive_table_db	a55ecc3b-8adc-47a3-99fb-ed4f0ff90175	krishna



__________________________________________________
structDefs
Typename 	 guid 					 createdBy
aws_cloud_watch_metric	622e4236-2ca5-454b-8f77-a73f418b9eac	krishna
aws_tag	e6949d0c-5328-4b72-a34c-fed61e401084	krishna
ozone_key_location	6a28d20d-95bc-4865-a707-c4c271dd8a74	krishna
aws_s3_access_policy	5dba2443-bea5-4767-a45c-e0cf696c163b	krishna
hive_order	47fd2057-d0e2-4118-ad9e-9a33a53e04da	krishna
hive_serde	20c2df4f-ef02-401a-96d3-005637bf576c	krishna
aws_s3_bucket_lifeCycleRule	d65aac31-b538-4816-bfe7-8b0d575dd7bf	krishna
fs_permissions	5ace3457-0b57-4593-9cfb-3e3d36923ce1	krishna

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment