Tuesday, 28 June 2022

Atlas client: check whether type with given name exists or not

AtlasClientV2#typeWithNameExists() method return true if the type with given name exists, else false.

 

Example

boolean typeWithName1Exists = atlasClient.typeWithNameExists(typeName1);

 

Find the below working application.

 

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

 

atlas-application.properties

 

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

 

TypeExistsCheckByName.java

package com.sample.app.types;

import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;

import com.fasterxml.jackson.core.JsonProcessingException;

public class TypeExistsCheckByName {

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

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

		String typeName1 = "gcp_storage_bucket";
		String typeName2 = "testType";

		boolean typeWithName1Exists = atlasClient.typeWithNameExists(typeName1);
		boolean typeWithName2Exists = atlasClient.typeWithNameExists(typeName2);

		System.out.println("typeWithName1Exists : " + typeWithName1Exists);
		System.out.println("typeWithName2Exists : " + typeWithName2Exists);

	}
}

Output

typeWithName1Exists : true
typeWithName2Exists : false



Previous                                                    Next                                                    Home

No comments:

Post a Comment