Commit 46b1b36e by apoorvnaik Committed by Madhan Neethiraj

ATLAS-1616: consolidated all V2 clients

parent 84f6923e
......@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -80,7 +80,8 @@ public abstract class AtlasBaseClient {
private AtlasClientContext atlasClientContext;
private boolean retryEnabled = false;
protected AtlasBaseClient() {}
protected AtlasBaseClient() {
}
protected AtlasBaseClient(String[] baseUrl, String[] basicAuthUserNamePassword) {
if (basicAuthUserNamePassword != null) {
......@@ -158,7 +159,8 @@ public abstract class AtlasBaseClient {
DefaultClientConfig config = new DefaultClientConfig();
// Enable POJO mapping feature
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
int readTimeout = configuration.getInt("atlas.client.readTimeoutMSecs", 60000);;
int readTimeout = configuration.getInt("atlas.client.readTimeoutMSecs", 60000);
;
int connectTimeout = configuration.getInt("atlas.client.connectTimeoutMSecs", 60000);
if (configuration.getBoolean(TLS_ENABLED, false)) {
// create an SSL properties configuration if one doesn't exist. SSLFactory expects a file, so forced
......@@ -237,10 +239,10 @@ public abstract class AtlasBaseClient {
activeServerAddress = serverInstance;
break;
} else {
LOG.info("attempt #{}: Service {} - is not active. status={}", (i+1), serverInstance, adminStatus);
LOG.info("attempt #{}: Service {} - is not active. status={}", (i + 1), serverInstance, adminStatus);
}
} catch (Exception e) {
LOG.error("attempt #{}: Service {} - could not get status", (i+1), serverInstance, e);
LOG.error("attempt #{}: Service {} - could not get status", (i + 1), serverInstance, e);
}
sleepBetweenRetries();
}
......@@ -280,7 +282,7 @@ public abstract class AtlasBaseClient {
protected <T> T callAPIWithResource(APIInfo api, WebResource resource, Object requestObject, Class<T> responseType) throws AtlasServiceException {
GenericType<T> genericType = null;
if(responseType != null) {
if (responseType != null) {
genericType = new GenericType<>(responseType);
}
return callAPIWithResource(api, resource, requestObject, genericType);
......@@ -381,7 +383,7 @@ public abstract class AtlasBaseClient {
* @return Return metrics of the service instance the client is pointing to
* @throws AtlasServiceException
*/
public AtlasMetrics getAtlasMetrics () throws AtlasServiceException {
public AtlasMetrics getAtlasMetrics() throws AtlasServiceException {
return callAPI(METRICS, AtlasMetrics.class, null);
}
......@@ -423,18 +425,18 @@ public abstract class AtlasBaseClient {
throw new AtlasServiceException(api, new RuntimeException("Could not get response after retries."));
}
public <T> T callAPI(APIInfo api, Object requestObject, Class<T> responseType, String... params)
public <T> T callAPI(APIInfo api, Class<T> responseType, Object requestObject, String... params)
throws AtlasServiceException {
return callAPIWithResource(api, getResource(api, params), requestObject, responseType);
}
public <T> T callAPI(APIInfo api, Object requestObject, GenericType<T> responseType, String... params)
public <T> T callAPI(APIInfo api, GenericType<T> responseType, Object requestObject, String... params)
throws AtlasServiceException {
return callAPIWithResource(api, getResource(api, params), requestObject, responseType);
}
public <T> T callAPI(APIInfo api, Object requestBody, Class<T> responseType,
public <T> T callAPI(APIInfo api, Class<T> responseType, Object requestBody,
MultivaluedMap<String, String> queryParams, String... params) throws AtlasServiceException {
WebResource resource = getResource(api, queryParams, params);
return callAPIWithResource(api, resource, requestBody, responseType);
......@@ -483,7 +485,7 @@ public abstract class AtlasBaseClient {
return resource;
}
protected WebResource getResource(APIInfo api, MultivaluedMap<String, String> queryParams, String ... pathParams) {
protected WebResource getResource(APIInfo api, MultivaluedMap<String, String> queryParams, String... pathParams) {
WebResource resource = service.path(api.getPath());
resource = appendPathParams(resource, pathParams);
resource = appendQueryParams(queryParams, resource);
......@@ -523,7 +525,7 @@ public abstract class AtlasBaseClient {
return resource;
}
protected APIInfo formatPathForPathParams(APIInfo apiInfo, String ... params) {
protected APIInfo updatePathParameters(APIInfo apiInfo, String... params) {
return new APIInfo(String.format(apiInfo.getPath(), params), apiInfo.getMethod(), apiInfo.getExpectedStatus());
}
......
......@@ -997,12 +997,12 @@ public class AtlasClient extends AtlasBaseClient {
@VisibleForTesting
public JSONObject callAPIWithBody(API api, Object requestObject) throws AtlasServiceException {
return callAPI(toAPIInfo(api), requestObject, JSONObject.class, (String[]) null);
return callAPI(toAPIInfo(api), JSONObject.class, requestObject, (String[]) null);
}
@VisibleForTesting
public JSONObject callAPIWithBodyAndParams(API api, Object requestObject, String ... params) throws AtlasServiceException {
return callAPI(toAPIInfo(api), requestObject, JSONObject.class, params);
return callAPI(toAPIInfo(api), JSONObject.class, requestObject, params);
}
@VisibleForTesting
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
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.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.type.AtlasType;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Map;
import static org.apache.atlas.AtlasClient.LIMIT;
import static org.apache.atlas.AtlasClient.OFFSET;
import static org.apache.atlas.AtlasClient.QUERY;
public class AtlasClientV2 extends AtlasBaseClient {
// Type APIs
public static final String TYPES_API = BASE_URI + "v2/types/";
private static final String TYPEDEFS_API = TYPES_API + "typedefs/";
private static final String GET_BY_NAME_TEMPLATE = TYPES_API + "%s/name/%s";
private static final String GET_BY_GUID_TEMPLATE = TYPES_API + "%s/guid/%s";
private static final APIInfo GET_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_API, HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_API, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_API, HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_API, HttpMethod.DELETE, Response.Status.OK);
// Entity APIs
public static final String ENTITY_API = BASE_URI + "v2/entity/";
private static final String ENTITY_BULK_API = ENTITY_API + "bulk/";
private static final APIInfo GET_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.GET, Response.Status.OK);
private static final APIInfo GET_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/", HttpMethod.GET, Response.Status.OK);
public static final APIInfo CREATE_ENTITY = new APIInfo(ENTITY_API, HttpMethod.POST, Response.Status.OK);
public static final APIInfo UPDATE_ENTITY = CREATE_ENTITY;
public static final APIInfo UPDATE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/", HttpMethod.DELETE, Response.Status.OK);
public static final APIInfo DELETE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo GET_ENTITIES_BY_GUIDS = new APIInfo(ENTITY_BULK_API, HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ENTITIES = new APIInfo(ENTITY_BULK_API, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ENTITIES = CREATE_ENTITIES;
private static final APIInfo DELETE_ENTITIES_BY_GUIDS = new APIInfo(ENTITY_BULK_API, HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo GET_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.GET, Response.Status.OK);
private static final APIInfo ADD_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.POST, Response.Status.NO_CONTENT);
private static final APIInfo UPDATE_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_CLASSIFICATION = new APIInfo(ENTITY_API + "guid/%s/classification/%s", HttpMethod.DELETE, Response.Status.NO_CONTENT);
public static final String PREFIX_ATTR = "attr:";
// Lineage APIs
private static final String LINEAGE_URI = BASE_URI + "v2/lineage/";
private static final APIInfo LINEAGE_INFO = new APIInfo(LINEAGE_URI, HttpMethod.GET, Response.Status.OK);
// Discovery APIs
private static final String DISCOVERY_URI = BASE_URI + "v2/search";
private static final String DSL_URI = DISCOVERY_URI + "/dsl";
private static final String FULL_TEXT_URI = DISCOVERY_URI + "/fulltext";
private static final APIInfo DSL_SEARCH = new APIInfo(DSL_URI, HttpMethod.GET, Response.Status.OK);
private static final APIInfo FULL_TEXT_SEARCH = new APIInfo(FULL_TEXT_URI, HttpMethod.GET, Response.Status.OK);
public AtlasClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword);
}
public AtlasClientV2(String... baseUrls) throws AtlasException {
super(baseUrls);
}
public AtlasClientV2(UserGroupInformation ugi, String doAsUser, String... baseUrls) {
super(ugi, doAsUser, baseUrls);
}
protected AtlasClientV2() {
super();
}
@VisibleForTesting
AtlasClientV2(WebResource service, Configuration configuration) {
super(service, configuration);
}
/**
* Bulk retrieval API for retrieving all type definitions in Atlas
*
* @return A composite wrapper object with lists of all type definitions
*/
public AtlasTypesDef getAllTypeDefs(SearchFilter searchFilter) throws AtlasServiceException {
return callAPI(GET_ALL_TYPE_DEFS, AtlasTypesDef.class, searchFilter.getParams());
}
public AtlasEnumDef getEnumDefByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasEnumDef.class);
}
public AtlasEnumDef getEnumDefByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasEnumDef.class);
}
public AtlasStructDef getStructDefByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasStructDef.class);
}
public AtlasStructDef getStructDefByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasStructDef.class);
}
public AtlasClassificationDef getClassificationDefByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasClassificationDef.class);
}
public AtlasClassificationDef getClassificationDefByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasClassificationDef.class);
}
public AtlasEntityDef getEntityDefByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasEntityDef.class);
}
public AtlasEntityDef getEntityDefByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasEntityDef.class);
}
@Deprecated
public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEnumDefs().add(enumDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getEnumDefs() != null;
return created.getEnumDefs().get(0);
}
@Deprecated
public AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getStructDefs().add(structDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getStructDefs() != null;
return created.getStructDefs().get(0);
}
@Deprecated
public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(entityDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getEntityDefs() != null;
return created.getEntityDefs().get(0);
}
@Deprecated
public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef)
throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getClassificationDefs().add(classificationDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getClassificationDefs() != null;
return created.getClassificationDefs().get(0);
}
/**
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Any changes to the existing definitions will be discarded
*
* @param typesDef A composite wrapper object with corresponding lists of the type definition
* @return A composite wrapper object with lists of type definitions that were successfully
* created
*/
public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
return callAPI(CREATE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef));
}
/**
* Bulk update API for all types, changes detected in the type definitions would be persisted
*
* @param typesDef A composite object that captures all type definition changes
* @return A composite object with lists of type definitions that were updated
*/
public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
return callAPI(UPDATE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef));
}
/**
* Bulk delete API for all types
*
* @param typesDef A composite object that captures all types to be deleted
*/
public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
callAPI(DELETE_ALL_TYPE_DEFS, AtlasTypesDef.class, AtlasType.toJson(typesDef));
}
/* Lineage Calls */
public AtlasLineageInfo getLineageInfo(final String guid, final LineageDirection direction, final int depth) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("direction", direction.toString());
queryParams.add("depth", String.valueOf(depth));
return callAPI(LINEAGE_INFO, AtlasLineageInfo.class, queryParams, guid);
}
/* Entity Calls */
public AtlasEntityWithExtInfo getEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(GET_ENTITY_BY_GUID, AtlasEntityWithExtInfo.class, (MultivaluedMap<String, String>) null, guid);
}
public AtlasEntityWithExtInfo getEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(GET_ENTITY_BY_ATTRIBUTE, AtlasEntityWithExtInfo.class, queryParams, type);
}
public EntityMutationResponse updateEntityByAttribute(String type, Map<String, String> attributes, AtlasEntity entity) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(UPDATE_ENTITY_BY_ATTRIBUTE, EntityMutationResponse.class, entity, queryParams, type);
}
public EntityMutationResponse deleteEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(DELETE_ENTITY_BY_ATTRIBUTE, EntityMutationResponse.class, queryParams, type);
}
public EntityMutationResponse createEntity(AtlasEntityWithExtInfo entity) throws AtlasServiceException {
return callAPI(CREATE_ENTITY, EntityMutationResponse.class, entity);
}
public EntityMutationResponse updateEntity(AtlasEntityWithExtInfo entity) throws AtlasServiceException {
return callAPI(UPDATE_ENTITY, EntityMutationResponse.class, entity);
}
public EntityMutationResponse deleteEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(DELETE_ENTITY_BY_GUID, EntityMutationResponse.class, null, guid);
}
public AtlasEntitiesWithExtInfo getEntitiesByGuids(List<String> guids) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("guid", guids);
return callAPI(GET_ENTITIES_BY_GUIDS, AtlasEntitiesWithExtInfo.class, queryParams);
}
public EntityMutationResponse createEntities(AtlasEntitiesWithExtInfo atlasEntities) throws AtlasServiceException {
return callAPI(CREATE_ENTITIES, EntityMutationResponse.class, atlasEntities);
}
public EntityMutationResponse updateEntities(AtlasEntitiesWithExtInfo atlasEntities) throws AtlasServiceException {
return callAPI(UPDATE_ENTITIES, EntityMutationResponse.class, atlasEntities);
}
public EntityMutationResponse deleteEntitiesByGuids(List<String> guids) throws AtlasServiceException {
return callAPI(DELETE_ENTITIES_BY_GUIDS, EntityMutationResponse.class, "guid", guids);
}
public AtlasClassifications getClassifications(String guid) throws AtlasServiceException {
return callAPI(updatePathParameters(GET_CLASSIFICATIONS, guid), AtlasClassifications.class, null);
}
public void addClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(updatePathParameters(ADD_CLASSIFICATIONS, guid), (Class<?>)null, classifications, (String[]) null);
}
public void updateClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(updatePathParameters(UPDATE_CLASSIFICATIONS, guid), AtlasClassifications.class, classifications);
}
public void deleteClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(updatePathParameters(GET_CLASSIFICATIONS, guid), AtlasClassifications.class, classifications);
}
public void deleteClassification(String guid, String classificationName) throws AtlasServiceException {
callAPI(updatePathParameters(DELETE_CLASSIFICATION, guid, classificationName), null, null);
}
private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes) {
return attributesToQueryParams(attributes, null);
}
private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes,
MultivaluedMap<String, String> queryParams) {
if (queryParams == null) {
queryParams = new MultivaluedMapImpl();
}
if (MapUtils.isNotEmpty(attributes)) {
for (Map.Entry<String, String> e : attributes.entrySet()) {
queryParams.putSingle(PREFIX_ATTR + e.getKey(), e.getValue());
}
}
return queryParams;
}
/* Discovery calls */
public AtlasSearchResult dslSearch(final String query) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
return callAPI(DSL_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult dslSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
queryParams.add(LIMIT, String.valueOf(limit));
queryParams.add(OFFSET, String.valueOf(offset));
return callAPI(DSL_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult fullTextSearch(final String query) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
return callAPI(FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult fullTextSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
queryParams.add(LIMIT, String.valueOf(limit));
queryParams.add(OFFSET, String.valueOf(offset));
return callAPI(FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
private <T> T getTypeDefByName(final String name, Class<T> typeDefClass) throws AtlasServiceException {
String atlasPath = getAtlasPath(typeDefClass);
APIInfo apiInfo = new APIInfo(String.format(GET_BY_NAME_TEMPLATE, atlasPath, name), HttpMethod.GET, Response.Status.OK);
return callAPI(apiInfo, typeDefClass, null);
}
private <T> T getTypeDefByGuid(final String guid, Class<T> typeDefClass) throws AtlasServiceException {
String atlasPath = getAtlasPath(typeDefClass);
APIInfo apiInfo = new APIInfo(String.format(GET_BY_GUID_TEMPLATE, atlasPath, guid), HttpMethod.GET, Response.Status.OK);
return callAPI(apiInfo, typeDefClass, null);
}
private <T> String getAtlasPath(Class<T> typeDefClass) {
if (typeDefClass.isAssignableFrom(AtlasEnumDef.class)) {
return "enumdef";
} else if (typeDefClass.isAssignableFrom(AtlasEntityDef.class)) {
return "entitydef";
} else if (typeDefClass.isAssignableFrom(AtlasClassificationDef.class)) {
return "classificationdef";
} else if (typeDefClass.isAssignableFrom(AtlasStructDef.class)) {
return "structdef";
}
// Code should never reach this point
return "";
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import static org.apache.atlas.AtlasClient.LIMIT;
import static org.apache.atlas.AtlasClient.OFFSET;
import static org.apache.atlas.AtlasClient.QUERY;
public class AtlasDiscoveryClientV2 extends AtlasBaseClient {
private static final String DISCOVERY_URI = BASE_URI + "v2/search";
private static final String DSL_URI = DISCOVERY_URI + "/dsl";
private static final String FULL_TEXT_URI = DISCOVERY_URI + "/fulltext";
private static final APIInfo DSL_SEARCH = new APIInfo(DSL_URI, HttpMethod.GET, Response.Status.OK);
private static final APIInfo FULL_TEXT_SEARCH = new APIInfo(FULL_TEXT_URI, HttpMethod.GET, Response.Status.OK);
public AtlasDiscoveryClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword);
}
public AtlasDiscoveryClientV2(String... baseUrls) throws AtlasException {
super(baseUrls);
}
public AtlasDiscoveryClientV2(UserGroupInformation ugi, String doAsUser, String... baseUrls) {
super(ugi, doAsUser, baseUrls);
}
protected AtlasDiscoveryClientV2() {
super();
}
@VisibleForTesting
AtlasDiscoveryClientV2(WebResource service, Configuration configuration) {
super(service, configuration);
}
public AtlasSearchResult dslSearch(final String query) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
return callAPI(DSL_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult dslSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
queryParams.add(LIMIT, String.valueOf(limit));
queryParams.add(OFFSET, String.valueOf(offset));
return callAPI(DSL_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult fullTextSearch(final String query) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
return callAPI(FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
public AtlasSearchResult fullTextSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(QUERY, query);
queryParams.add(LIMIT, String.valueOf(limit));
queryParams.add(OFFSET, String.valueOf(offset));
return callAPI(FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
}
\ No newline at end of file
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import java.util.List;
import java.util.Map;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
public class AtlasEntitiesClientV2 extends AtlasBaseClient {
public static final String ENTITY_API = BASE_URI + "v2/entity/";
private static final APIInfo GET_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/%s", HttpMethod.GET, Response.Status.OK);
private static final APIInfo GET_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s", HttpMethod.GET, Response.Status.OK);
public static final APIInfo CREATE_ENTITY = new APIInfo(ENTITY_API, HttpMethod.POST, Response.Status.OK);
public static final APIInfo UPDATE_ENTITY = CREATE_ENTITY;
public static final APIInfo UPDATE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ENTITY_BY_GUID = new APIInfo(ENTITY_API + "guid/%s", HttpMethod.DELETE, Response.Status.OK);
public static final APIInfo DELETE_ENTITY_BY_ATTRIBUTE = new APIInfo(ENTITY_API + "uniqueAttribute/type/%s", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo GET_ENTITIES_BY_GUIDS = new APIInfo(ENTITY_API + "bulk/", HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ENTITIES = new APIInfo(ENTITY_API + "bulk/", HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ENTITIES = CREATE_ENTITIES;
private static final APIInfo DELETE_ENTITIES_BY_GUIDS = new APIInfo(ENTITY_API + "bulk/", HttpMethod.DELETE, Response.Status.OK);
private static final APIInfo GET_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.GET, Response.Status.OK);
private static final APIInfo ADD_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.POST, Response.Status.NO_CONTENT);
private static final APIInfo UPDATE_CLASSIFICATIONS = new APIInfo(ENTITY_API + "guid/%s/classifications", HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_CLASSIFICATION = new APIInfo(ENTITY_API + "guid/%s/classification/%s", HttpMethod.DELETE, Response.Status.NO_CONTENT);
public static final String PREFIX_ATTR = "attr:";
public AtlasEntitiesClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword);
}
public AtlasEntitiesClientV2(String... baseUrls) throws AtlasException {
super(baseUrls);
}
public AtlasEntitiesClientV2(UserGroupInformation ugi, String doAsUser, String... baseUrls) {
super(ugi, doAsUser, baseUrls);
}
protected AtlasEntitiesClientV2() {
super();
}
@VisibleForTesting
AtlasEntitiesClientV2(WebResource service, Configuration configuration) {
super(service, configuration);
}
public AtlasEntityWithExtInfo getEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(formatPathForPathParams(GET_ENTITY_BY_GUID, guid), AtlasEntityWithExtInfo.class, null);
}
public AtlasEntityWithExtInfo getEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(formatPathForPathParams(GET_ENTITY_BY_ATTRIBUTE, type), AtlasEntityWithExtInfo.class, queryParams);
}
public EntityMutationResponse updateEntityByAttribute(String type, Map<String, String> attributes, AtlasEntity entity) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(formatPathForPathParams(UPDATE_ENTITY_BY_ATTRIBUTE, type), entity, EntityMutationResponse.class, queryParams);
}
public EntityMutationResponse deleteEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = attributesToQueryParams(attributes);
return callAPI(formatPathForPathParams(DELETE_ENTITY_BY_ATTRIBUTE, type), null, EntityMutationResponse.class, queryParams);
}
public EntityMutationResponse createEntity(AtlasEntityWithExtInfo entity) throws AtlasServiceException {
return callAPI(CREATE_ENTITY, entity, EntityMutationResponse.class);
}
public EntityMutationResponse updateEntity(AtlasEntityWithExtInfo entity) throws AtlasServiceException {
return callAPI(UPDATE_ENTITY, entity, EntityMutationResponse.class);
}
public EntityMutationResponse deleteEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(formatPathForPathParams(DELETE_ENTITY_BY_GUID, guid), EntityMutationResponse.class, null);
}
public AtlasEntitiesWithExtInfo getEntitiesByGuids(List<String> guids) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.put("guid", guids);
return callAPI(GET_ENTITIES_BY_GUIDS, AtlasEntitiesWithExtInfo.class, queryParams);
}
public EntityMutationResponse createEntities(AtlasEntitiesWithExtInfo atlasEntities) throws AtlasServiceException {
return callAPI(CREATE_ENTITIES, atlasEntities, EntityMutationResponse.class);
}
public EntityMutationResponse updateEntities(AtlasEntitiesWithExtInfo atlasEntities) throws AtlasServiceException {
return callAPI(UPDATE_ENTITIES, atlasEntities, EntityMutationResponse.class);
}
public EntityMutationResponse deleteEntitiesByGuids(List<String> guids) throws AtlasServiceException {
return callAPI(DELETE_ENTITIES_BY_GUIDS, EntityMutationResponse.class, "guid", guids);
}
public AtlasClassifications getClassifications(String guid) throws AtlasServiceException {
return callAPI(formatPathForPathParams(GET_CLASSIFICATIONS, guid), null, AtlasClassifications.class);
}
public void addClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPathForPathParams(ADD_CLASSIFICATIONS, guid), classifications, (Class<?>)null, (String[]) null);
}
public void updateClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPathForPathParams(UPDATE_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
}
public void deleteClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException {
callAPI(formatPathForPathParams(GET_CLASSIFICATIONS, guid), classifications, AtlasClassifications.class);
}
public void deleteClassification(String guid, String classificationName) throws AtlasServiceException {
callAPI(formatPathForPathParams(DELETE_CLASSIFICATION, guid, classificationName), null, null);
}
// Entities operations
public List<AtlasEntity> getEntities(List<String> entityIds) {
// TODO Map the query params correctly
return null;
}
private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes) {
return attributesToQueryParams(attributes, null);
}
private MultivaluedMap<String, String> attributesToQueryParams(Map<String, String> attributes,
MultivaluedMap<String, String> queryParams) {
if (queryParams == null) {
queryParams = new MultivaluedMapImpl();
}
if (MapUtils.isNotEmpty(attributes)) {
for (Map.Entry<String, String> e : attributes.entrySet()) {
queryParams.putSingle(PREFIX_ATTR + e.getKey(), e.getValue());
}
}
return queryParams;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
public class AtlasLineageClientV2 extends AtlasBaseClient {
private static final String LINEAGE_URI = BASE_URI + "v2/lineage/%s/";
private static final APIInfo LINEAGE_INFO = new APIInfo(LINEAGE_URI, HttpMethod.GET, Response.Status.OK);
public AtlasLineageClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword);
}
public AtlasLineageClientV2(String... baseUrls) throws AtlasException {
super(baseUrls);
}
public AtlasLineageClientV2(UserGroupInformation ugi, String doAsUser, String... baseUrls) {
super(ugi, doAsUser, baseUrls);
}
protected AtlasLineageClientV2() {
super();
}
@VisibleForTesting
AtlasLineageClientV2(WebResource service, Configuration configuration) {
super(service, configuration);
}
public AtlasLineageInfo getLineageInfo(final String guid, final LineageDirection direction, final int depth) throws AtlasServiceException {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("direction", direction.toString());
queryParams.add("depth", String.valueOf(depth));
return callAPI(formatPathForPathParams(LINEAGE_INFO, guid), AtlasLineageInfo.class, queryParams);
}
}
\ No newline at end of file
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.WebResource;
import org.apache.atlas.model.SearchFilter;
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.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.type.AtlasType;
import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.Response;
public class AtlasTypedefClientV2 extends AtlasBaseClient {
private static final String BASE_URI = "api/atlas/v2/types/";
private static final String ENUMDEF_URI = BASE_URI + "enumdef/";
private static final String STRUCTDEF_URI = BASE_URI + "structdef/";
private static final String ENTITYDEF_URI = BASE_URI + "entitydef/";
private static final String CLASSIFICATIONDEF_URI = BASE_URI + "classificationdef/";
private static final String TYPEDEFS_PATH = BASE_URI + "typedefs/";
private static final String GET_BY_NAME_TEMPLATE = BASE_URI + "%s/name/%s";
private static final String GET_BY_GUID_TEMPLATE = BASE_URI + "%s/guid/%s";
private static final APIInfo CREATE_ENUM_DEF = new APIInfo(ENUMDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_STRUCT_DEF = new APIInfo(STRUCTDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_ENTITY_DEF = new APIInfo(ENTITYDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo CREATE_CLASSIFICATION_DEF = new APIInfo(CLASSIFICATIONDEF_URI, HttpMethod.POST, Response.Status.OK);
private static final APIInfo GET_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.GET, Response.Status.OK);
private static final APIInfo CREATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.POST, Response.Status.OK);
private static final APIInfo UPDATE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.PUT, Response.Status.OK);
private static final APIInfo DELETE_ALL_TYPE_DEFS = new APIInfo(TYPEDEFS_PATH, HttpMethod.DELETE, Response.Status.OK);
public AtlasTypedefClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword);
}
public AtlasTypedefClientV2(String... baseUrls) throws AtlasException {
super(baseUrls);
}
public AtlasTypedefClientV2(UserGroupInformation ugi, String doAsUser, String... baseUrls) {
super(ugi, doAsUser, baseUrls);
}
protected AtlasTypedefClientV2() {
super();
}
@VisibleForTesting
AtlasTypedefClientV2(WebResource service, Configuration configuration) {
super(service, configuration);
}
/**
* Bulk retrieval API for retrieving all type definitions in Atlas
*
* @return A composite wrapper object with lists of all type definitions
*/
public AtlasTypesDef getAllTypeDefs(SearchFilter searchFilter) throws AtlasServiceException {
return callAPI(GET_ALL_TYPE_DEFS, AtlasTypesDef.class, searchFilter.getParams());
}
public AtlasEnumDef getEnumByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasEnumDef.class);
}
public AtlasEnumDef getEnumByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasEnumDef.class);
}
public AtlasStructDef getStructByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasStructDef.class);
}
public AtlasStructDef getStructByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasStructDef.class);
}
public AtlasClassificationDef getClassificationByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasClassificationDef.class);
}
public AtlasClassificationDef getClassificationByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasClassificationDef.class);
}
public AtlasEntityDef getEntityByName(final String name) throws AtlasServiceException {
return getTypeDefByName(name, AtlasEntityDef.class);
}
public AtlasEntityDef getEntityByGuid(final String guid) throws AtlasServiceException {
return getTypeDefByGuid(guid, AtlasEntityDef.class);
}
@Deprecated
public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEnumDefs().add(enumDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getEnumDefs() != null;
return created.getEnumDefs().get(0);
}
@Deprecated
public AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getStructDefs().add(structDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getStructDefs() != null;
return created.getStructDefs().get(0);
}
@Deprecated
public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(entityDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getEntityDefs() != null;
return created.getEntityDefs().get(0);
}
@Deprecated
public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef)
throws AtlasServiceException {
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getClassificationDefs().add(classificationDef);
AtlasTypesDef created = createAtlasTypeDefs(atlasTypesDef);
assert created != null;
assert created.getClassificationDefs() != null;
return created.getClassificationDefs().get(0);
}
/**
* Bulk create APIs for all atlas type definitions, only new definitions will be created.
* Any changes to the existing definitions will be discarded
*
* @param typesDef A composite wrapper object with corresponding lists of the type definition
* @return A composite wrapper object with lists of type definitions that were successfully
* created
*/
public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
return callAPI(CREATE_ALL_TYPE_DEFS, AtlasType.toJson(typesDef), AtlasTypesDef.class);
}
/**
* Bulk update API for all types, changes detected in the type definitions would be persisted
*
* @param typesDef A composite object that captures all type definition changes
* @return A composite object with lists of type definitions that were updated
*/
public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
return callAPI(UPDATE_ALL_TYPE_DEFS, AtlasType.toJson(typesDef), AtlasTypesDef.class);
}
/**
* Bulk delete API for all types
*
* @param typesDef A composite object that captures all types to be deleted
*/
public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasServiceException {
callAPI(DELETE_ALL_TYPE_DEFS, AtlasType.toJson(typesDef), AtlasTypesDef.class);
}
private <T> T getTypeDefByName(final String name, Class<T> typeDefClass) throws AtlasServiceException {
String atlasPath = getAtlasPath(typeDefClass);
APIInfo apiInfo = new APIInfo(String.format(GET_BY_NAME_TEMPLATE, atlasPath, name), HttpMethod.GET, Response.Status.OK);
return callAPI(apiInfo, null, typeDefClass);
}
private <T> T getTypeDefByGuid(final String guid, Class<T> typeDefClass) throws AtlasServiceException {
String atlasPath = getAtlasPath(typeDefClass);
APIInfo apiInfo = new APIInfo(String.format(GET_BY_GUID_TEMPLATE, atlasPath, guid), HttpMethod.GET, Response.Status.OK);
return callAPI(apiInfo, null, typeDefClass);
}
private <T> String getAtlasPath(Class<T> typeDefClass) {
if (typeDefClass.isAssignableFrom(AtlasEnumDef.class)) {
return "enumdef";
} else if (typeDefClass.isAssignableFrom(AtlasEntityDef.class)) {
return "entitydef";
} else if (typeDefClass.isAssignableFrom(AtlasClassificationDef.class)) {
return "classificationdef";
} else if (typeDefClass.isAssignableFrom(AtlasStructDef.class)) {
return "structdef";
}
// Code should never reach this pion
return "";
}
}
......@@ -24,18 +24,18 @@ import com.google.common.collect.ImmutableSet;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasDiscoveryClientV2;
import org.apache.atlas.AtlasEntitiesClientV2;
import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasException;
import org.apache.atlas.AtlasLineageClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.AtlasTypedefClientV2;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult;
import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
import org.apache.atlas.model.instance.*;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
......@@ -53,11 +53,15 @@ import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.ArrayUtils;
import javax.ws.rs.core.MultivaluedMap;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE;
/**
* A driver that sets up sample types and entities using v2 types and entity model for testing purposes.
......@@ -169,23 +173,14 @@ public class QuickStartV2 {
return urls;
}
private final AtlasTypedefClientV2 typesClient;
private final AtlasEntitiesClientV2 entitiesClient;
private final AtlasDiscoveryClientV2 discoveryClient;
private final AtlasLineageClientV2 lineageClient;
private final AtlasClientV2 atlasClientV2;
QuickStartV2(String[] urls, String[] basicAuthUsernamePassword) {
typesClient = new AtlasTypedefClientV2(urls,basicAuthUsernamePassword);
entitiesClient = new AtlasEntitiesClientV2(urls,basicAuthUsernamePassword);
discoveryClient = new AtlasDiscoveryClientV2(urls,basicAuthUsernamePassword);
lineageClient = new AtlasLineageClientV2(urls,basicAuthUsernamePassword);
atlasClientV2 = new AtlasClientV2(urls,basicAuthUsernamePassword);
}
QuickStartV2(String[] urls) throws AtlasException {
typesClient = new AtlasTypedefClientV2(urls);
entitiesClient = new AtlasEntitiesClientV2(urls);
discoveryClient = new AtlasDiscoveryClientV2(urls);
lineageClient = new AtlasLineageClientV2(urls);
atlasClientV2 = new AtlasClientV2(urls);
}
......@@ -193,7 +188,7 @@ public class QuickStartV2 {
AtlasTypesDef atlasTypesDef = createTypeDefinitions();
System.out.println("\nCreating sample types: ");
typesClient.createAtlasTypeDefs(atlasTypesDef);
atlasClientV2.createAtlasTypeDefs(atlasTypesDef);
verifyTypesCreated();
}
......@@ -341,11 +336,11 @@ public class QuickStartV2 {
private AtlasEntity createInstance(AtlasEntity entity, String[] traitNames) throws Exception {
AtlasEntity ret = null;
EntityMutationResponse response = entitiesClient.createEntity(new AtlasEntityWithExtInfo(entity));
EntityMutationResponse response = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(entity));
List<AtlasEntityHeader> entities = response.getEntitiesByOperation(EntityOperation.CREATE);
if (CollectionUtils.isNotEmpty(entities)) {
AtlasEntityWithExtInfo getByGuidResponse = entitiesClient.getEntityByGuid(entities.get(0).getGuid());
AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid());
ret = getByGuidResponse.getEntity();
System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid());
}
......@@ -463,7 +458,7 @@ public class QuickStartV2 {
searchParams.clear();
searchParams.add(SearchFilter.PARAM_NAME, typeName);
SearchFilter searchFilter = new SearchFilter(searchParams);
AtlasTypesDef searchDefs = typesClient.getAllTypeDefs(searchFilter);
AtlasTypesDef searchDefs = atlasClientV2.getAllTypeDefs(searchFilter);
assert (!searchDefs.isEmpty());
System.out.println("Created type [" + typeName + "]");
......@@ -516,7 +511,7 @@ public class QuickStartV2 {
System.out.println("\nSample DSL Queries: ");
for (String dslQuery : getDSLQueries()) {
AtlasSearchResult results = discoveryClient.dslSearchWithParams(dslQuery, 10, 0);
AtlasSearchResult results = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
if (results != null) {
List<AtlasEntityHeader> entitiesResult = results.getEntities();
......@@ -539,7 +534,7 @@ public class QuickStartV2 {
private void lineage() throws AtlasServiceException {
System.out.println("\nSample Lineage Info: ");
AtlasLineageInfo lineageInfo = lineageClient.getLineageInfo(getTableId(SALES_FACT_DAILY_MV_TABLE), LineageDirection.BOTH, 0);
AtlasLineageInfo lineageInfo = atlasClientV2.getLineageInfo(getTableId(SALES_FACT_DAILY_MV_TABLE), LineageDirection.BOTH, 0);
Set<LineageRelation> relations = lineageInfo.getRelations();
Map<String, AtlasEntityHeader> guidEntityMap = lineageInfo.getGuidEntityMap();
......@@ -556,7 +551,7 @@ public class QuickStartV2 {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
AtlasEntity tableEntity = entitiesClient.getEntityByAttribute(TABLE_TYPE, attributes).getEntity();
AtlasEntity tableEntity = atlasClientV2.getEntityByAttribute(TABLE_TYPE, attributes).getEntity();
return tableEntity.getGuid();
}
}
......@@ -56,10 +56,10 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.atlas.AtlasEntitiesClientV2.CREATE_ENTITY;
import static org.apache.atlas.AtlasEntitiesClientV2.DELETE_ENTITY_BY_ATTRIBUTE;
import static org.apache.atlas.AtlasEntitiesClientV2.UPDATE_ENTITY;
import static org.apache.atlas.AtlasEntitiesClientV2.UPDATE_ENTITY_BY_ATTRIBUTE;
import static org.apache.atlas.AtlasClientV2.CREATE_ENTITY;
import static org.apache.atlas.AtlasClientV2.DELETE_ENTITY_BY_ATTRIBUTE;
import static org.apache.atlas.AtlasClientV2.UPDATE_ENTITY;
import static org.apache.atlas.AtlasClientV2.UPDATE_ENTITY_BY_ATTRIBUTE;
import static org.apache.atlas.notification.hook.HookNotification.EntityCreateRequest;
import static org.apache.atlas.notification.hook.HookNotification.EntityDeleteRequest;
import static org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequest;
......
......@@ -61,7 +61,7 @@ public class QuickStartV2IT extends BaseResourceIT {
private AtlasEntity getDB(String dbName) throws AtlasServiceException, JSONException {
Map<String, String> attributes = new HashMap<>();
attributes.put("name", dbName);
AtlasEntity dbEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.DATABASE_TYPE, attributes).getEntity();
AtlasEntity dbEntity = atlasClientV2.getEntityByAttribute(QuickStartV2.DATABASE_TYPE, attributes).getEntity();
return dbEntity;
}
......@@ -80,20 +80,20 @@ public class QuickStartV2IT extends BaseResourceIT {
private AtlasEntity getTable(String tableName) throws AtlasServiceException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
AtlasEntity tableEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.TABLE_TYPE, attributes).getEntity();
AtlasEntity tableEntity = atlasClientV2.getEntityByAttribute(QuickStartV2.TABLE_TYPE, attributes).getEntity();
return tableEntity;
}
private AtlasEntity getProcess(String processName) throws AtlasServiceException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, processName);
AtlasEntity processEntity = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
AtlasEntity processEntity = atlasClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
return processEntity;
}
private void verifyTrait(AtlasEntity table) throws AtlasServiceException {
AtlasClassification.AtlasClassifications classfications = entitiesClientV2.getClassifications(table.getGuid());
AtlasClassification.AtlasClassifications classfications = atlasClientV2.getClassifications(table.getGuid());
List<AtlasClassification> traits = classfications.getList();
assertNotNull(traits.get(0).getTypeName());
}
......@@ -126,7 +126,7 @@ public class QuickStartV2IT extends BaseResourceIT {
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.LOAD_SALES_DAILY_PROCESS);
AtlasEntity loadProcess = entitiesClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
AtlasEntity loadProcess = atlasClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();
Map loadProcessAttribs = loadProcess.getAttributes();
assertEquals(QuickStartV2.LOAD_SALES_DAILY_PROCESS, loadProcessAttribs.get(AtlasClient.NAME));
......@@ -162,7 +162,7 @@ public class QuickStartV2IT extends BaseResourceIT {
String salesDailyProcessId = getProcessId(QuickStartV2.LOAD_SALES_DAILY_PROCESS);
String salesMonthlyProcessId = getProcessId(QuickStartV2.LOAD_SALES_MONTHLY_PROCESS);
AtlasLineageInfo inputLineage = lineageClientV2.getLineageInfo(salesFactDailyMVId, LineageDirection.BOTH, 0);
AtlasLineageInfo inputLineage = atlasClientV2.getLineageInfo(salesFactDailyMVId, LineageDirection.BOTH, 0);
List<LineageRelation> relations = new ArrayList<>(inputLineage.getRelations());
Map<String, AtlasEntityHeader> entityMap = inputLineage.getGuidEntityMap();
......@@ -181,7 +181,7 @@ public class QuickStartV2IT extends BaseResourceIT {
public void testViewIsAdded() throws AtlasServiceException, JSONException {
Map<String, String> attributes = new HashMap<>();
attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.PRODUCT_DIM_VIEW);
AtlasEntity view = entitiesClientV2.getEntityByAttribute(QuickStartV2.VIEW_TYPE, attributes).getEntity();
AtlasEntity view = atlasClientV2.getEntityByAttribute(QuickStartV2.VIEW_TYPE, attributes).getEntity();
Map<String, Object> viewAttributes = view.getAttributes();
assertEquals(QuickStartV2.PRODUCT_DIM_VIEW, viewAttributes.get(AtlasClient.NAME));
......
......@@ -18,32 +18,21 @@
package org.apache.atlas.web.resources;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import kafka.consumer.ConsumerTimeoutException;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasDiscoveryClientV2;
import org.apache.atlas.AtlasEntitiesClientV2;
import org.apache.atlas.AtlasLineageClientV2;
import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.AtlasTypedefClientV2;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.instance.EntityMutations;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
......@@ -61,21 +50,10 @@ import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.InstanceSerialization;
import org.apache.atlas.typesystem.json.TypesSerialization;
import org.apache.atlas.typesystem.persistence.Id;
import org.apache.atlas.typesystem.types.AttributeDefinition;
import org.apache.atlas.typesystem.types.ClassType;
import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.typesystem.types.EnumTypeDefinition;
import org.apache.atlas.typesystem.types.EnumValue;
import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import org.apache.atlas.typesystem.types.IDataType;
import org.apache.atlas.typesystem.types.Multiplicity;
import org.apache.atlas.typesystem.types.StructTypeDefinition;
import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.TypeUtils;
import org.apache.atlas.typesystem.types.*;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray;
......@@ -84,11 +62,17 @@ import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kafka.consumer.ConsumerTimeoutException;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* Base class for integration tests.
......@@ -104,10 +88,7 @@ public abstract class BaseResourceIT {
// All service clients
protected AtlasClient atlasClientV1;
protected AtlasTypedefClientV2 typedefClientV2;
protected AtlasEntitiesClientV2 entitiesClientV2;
protected AtlasDiscoveryClientV2 discoveryClientV2;
protected AtlasLineageClientV2 lineageClientV2;
protected AtlasClientV2 atlasClientV2;
public static final Logger LOG = LoggerFactory.getLogger(BaseResourceIT.class);
protected static final int MAX_WAIT_TIME = 60000;
......@@ -131,30 +112,24 @@ public abstract class BaseResourceIT {
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClientV1 = new AtlasClient(atlasUrls, new String[]{"admin", "admin"});
typedefClientV2 = new AtlasTypedefClientV2(atlasUrls, new String[]{"admin", "admin"});
entitiesClientV2 = new AtlasEntitiesClientV2(atlasUrls, new String[]{"admin", "admin"});
discoveryClientV2 = new AtlasDiscoveryClientV2(atlasUrls, new String[]{"admin", "admin"});
lineageClientV2 = new AtlasLineageClientV2(atlasUrls, new String[]{"admin", "admin"});
atlasClientV2 = new AtlasClientV2(atlasUrls, new String[]{"admin", "admin"});
} else {
atlasClientV1 = new AtlasClient(atlasUrls);
typedefClientV2 = new AtlasTypedefClientV2(atlasUrls);
entitiesClientV2 = new AtlasEntitiesClientV2(atlasUrls);
discoveryClientV2 = new AtlasDiscoveryClientV2(atlasUrls);
lineageClientV2 = new AtlasLineageClientV2(atlasUrls);
atlasClientV2 = new AtlasClientV2(atlasUrls);
}
}
protected void batchCreateTypes(AtlasTypesDef typesDef) throws AtlasServiceException {
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
try {
typedefClientV2.createEnumDef(enumDef);
atlasClientV2.createEnumDef(enumDef);
} catch (AtlasServiceException ex) {
LOG.warn("EnumDef creation failed for {}", enumDef.getName());
}
}
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
try {
typedefClientV2.createStructDef(structDef);
atlasClientV2.createStructDef(structDef);
} catch (AtlasServiceException ex) {
LOG.warn("StructDef creation failed for {}", structDef.getName());
}
......@@ -166,7 +141,7 @@ public abstract class BaseResourceIT {
Collections.<AtlasClassificationDef>emptyList(),
typesDef.getEntityDefs());
try {
typedefClientV2.createAtlasTypeDefs(entityDefs);
atlasClientV2.createAtlasTypeDefs(entityDefs);
}
catch(AtlasServiceException e) {
LOG.warn("Type creation failed for {}", typesDef.toString());
......@@ -175,7 +150,7 @@ public abstract class BaseResourceIT {
for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) {
try {
typedefClientV2.createClassificationDef(classificationDef);
atlasClientV2.createClassificationDef(classificationDef);
} catch (AtlasServiceException ex) {
LOG.warn("ClassificationDef creation failed for {}", classificationDef.getName());
}
......@@ -187,28 +162,28 @@ public abstract class BaseResourceIT {
// Since the bulk create bails out on a single failure, this has to be done as a workaround
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
try {
typedefClientV2.createEnumDef(enumDef);
atlasClientV2.createEnumDef(enumDef);
} catch (AtlasServiceException ex) {
LOG.warn("EnumDef creation failed for {}", enumDef.getName());
}
}
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
try {
typedefClientV2.createStructDef(structDef);
atlasClientV2.createStructDef(structDef);
} catch (AtlasServiceException ex) {
LOG.warn("StructDef creation failed for {}", structDef.getName());
}
}
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
try {
typedefClientV2.createEntityDef(entityDef);
atlasClientV2.createEntityDef(entityDef);
} catch (AtlasServiceException ex) {
LOG.warn("EntityDef creation failed for {}", entityDef.getName());
}
}
for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) {
try {
typedefClientV2.createClassificationDef(classificationDef);
atlasClientV2.createClassificationDef(classificationDef);
} catch (AtlasServiceException ex) {
LOG.warn("ClassificationDef creation failed for {}", classificationDef.getName());
}
......@@ -288,13 +263,13 @@ public abstract class BaseResourceIT {
EntityMutationResponse entity = null;
try {
if (!update) {
entity = entitiesClientV2.createEntity(new AtlasEntityWithExtInfo(atlasEntity));
entity = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(atlasEntity));
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size() > 0);
return entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0);
} else {
entity = entitiesClientV2.updateEntity(new AtlasEntityWithExtInfo(atlasEntity));
entity = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(atlasEntity));
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).size() > 0);
......
......@@ -63,7 +63,7 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
public void testSearchByDSL() throws Exception {
String dslQuery = "from "+ DATABASE_TYPE_BUILTIN + " " + QUALIFIED_NAME + "=\"" + dbName + "\"";
AtlasSearchResult searchResult = discoveryClientV2.dslSearch(dslQuery);
AtlasSearchResult searchResult = atlasClientV2.dslSearch(dslQuery);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), dslQuery);
assertEquals(searchResult.getQueryType(), AtlasQueryType.DSL);
......@@ -84,48 +84,48 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test
public void testSearchDSLLimits() throws Exception {
String dslQuery = "from "+ DATABASE_TYPE_BUILTIN + " " + QUALIFIED_NAME + "=\"" + dbName + "\"";
AtlasSearchResult searchResult = discoveryClientV2.dslSearch(dslQuery);
AtlasSearchResult searchResult = atlasClientV2.dslSearch(dslQuery);
assertNotNull(searchResult);
//higher limit, all results returned
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, 10, 0);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
assertEquals(searchResult.getEntities().size(), 1);
//default limit and offset -1, all results returned
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, -1, -1);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, -1, -1);
assertEquals(searchResult.getEntities().size(), 1);
//uses the limit parameter passed
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, 1, 0);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 1, 0);
assertEquals(searchResult.getEntities().size(), 1);
//uses the offset parameter passed
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, 10, 1);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, 1);
assertNull(searchResult.getEntities());
//limit > 0
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, 0, 10);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 0, 10);
assertNull(searchResult.getEntities());
//limit > maxlimit
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, Integer.MAX_VALUE, 10);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, Integer.MAX_VALUE, 10);
assertNull(searchResult.getEntities());
//offset >= 0
searchResult = discoveryClientV2.dslSearchWithParams(dslQuery, 10, -2);
searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, -2);
assertEquals(searchResult.getEntities().size(), 1);
}
@Test(expectedExceptions = AtlasServiceException.class)
public void testSearchByDSLForUnknownType() throws Exception {
String dslQuery = "from blah";
discoveryClientV2.dslSearch(dslQuery);
atlasClientV2.dslSearch(dslQuery);
}
@Test
public void testSearchUsingDSL() throws Exception {
String query = "from "+ DATABASE_TYPE_BUILTIN + " " + QUALIFIED_NAME + "=\"" + dbName + "\"";
AtlasSearchResult searchResult = discoveryClientV2.dslSearch(query);
AtlasSearchResult searchResult = atlasClientV2.dslSearch(query);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), query);
......@@ -147,7 +147,7 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test
public void testSearchFullTextOnDSLFailure() throws Exception {
String query = "*";
AtlasSearchResult searchResult = discoveryClientV2.fullTextSearch(query);
AtlasSearchResult searchResult = atlasClientV2.fullTextSearch(query);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), query);
assertEquals(searchResult.getQueryType(), AtlasQueryType.FULL_TEXT);
......@@ -155,7 +155,7 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
@Test(dependsOnMethods = "testSearchDSLLimits")
public void testSearchUsingFullText() throws Exception {
AtlasSearchResult searchResult = discoveryClientV2.fullTextSearchWithParams(dbName, 10, 0);
AtlasSearchResult searchResult = atlasClientV2.fullTextSearchWithParams(dbName, 10, 0);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), dbName);
......@@ -173,25 +173,25 @@ public class EntityDiscoveryJerseyResourceIT extends BaseResourceIT {
String query = dbName;
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", query);
searchResult = discoveryClientV2.fullTextSearch(query);
searchResult = atlasClientV2.fullTextSearch(query);
assertNotNull(searchResult);
assertEquals(searchResult.getFullTextResult().size(), 1);
//verify passed in limits and offsets are used
//higher limit and 0 offset returns all results
searchResult = discoveryClientV2.fullTextSearchWithParams(query, 10, 0);
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
//offset is used
searchResult = discoveryClientV2.fullTextSearchWithParams(query, 10, 1);
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 1);
assertEquals(searchResult.getFullTextResult().size(), 1);
//limit is used
searchResult = discoveryClientV2.fullTextSearchWithParams(query, 1, 0);
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
//higher offset returns 0 results
searchResult = discoveryClientV2.fullTextSearchWithParams(query, 1, 2);
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 2);
assertEquals(searchResult.getFullTextResult().size(), 1);
}
......
......@@ -147,7 +147,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
//Create the tables. The database and columns should be created automatically, since
//the tables reference them.
EntityMutationResponse response = entitiesClientV2.createEntities(entities);
EntityMutationResponse response = atlasClientV2.createEntities(entities);
Assert.assertNotNull(response);
Map<String,String> guidsCreated = response.getGuidAssignments();
......@@ -194,7 +194,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity hiveTableInstanceV2 = createHiveTableInstanceV2(hiveDBInstanceV2, tableName);
hiveTableInstanceV2.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
EntityMutationResponse entity = entitiesClientV2.createEntity(new AtlasEntityWithExtInfo(hiveTableInstanceV2));
EntityMutationResponse entity = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(hiveTableInstanceV2));
assertNotNull(entity);
assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
results = searchByDSL(String.format("%s where name='%s'", DATABASE_TYPE_V2, DATABASE_NAME));
......@@ -223,7 +223,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(entityDef);
AtlasTypesDef created = typedefClientV2.createAtlasTypeDefs(typesDef);
AtlasTypesDef created = atlasClientV2.createAtlasTypeDefs(typesDef);
assertNotNull(created);
assertNotNull(created.getEntityDefs());
assertEquals(created.getEntityDefs().size(), 1);
......@@ -231,7 +231,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
//create entity for the type
AtlasEntity instance = new AtlasEntity(entityDef.getName());
instance.setAttribute("name", randomString());
EntityMutationResponse mutationResponse = entitiesClientV2.createEntity(new AtlasEntityWithExtInfo(instance));
EntityMutationResponse mutationResponse = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(instance));
assertNotNull(mutationResponse);
assertNotNull(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
assertEquals(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size(),1 );
......@@ -245,7 +245,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(entityDef);
AtlasTypesDef updated = typedefClientV2.updateAtlasTypeDefs(typesDef);
AtlasTypesDef updated = atlasClientV2.updateAtlasTypeDefs(typesDef);
assertNotNull(updated);
assertNotNull(updated.getEntityDefs());
assertEquals(updated.getEntityDefs().size(), 1);
......@@ -278,7 +278,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
String qualifiedName = (String) hiveDB.getAttribute(NAME);
//get entity by attribute
AtlasEntity byAttribute = entitiesClientV2.getEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, qualifiedName)).getEntity();
AtlasEntity byAttribute = atlasClientV2.getEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, qualifiedName)).getEntity();
assertEquals(byAttribute.getTypeName(), DATABASE_TYPE_V2);
assertEquals(byAttribute.getAttribute(NAME), qualifiedName);
}
......@@ -390,7 +390,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
@Test(dependsOnMethods = "testSubmitEntity")
public void testGetTraitNames() throws Exception {
AtlasClassifications classifications = entitiesClientV2.getClassifications(createHiveTable().getGuid());
AtlasClassifications classifications = atlasClientV2.getClassifications(createHiveTable().getGuid());
assertNotNull(classifications);
assertTrue(classifications.getList().size() > 0);
assertEquals(classifications.getList().size(), 8);
......@@ -411,7 +411,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity entityByGuid = getEntityByGuid(guid);
entityByGuid.setAttribute(property, value);
EntityMutationResponse response = entitiesClientV2.updateEntity(new AtlasEntityWithExtInfo(entityByGuid));
EntityMutationResponse response = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(entityByGuid));
assertNotNull(response);
assertNotNull(response.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
}
......@@ -452,7 +452,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
assertNotNull(createdHeader);
assertNotNull(createdHeader.getGuid());
hiveTableInstanceV2.setGuid(createdHeader.getGuid());
entitiesClientV2.addClassifications(createdHeader.getGuid(), hiveTableInstanceV2.getClassifications());
atlasClientV2.addClassifications(createdHeader.getGuid(), hiveTableInstanceV2.getClassifications());
tableEntity = hiveTableInstanceV2;
return hiveTableInstanceV2;
}
......@@ -466,7 +466,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
entitiesClientV2.addClassifications(createHiveTable().getGuid(), ImmutableList.of(new AtlasClassification(piiTrait.getName())));
atlasClientV2.addClassifications(createHiveTable().getGuid(), ImmutableList.of(new AtlasClassification(piiTrait.getName())));
assertEntityAudit(createHiveTable().getGuid(), EntityAuditEvent.EntityAuditAction.TAG_ADD);
}
......@@ -480,7 +480,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
AtlasClassificationDef classificationByName = typedefClientV2.getClassificationByName(traitName);
AtlasClassificationDef classificationByName = atlasClientV2.getClassificationDefByName(traitName);
assertNotNull(classificationByName);
AtlasEntity hiveTable = createHiveTable();
......@@ -488,9 +488,9 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasClassification piiClassification = new AtlasClassification(piiTrait.getName());
entitiesClientV2.addClassifications(hiveTable.getGuid(), Lists.newArrayList(piiClassification));
atlasClientV2.addClassifications(hiveTable.getGuid(), Lists.newArrayList(piiClassification));
AtlasClassifications classifications = entitiesClientV2.getClassifications(hiveTable.getGuid());
AtlasClassifications classifications = atlasClientV2.getClassifications(hiveTable.getGuid());
assertNotNull(classifications);
assertTrue(classifications.getList().size() > 0);
assertEquals(classifications.getList().size(), 8);
......@@ -511,10 +511,10 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
traitInstance.setAttribute("type", "SSN");
final String guid = createHiveTable().getGuid();
entitiesClientV2.addClassifications(guid, ImmutableList.of(traitInstance));
atlasClientV2.addClassifications(guid, ImmutableList.of(traitInstance));
// verify the response
AtlasEntity withAssociationByGuid = entitiesClientV2.getEntityByGuid(guid).getEntity();
AtlasEntity withAssociationByGuid = atlasClientV2.getEntityByGuid(guid).getEntity();
assertNotNull(withAssociationByGuid);
assertFalse(withAssociationByGuid.getClassifications().isEmpty());
......@@ -536,7 +536,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasClassification traitInstance = new AtlasClassification(traitName);
entitiesClientV2.addClassifications("random", ImmutableList.of(traitInstance));
atlasClientV2.addClassifications("random", ImmutableList.of(traitInstance));
}
@Test(dependsOnMethods = "testAddTrait")
......@@ -544,7 +544,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
final String guid = createHiveTable().getGuid();
try {
entitiesClientV2.deleteClassification(guid, traitName);
atlasClientV2.deleteClassification(guid, traitName);
} catch (AtlasServiceException ex) {
fail("Deletion should've succeeded");
}
......@@ -556,7 +556,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
final String traitName = "blah_trait";
try {
entitiesClientV2.deleteClassification("random", traitName);
atlasClientV2.deleteClassification("random", traitName);
fail("Deletion for bogus names shouldn't have succeeded");
} catch (AtlasServiceException ex) {
assertNotNull(ex.getStatus());
......@@ -579,7 +579,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
createType(typesDef);
try {
entitiesClientV2.deleteClassification(guid, traitName);
atlasClientV2.deleteClassification(guid, traitName);
fail("Deletion should've failed for non-existent trait association");
} catch (AtlasServiceException ex) {
Assert.assertNotNull(ex.getStatus());
......@@ -631,7 +631,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
hiveTable.setAttribute("columns", AtlasTypeUtil.toObjectIds(columns));
LOG.debug("Updating entity= " + tableUpdated);
EntityMutationResponse updateResult = entitiesClientV2.updateEntity(new AtlasEntityWithExtInfo(tableUpdated));
EntityMutationResponse updateResult = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(tableUpdated));
assertNotNull(updateResult);
assertNotNull(updateResult.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
assertTrue(updateResult.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).size() > 0);
......@@ -651,7 +651,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
LOG.debug("Updating entity= " + tableUpdated);
Map<String, String> uniqAttributes = new HashMap<>();
uniqAttributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, (String)hiveTable.getAttribute("name"));
EntityMutationResponse updateResponse = entitiesClientV2.updateEntityByAttribute(BaseResourceIT.HIVE_TABLE_TYPE_V2, uniqAttributes, tableUpdated);
EntityMutationResponse updateResponse = atlasClientV2.updateEntityByAttribute(BaseResourceIT.HIVE_TABLE_TYPE_V2, uniqAttributes, tableUpdated);
assertNotNull(updateResponse);
assertNotNull(updateResponse.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
assertTrue(updateResponse.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).size() > 0);
......@@ -662,7 +662,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
}
private AtlasEntity getEntityByGuid(String guid) throws AtlasServiceException {
return entitiesClientV2.getEntityByGuid(guid).getEntity();
return atlasClientV2.getEntityByGuid(guid).getEntity();
}
@Test(dependsOnMethods = "testSubmitEntity")
......@@ -686,7 +686,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
columns.add(ref2);
AtlasEntity hiveTable = createHiveTable();
hiveTable.setAttribute("columns", AtlasTypeUtil.toObjectIds(columns));
EntityMutationResponse updateEntityResult = entitiesClientV2.updateEntity(new AtlasEntityWithExtInfo(hiveTable));
EntityMutationResponse updateEntityResult = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(hiveTable));
assertNotNull(updateEntityResult);
assertNotNull(updateEntityResult.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
assertNotNull(updateEntityResult.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
......@@ -718,7 +718,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntityHeader entity2Header = createEntity(db2);
// Delete the database entities
EntityMutationResponse deleteResponse = entitiesClientV2.deleteEntitiesByGuids(ImmutableList.of(entity1Header.getGuid(), entity2Header.getGuid()));
EntityMutationResponse deleteResponse = atlasClientV2.deleteEntitiesByGuids(ImmutableList.of(entity1Header.getGuid(), entity2Header.getGuid()));
// Verify that deleteEntities() response has database entity guids
assertNotNull(deleteResponse);
......@@ -734,7 +734,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + random());
// Delete the database entity
EntityMutationResponse deleteResponse = entitiesClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) hiveDB.getAttribute(NAME)));
EntityMutationResponse deleteResponse = atlasClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) hiveDB.getAttribute(NAME)));
// Verify that deleteEntities() response has database entity guids
assertNotNull(deleteResponse);
......
......@@ -20,8 +20,8 @@ package org.apache.atlas.web.resources;
import com.google.common.collect.ImmutableSet;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.AtlasTypedefClientV2;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
......@@ -57,7 +57,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
private AtlasTypesDef typeDefinitions;
private AtlasTypedefClientV2 clientV2;
private AtlasClientV2 clientV2;
@BeforeClass
public void setUp() throws Exception {
......@@ -66,9 +66,9 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
typeDefinitions = createHiveTypes();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
clientV2 = new AtlasTypedefClientV2(atlasUrls, new String[]{"admin", "admin"});
clientV2 = new AtlasClientV2(atlasUrls, new String[]{"admin", "admin"});
} else {
clientV2 = new AtlasTypedefClientV2(atlasUrls);
clientV2 = new AtlasClientV2(atlasUrls);
}
}
......@@ -176,7 +176,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
@Test
public void testInvalidGets() throws Exception {
try {
AtlasEnumDef byName = clientV2.getEnumByName("blah");
AtlasEnumDef byName = clientV2.getEnumDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -184,7 +184,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasEnumDef byGuid = clientV2.getEnumByGuid("blah");
AtlasEnumDef byGuid = clientV2.getEnumDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -192,7 +192,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasStructDef byName = clientV2.getStructByName("blah");
AtlasStructDef byName = clientV2.getStructDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -200,7 +200,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasStructDef byGuid = clientV2.getStructByGuid("blah");
AtlasStructDef byGuid = clientV2.getStructDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -208,7 +208,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasClassificationDef byName = clientV2.getClassificationByName("blah");
AtlasClassificationDef byName = clientV2.getClassificationDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -216,7 +216,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasClassificationDef byGuid = clientV2.getClassificationByGuid("blah");
AtlasClassificationDef byGuid = clientV2.getClassificationDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -224,7 +224,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasEntityDef byName = clientV2.getEntityByName("blah");
AtlasEntityDef byName = clientV2.getEntityDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -232,7 +232,7 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
}
try {
AtlasEntityDef byGuid = clientV2.getEntityByGuid("blah");
AtlasEntityDef byGuid = clientV2.getEntityDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(),
......@@ -312,13 +312,13 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
try {
AtlasBaseTypeDef byName = null;
if (typeDef.getCategory() == TypeCategory.ENUM) {
byName = clientV2.getEnumByName(typeDef.getName());
byName = clientV2.getEnumDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.ENTITY) {
byName = clientV2.getEntityByName(typeDef.getName());
byName = clientV2.getEntityDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
byName = clientV2.getClassificationByName(typeDef.getName());
byName = clientV2.getClassificationDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.STRUCT) {
byName = clientV2.getStructByName(typeDef.getName());
byName = clientV2.getStructDefByName(typeDef.getName());
}
assertNotNull(byName);
} catch (AtlasServiceException e) {
......@@ -328,13 +328,13 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
try {
AtlasBaseTypeDef byGuid = null;
if (typeDef.getCategory() == TypeCategory.ENUM) {
byGuid = clientV2.getEnumByGuid(typeDef.getGuid());
byGuid = clientV2.getEnumDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.ENTITY) {
byGuid = clientV2.getEntityByGuid(typeDef.getGuid());
byGuid = clientV2.getEntityDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
byGuid = clientV2.getClassificationByGuid(typeDef.getGuid());
byGuid = clientV2.getClassificationDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.STRUCT) {
byGuid = clientV2.getStructByGuid(typeDef.getGuid());
byGuid = clientV2.getStructDefByGuid(typeDef.getGuid());
}
assertNotNull(byGuid);
} catch (AtlasServiceException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment