/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> createType(String typeAsJson) throws AtlasServiceException { LOG.debug("Creating type definition: {}", typeAsJson); ObjectNode response = callAPIWithBody(API_V1.CREATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, ObjectNode>() { @Override String extractElement(ObjectNode element) { return element.get(AtlasClient.NAME).asText(); } }); LOG.debug("Create type definition returned results: {}", results); return results; }
/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> updateType(String typeAsJson) throws AtlasServiceException { LOG.debug("Updating type definition: {}", typeAsJson); JSONObject response = callAPIWithBody(API.UPDATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, JSONObject>() { @Override String extractElement(JSONObject element) throws JSONException { return element.getString(AtlasClient.NAME); } }); LOG.debug("Update type definition returned results: {}", results); return results; }
/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> updateType(String typeAsJson) throws AtlasServiceException { LOG.debug("Updating type definition: {}", typeAsJson); ObjectNode response = callAPIWithBody(API_V1.UPDATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, ObjectNode>() { @Override String extractElement(ObjectNode element) { return element.get(AtlasClient.NAME).asText(); } }); LOG.debug("Update type definition returned results: {}", results); return results; }
/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> updateType(String typeAsJson) throws AtlasServiceException { LOG.debug("Updating type definition: {}", typeAsJson); ObjectNode response = callAPIWithBody(API_V1.UPDATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, ObjectNode>() { @Override String extractElement(ObjectNode element) { return element.get(AtlasClient.NAME).asText(); } }); LOG.debug("Update type definition returned results: {}", results); return results; }
/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> createType(String typeAsJson) throws AtlasServiceException { LOG.debug("Creating type definition: {}", typeAsJson); JSONObject response = callAPIWithBody(API.CREATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, JSONObject>() { @Override String extractElement(JSONObject element) throws JSONException { return element.getString(AtlasClient.NAME); } }); LOG.debug("Create type definition returned results: {}", results); return results; }
/** * Register the given type(meta model) * @param typeAsJson type definition a jaon * @return result json object * @throws AtlasServiceException */ public List<String> createType(String typeAsJson) throws AtlasServiceException { LOG.debug("Creating type definition: {}", typeAsJson); ObjectNode response = callAPIWithBody(API_V1.CREATE_TYPE, typeAsJson); List<String> results = extractResults(response, AtlasClient.TYPES, new ExtractOperation<String, ObjectNode>() { @Override String extractElement(ObjectNode element) { return element.get(AtlasClient.NAME).asText(); } }); LOG.debug("Create type definition returned results: {}", results); return results; }
/** * Returns all type names in the system * @return list of type names * @throws AtlasServiceException */ public List<String> listTypes() throws AtlasServiceException { final JSONObject jsonObject = callAPIWithQueryParams(API.LIST_TYPES, null); return extractResults(jsonObject, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * List traits for a given entity identified by its GUID * @param guid GUID of the entity * @return List<String> - traitnames associated with entity * @throws AtlasServiceException */ public List<String> listTraits(final String guid) throws AtlasServiceException { JSONObject jsonResponse = callAPIWithBodyAndParams(API.LIST_TRAITS, null, guid, URI_TRAITS); return extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Get all trait definitions for an entity * @param guid GUID of the entity * @return List<String> trait definitions of the traits associated to the entity * @throws AtlasServiceException */ public List<Struct> listTraitDefinitions(final String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ALL_TRAIT_DEFINITIONS, null, guid, TRAIT_DEFINITIONS); List<ObjectNode> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<ObjectNode, ObjectNode>()); ArrayList<Struct> traitStructList = new ArrayList<>(); for (ObjectNode traitDef : traitDefList) { Struct traitStruct = AtlasType.fromV1Json(traitDef.toString(), Struct.class); traitStructList.add(traitStruct); } return traitStructList; }
/** * Get all trait definitions for an entity * @param guid GUID of the entity * @return List<String> trait definitions of the traits associated to the entity * @throws AtlasServiceException */ public List<Struct> listTraitDefinitions(final String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ALL_TRAIT_DEFINITIONS, null, guid, TRAIT_DEFINITIONS); List<ObjectNode> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<ObjectNode, ObjectNode>()); ArrayList<Struct> traitStructList = new ArrayList<>(); for (ObjectNode traitDef : traitDefList) { Struct traitStruct = AtlasType.fromV1Json(traitDef.toString(), Struct.class); traitStructList.add(traitStruct); } return traitStructList; }
/** * List entities for a given entity type * @param entityType * @return * @throws AtlasServiceException */ public List<String> listEntities(final String entityType) throws AtlasServiceException { JSONObject jsonResponse = callAPIWithRetries(API.LIST_ENTITIES, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(API.LIST_ENTITIES); resource = resource.queryParam(TYPE, entityType); return resource; } }); return extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Returns all type names with the given category * @param category * @return list of type names * @throws AtlasServiceException */ public List<String> listTypes(final DataTypes.TypeCategory category) throws AtlasServiceException { final API api = API_V1.LIST_TYPES; ObjectNode response = callAPIWithRetries(api, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(api.getNormalizedPath()); resource = resource.queryParam(TYPE, category.name()); return resource; } }); return extractResults(response, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Returns all type names with the given category * @param category * @return list of type names * @throws AtlasServiceException */ public List<String> listTypes(final DataTypes.TypeCategory category) throws AtlasServiceException { final API api = API_V1.LIST_TYPES; ObjectNode response = callAPIWithRetries(api, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(api.getNormalizedPath()); resource = resource.queryParam(TYPE, category.name()); return resource; } }); return extractResults(response, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Returns all type names with the given category * @param category * @return list of type names * @throws AtlasServiceException */ public List<String> listTypes(final DataTypes.TypeCategory category) throws AtlasServiceException { JSONObject response = callAPIWithRetries(API.LIST_TYPES, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(API.LIST_TYPES.getPath()); resource = resource.queryParam(TYPE, category.name()); return resource; } }); return extractResults(response, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Get all trait definitions for an entity * @param guid GUID of the entity * @return List<String> trait definitions of the traits associated to the entity * @throws AtlasServiceException */ public List<Struct> listTraitDefinitions(final String guid) throws AtlasServiceException{ JSONObject jsonResponse = callAPIWithBodyAndParams(API.GET_ALL_TRAIT_DEFINITIONS, null, guid, TRAIT_DEFINITIONS); List<JSONObject> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<JSONObject, JSONObject>()); ArrayList<Struct> traitStructList = new ArrayList<>(); for(JSONObject traitDef:traitDefList){ Struct traitStruct = InstanceSerialization.fromJsonStruct(traitDef.toString(), true); traitStructList.add(traitStruct); } return traitStructList; }
/** * Return the list of type names in the type system which match the specified filter. * * @param category returns types whose category is the given typeCategory * @param superType returns types which contain the given supertype * @param notSupertype returns types which do not contain the given supertype * * Its possible to specify combination of these filters in one request and the conditions are combined with AND * For example, typeCategory = TRAIT && supertype contains 'X' && supertype !contains 'Y' * If there is no filter, all the types are returned * @return list of type names */ public List<String> listTypes(final DataTypes.TypeCategory category, final String superType, final String notSupertype) throws AtlasServiceException { JSONObject response = callAPIWithRetries(API.LIST_TYPES, null, new ResourceCreator() { @Override public WebResource createResource() { WebResource resource = getResource(API.LIST_TYPES); resource = resource.queryParam(TYPE, category.name()); resource = resource.queryParam(SUPERTYPE, superType); resource = resource.queryParam(NOT_SUPERTYPE, notSupertype); return resource; } }); return extractResults(response, AtlasClient.RESULTS, new ExtractOperation<String, String>()); }
/** * Get the entity audit events in decreasing order of timestamp for the given entity id * @param entityId entity id * @param startKey key for the first event to be returned, used for pagination * @param numResults number of results to be returned * @return list of audit events for the entity id * @throws AtlasServiceException */ public List<EntityAuditEvent> getEntityAuditEvents(String entityId, String startKey, short numResults) throws AtlasServiceException { WebResource resource = getResource(API_V1.LIST_ENTITY_AUDIT, entityId, URI_ENTITY_AUDIT); if (StringUtils.isNotEmpty(startKey)) { resource = resource.queryParam(START_KEY, startKey); } resource = resource.queryParam(NUM_RESULTS, String.valueOf(numResults)); ObjectNode jsonResponse = callAPIWithResource(API_V1.LIST_ENTITY_AUDIT, resource); return extractResults(jsonResponse, AtlasClient.EVENTS, new ExtractOperation<EntityAuditEvent, ObjectNode>() { @Override EntityAuditEvent extractElement(ObjectNode element) { return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class); } }); }
/** * Get the entity audit events in decreasing order of timestamp for the given entity id * @param entityId entity id * @param startKey key for the first event to be returned, used for pagination * @param numResults number of results to be returned * @return list of audit events for the entity id * @throws AtlasServiceException */ public List<EntityAuditEvent> getEntityAuditEvents(String entityId, String startKey, short numResults) throws AtlasServiceException { WebResource resource = getResource(API.LIST_ENTITY_AUDIT, entityId, URI_ENTITY_AUDIT); if (StringUtils.isNotEmpty(startKey)) { resource = resource.queryParam(START_KEY, startKey); } resource = resource.queryParam(NUM_RESULTS, String.valueOf(numResults)); JSONObject jsonResponse = callAPIWithResource(API.LIST_ENTITY_AUDIT, resource); return extractResults(jsonResponse, AtlasClient.EVENTS, new ExtractOperation<EntityAuditEvent, JSONObject>() { @Override EntityAuditEvent extractElement(JSONObject element) throws JSONException { return SerDe.GSON.fromJson(element.toString(), EntityAuditEvent.class); } }); }
/** * Get the entity audit events in decreasing order of timestamp for the given entity id * @param entityId entity id * @param startKey key for the first event to be returned, used for pagination * @param numResults number of results to be returned * @return list of audit events for the entity id * @throws AtlasServiceException */ public List<EntityAuditEvent> getEntityAuditEvents(String entityId, String startKey, short numResults) throws AtlasServiceException { WebResource resource = getResource(API_V1.LIST_ENTITY_AUDIT, entityId, URI_ENTITY_AUDIT); if (StringUtils.isNotEmpty(startKey)) { resource = resource.queryParam(START_KEY, startKey); } resource = resource.queryParam(NUM_RESULTS, String.valueOf(numResults)); ObjectNode jsonResponse = callAPIWithResource(API_V1.LIST_ENTITY_AUDIT, resource); return extractResults(jsonResponse, AtlasClient.EVENTS, new ExtractOperation<EntityAuditEvent, ObjectNode>() { @Override EntityAuditEvent extractElement(ObjectNode element) { return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class); } }); }