AtlasClientV2#getAllTypeDefHeaders method can be used to retrieve all the classification types.
Example
SearchFilter searchFilter = new SearchFilter();
searchFilter.setParam("type", "classification");
List<AtlasTypeDefHeader> atlasTypesDefHeaders = atlasClient.getAllTypeDefHeaders(searchFilter);
Find the below working application.
Create atlas-application.properties file under src/main/resources folder.
atlas-application.properties
atlas.client.readTimeoutMSecs=30000 atlas.client.connectTimeoutMSecs=30000
JsonUtil.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.AtlasTypeDefHeader;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.sample.app.util.JsonUtil;
public class GetClassifications {
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();
searchFilter.setParam("type", "classification");
List<AtlasTypeDefHeader> atlasTypesDefHeaders = atlasClient.getAllTypeDefHeaders(searchFilter);
System.out.println(JsonUtil.prettyPrintJson(atlasTypesDefHeaders));
}
}
GetClassifications.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.AtlasTypeDefHeader;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.sample.app.util.JsonUtil;
public class GetClassifications {
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();
searchFilter.setParam("type", "classification");
List<AtlasTypeDefHeader> atlasTypesDefHeaders = atlasClient.getAllTypeDefHeaders(searchFilter);
System.out.println(JsonUtil.prettyPrintJson(atlasTypesDefHeaders));
}
}
Output
[ { "guid" : "d71e4578-3e55-4a86-ae04-c9c971ee0420", "name" : "sensitive_data", "category" : "CLASSIFICATION" }, { "guid" : "23558f0d-1818-4e16-b583-9160927e07db", "name" : "classified", "category" : "CLASSIFICATION" } ]
No comments:
Post a Comment