Search in sources :

Example 21 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getEntitiesByUniqueAttributes.

/**
 ***************************************************************
 */
/**
 * Bulk API operations                                          *
 */
/**
 ***************************************************************
 */
/**
 * Bulk API to retrieve list of entities identified by its unique attributes.
 *
 * In addition to the typeName path parameter, attribute key-value pair(s) can be provided in the following format
 *
 * typeName=<typeName>&attr_1:<attrName>=<attrValue>&attr_2:<attrName>=<attrValue>&attr_3:<attrName>=<attrValue>
 *
 * NOTE: The attrName should be an unique attribute for the given entity-type
 *
 * The REST request would look something like this
 *
 * GET /v2/entity/bulk/uniqueAttribute/type/hive_db?attr_0:qualifiedName=db1@cl1&attr_2:qualifiedName=db2@cl1
 *
 * @param typeName
 * @param minExtInfo
 * @param ignoreRelationships
 * @return AtlasEntitiesWithExtInfo
 * @throws AtlasBaseException
 */
@GET
@Path("/bulk/uniqueAttribute/type/{typeName}")
@Timed
public AtlasEntitiesWithExtInfo getEntitiesByUniqueAttributes(@PathParam("typeName") String typeName, @QueryParam("minExtInfo") @DefaultValue("false") boolean minExtInfo, @QueryParam("ignoreRelationships") @DefaultValue("false") boolean ignoreRelationships, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        List<Map<String, Object>> uniqAttributesList = getAttributesList(servletRequest);
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getEntitiesByUniqueAttributes(" + typeName + "," + uniqAttributesList + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        for (Map<String, Object> uniqAttributes : uniqAttributesList) {
            validateUniqueAttribute(entityType, uniqAttributes);
        }
        return entitiesStore.getEntitiesByUniqueAttributes(entityType, uniqAttributesList, minExtInfo, ignoreRelationships);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Map(java.util.Map) HashMap(java.util.HashMap) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 22 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getEntityHeaderByUniqueAttributes.

/**
 * Fetch AtlasEntityHeader given its type and unique attribute.
 *
 * In addition to the typeName path parameter, attribute key-value pair(s) can be provided in the following format
 *
 * attr:<attrName>=<attrValue>
 *
 * NOTE: The attrName and attrValue should be unique across entities, eg. qualifiedName
 *
 * The REST request would look something like this
 *
 * GET /v2/entity/uniqueAttribute/type/aType/header?attr:aTypeAttribute=someValue
 *
 * @param typeName
 * @return AtlasEntityHeader
 * @throws AtlasBaseException
 */
@GET
@Path("/uniqueAttribute/type/{typeName}/header")
@Timed
public AtlasEntityHeader getEntityHeaderByUniqueAttributes(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        Map<String, Object> attributes = getAttributes(servletRequest);
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getEntityHeaderByUniqueAttributes(" + typeName + "," + attributes + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        validateUniqueAttribute(entityType, attributes);
        return entitiesStore.getEntityHeaderByUniqueAttributes(entityType, attributes);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 23 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class GlossaryREST method getDetailedGlossary.

/**
 * Get a specific Glossary
 * @param glossaryGuid unique glossary identifier
 * @return Glossary
 * @throws AtlasBaseException
 * @HTTP 200 If glossary exists for given GUID
 * @HTTP 404 If glossary GUID is invalid
 */
@GET
@Path("/{glossaryGuid}/detailed")
@Timed
public AtlasGlossary.AtlasGlossaryExtInfo getDetailedGlossary(@PathParam("glossaryGuid") String glossaryGuid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("glossaryGuid", glossaryGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getDetailedGlossary(" + glossaryGuid + ")");
        }
        AtlasGlossary.AtlasGlossaryExtInfo ret = glossaryService.getDetailedGlossary(glossaryGuid);
        if (ret == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
        }
        return ret;
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 24 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class GlossaryREST method getEntitiesAssignedWithTerm.

/**
 * Get all entity headers assigned with the specified term
 * @param termGuid GUID of the term
 * @param limit page size - by default there is no paging
 * @param offset offset for pagination purpose
 * @param sort ASC (default) or DESC
 * @return
 * @throws AtlasBaseException
 * @HTTP 200 List of entity headers (if any) for the given glossary or an empty list
 * @HTTP 404 If glossary term guid in invalid
 */
@GET
@Path("/terms/{termGuid}/assignedEntities")
@Timed
public List<AtlasRelatedObjectId> getEntitiesAssignedWithTerm(@PathParam("termGuid") String termGuid, @DefaultValue("-1") @QueryParam("limit") String limit, @DefaultValue("0") @QueryParam("offset") String offset, @DefaultValue("ASC") @QueryParam("sort") final String sort) throws AtlasBaseException {
    Servlets.validateQueryParamLength("termGuid", termGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getEntitiesAssignedWithTerm(" + termGuid + ")");
        }
        return glossaryService.getAssignedEntities(termGuid, Integer.parseInt(offset), Integer.parseInt(limit), toSortOrder(sort));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 25 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class GlossaryREST method partialUpdateGlossaryCategory.

/**
 * Partially update the glossary category
 * @param categoryGuid unique identifier for glossary term
 * @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values
 * @return Updated glossary category
 * @throws AtlasBaseException
 * @HTTP 200 If glossary category partial update was successful
 * @HTTP 404 If glossary category guid in invalid
 * @HTTP 400 If category attributes are invalid
 */
@PUT
@Path("/category/{categoryGuid}/partial")
@Timed
public AtlasGlossaryCategory partialUpdateGlossaryCategory(@PathParam("categoryGuid") String categoryGuid, Map<String, String> partialUpdates) throws AtlasBaseException {
    Servlets.validateQueryParamLength("categoryGuid", categoryGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossaryCategory()");
        }
        if (MapUtils.isEmpty(partialUpdates)) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty");
        }
        AtlasGlossaryCategory glossaryCategory = glossaryService.getCategory(categoryGuid);
        for (Map.Entry<String, String> entry : partialUpdates.entrySet()) {
            try {
                glossaryCategory.setAttribute(entry.getKey(), entry.getValue());
            } catch (IllegalArgumentException e) {
                throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, "Glossary Category", entry.getKey());
            }
        }
        return glossaryService.updateCategory(glossaryCategory);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasGlossaryCategory(org.apache.atlas.model.glossary.AtlasGlossaryCategory) Map(java.util.Map) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) PUT(javax.ws.rs.PUT)

Aggregations

Timed (org.apache.atlas.annotation.Timed)74 Path (javax.ws.rs.Path)72 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)58 GET (javax.ws.rs.GET)45 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)23 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)14 PUT (javax.ws.rs.PUT)12 DELETE (javax.ws.rs.DELETE)9 POST (javax.ws.rs.POST)6 Map (java.util.Map)5 AtlasGlossary (org.apache.atlas.model.glossary.AtlasGlossary)3 HashMap (java.util.HashMap)2 Produces (javax.ws.rs.Produces)2 SearchFilter (org.apache.atlas.model.SearchFilter)2 AtlasGlossaryCategory (org.apache.atlas.model.glossary.AtlasGlossaryCategory)2 AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)2 AtlasUserSavedSearch (org.apache.atlas.model.profile.AtlasUserSavedSearch)2 AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)2 AtlasBusinessMetadataDef (org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2