Commit c08bac80 by Andrew Hulbert Committed by apoorvnaik

ATLAS-2210 Add Relationships to Client V2

parent 3959b318
...@@ -27,6 +27,7 @@ import org.apache.atlas.model.instance.AtlasClassification; ...@@ -27,6 +27,7 @@ import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications; import org.apache.atlas.model.instance.AtlasClassification.AtlasClassifications;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
import org.apache.atlas.model.instance.AtlasRelationship;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.lineage.AtlasLineageInfo; import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection; import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
...@@ -69,6 +70,9 @@ public class AtlasClientV2 extends AtlasBaseClient { ...@@ -69,6 +70,9 @@ public class AtlasClientV2 extends AtlasBaseClient {
private static final String BASIC_SEARCH_URI = DISCOVERY_URI + "/basic"; private static final String BASIC_SEARCH_URI = DISCOVERY_URI + "/basic";
private static final String FACETED_SEARCH_URI = BASIC_SEARCH_URI; private static final String FACETED_SEARCH_URI = BASIC_SEARCH_URI;
// Relationships APIs
private static final String RELATIONSHIPS_URI = BASE_URI + "v2/relationship/";
public AtlasClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) { public AtlasClientV2(String[] baseUrl, String[] basicAuthUserNamePassword) {
super(baseUrl, basicAuthUserNamePassword); super(baseUrl, basicAuthUserNamePassword);
} }
...@@ -247,7 +251,7 @@ public class AtlasClientV2 extends AtlasBaseClient { ...@@ -247,7 +251,7 @@ public class AtlasClientV2 extends AtlasBaseClient {
} }
public AtlasEntityWithExtInfo getEntityByGuid(String guid) throws AtlasServiceException { public AtlasEntityWithExtInfo getEntityByGuid(String guid) throws AtlasServiceException {
return callAPI(API_V2.GET_ENTITY_BY_GUID, AtlasEntityWithExtInfo.class, (MultivaluedMap<String, String>) null, guid); return callAPI(API_V2.GET_ENTITY_BY_GUID, AtlasEntityWithExtInfo.class, null, guid);
} }
public AtlasEntityWithExtInfo getEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException { public AtlasEntityWithExtInfo getEntityByAttribute(String type, Map<String, String> attributes) throws AtlasServiceException {
...@@ -375,6 +379,14 @@ public class AtlasClientV2 extends AtlasBaseClient { ...@@ -375,6 +379,14 @@ public class AtlasClientV2 extends AtlasBaseClient {
return callAPI(API_V2.FACETED_SEARCH, AtlasSearchResult.class, searchParameters); return callAPI(API_V2.FACETED_SEARCH, AtlasSearchResult.class, searchParameters);
} }
public AtlasRelationship getRelationshipByGuid(String guid) throws AtlasServiceException {
return callAPI(API_V2.GET_RELATIONSHIP_BY_GUID, AtlasRelationship.class, null, guid);
}
public void deleteRelationshipByGuid(String guid) throws AtlasServiceException {
callAPI(API_V2.DELETE_RELATIONSHIP_BY_GUID, (Class) null, null, guid);
}
@Override @Override
protected API formatPathParameters(final API api, final String... params) { protected API formatPathParameters(final API api, final String... params) {
return new API(String.format(api.getPath(), params), api.getMethod(), api.getExpectedStatus()); return new API(String.format(api.getPath(), params), api.getMethod(), api.getExpectedStatus());
...@@ -452,6 +464,8 @@ public class AtlasClientV2 extends AtlasBaseClient { ...@@ -452,6 +464,8 @@ public class AtlasClientV2 extends AtlasBaseClient {
public static final API_V2 FULL_TEXT_SEARCH = new API_V2(FULL_TEXT_URI, HttpMethod.GET, Response.Status.OK); public static final API_V2 FULL_TEXT_SEARCH = new API_V2(FULL_TEXT_URI, HttpMethod.GET, Response.Status.OK);
public static final API_V2 BASIC_SEARCH = new API_V2(BASIC_SEARCH_URI, HttpMethod.GET, Response.Status.OK); public static final API_V2 BASIC_SEARCH = new API_V2(BASIC_SEARCH_URI, HttpMethod.GET, Response.Status.OK);
public static final API_V2 FACETED_SEARCH = new API_V2(FACETED_SEARCH_URI, HttpMethod.POST, Response.Status.OK); public static final API_V2 FACETED_SEARCH = new API_V2(FACETED_SEARCH_URI, HttpMethod.POST, Response.Status.OK);
public static final API_V2 GET_RELATIONSHIP_BY_GUID = new API_V2(RELATIONSHIPS_URI + "guid/", HttpMethod.GET, Response.Status.OK);
public static final API_V2 DELETE_RELATIONSHIP_BY_GUID = new API_V2(RELATIONSHIPS_URI + "guid/", HttpMethod.DELETE, Response.Status.NO_CONTENT);
private API_V2(String path, String method, Response.Status status) { private API_V2(String path, String method, Response.Status status) {
super(path, method, status); super(path, method, status);
......
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