Monday 4 July 2022

Atlas client : Delete a type by name

This is continuation to my previous posts. In previous posts, I explained how to create new type ‘tablet’ and update the definition.

 

In this post, I am going to explain how to delete the type by name.

 

AtlasClientV2#deleteTypeByName method is used to delete the type by name. If there are entities created for this type, then this method throws an exception.

 

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

 

atlas-application.properties

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

DeleteTypeByName.java

package com.sample.app.types;

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

import com.fasterxml.jackson.core.JsonProcessingException;

public class DeleteTypeByName {
  public static void main(String[] args) throws AtlasServiceException, JsonProcessingException {
    AtlasClientV2 atlasClient = new AtlasClientV2(new String[] { "http://localhost:21000" },
        new String[] { "admin", "admin" });

    String typeToDelete = "tablet";

    boolean isTypeExists = atlasClient.typeWithNameExists(typeToDelete);
    System.out.println("Is type with name '" + typeToDelete + "' exists : " + isTypeExists);

    System.out.println("\nTrying to delete the type : " + typeToDelete);
    atlasClient.deleteTypeByName(typeToDelete);

    isTypeExists = atlasClient.typeWithNameExists(typeToDelete);
    System.out.println("\nIs type with name '" + typeToDelete + "' exists : " + isTypeExists);

  }
}

Output

Is type with name 'tablet' exists : true

Trying to delete the type : tablet

Is type with name 'tablet' exists : false

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment