Search in sources :

Example 11 with Timed

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

the class EntityREST method deleteByGuid.

/**
 * Delete an entity identified by its GUID.
 * @param  guid GUID for the entity
 * @return EntityMutationResponse
 */
@DELETE
@Path("/guid/{guid}")
@Timed
public EntityMutationResponse deleteByGuid(@PathParam("guid") final String guid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteByGuid(" + guid + ")");
        }
        return entitiesStore.deleteById(guid);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(org.apache.atlas.annotation.Timed)

Example 12 with Timed

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

the class EntityREST method removeLabels.

@DELETE
@Path("/uniqueAttribute/type/{typeName}/labels")
@Timed
public void removeLabels(@PathParam("typeName") String typeName, Set<String> labels, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.removeLabels(" + typeName + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        Map<String, Object> attributes = getAttributes(servletRequest);
        String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
        if (guid == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
        }
        entitiesStore.removeLabels(guid, labels);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(org.apache.atlas.annotation.Timed)

Example 13 with Timed

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

the class EntityREST method deleteClassificationByUniqueAttribute.

/**
 * Deletes a given classification from an entity identified by its type and unique attributes.
 * @param typeName
 * @param classificationName name of the classification
 */
@DELETE
@Path("/uniqueAttribute/type/{typeName}/classification/{classificationName}")
@Timed
public void deleteClassificationByUniqueAttribute(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest, @PathParam("classificationName") String classificationName) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    Servlets.validateQueryParamLength("classificationName", classificationName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteClassificationByUniqueAttribute(" + typeName + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        Map<String, Object> attributes = getAttributes(servletRequest);
        String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
        if (guid == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
        }
        entitiesStore.deleteClassification(guid, classificationName);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(org.apache.atlas.annotation.Timed)

Example 14 with Timed

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

the class EntityREST method getClassifications.

/**
 * Gets the list of classifications for a given entity represented by a guid.
 * @param guid globally unique identifier for the entity
 * @return a list of classifications for the given entity guid
 */
@GET
@Path("/guid/{guid}/classifications")
@Timed
public AtlasClassification.AtlasClassifications getClassifications(@PathParam("guid") String guid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassifications(" + guid + ")");
        }
        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }
        return new AtlasClassification.AtlasClassifications(entitiesStore.getClassifications(guid));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : 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 15 with Timed

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

the class EntityREST method partialUpdateEntityByUniqueAttrs.

/**
 *****
 * Entity Partial Update - Allows a subset of attributes to be updated on
 * an entity which is identified by its type and unique attribute  eg: Referenceable.qualifiedName.
 * Null updates are not possible
 *
 * 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
 *
 * PUT /v2/entity/uniqueAttribute/type/aType?attr:aTypeAttribute=someValue
 *
 ******
 */
@PUT
@Path("/uniqueAttribute/type/{typeName}")
@Timed
public EntityMutationResponse partialUpdateEntityByUniqueAttrs(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest, AtlasEntityWithExtInfo entityInfo) throws Exception {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        Map<String, Object> uniqueAttributes = getAttributes(servletRequest);
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.partialUpdateEntityByUniqueAttrs(" + typeName + "," + uniqueAttributes + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        validateUniqueAttribute(entityType, uniqueAttributes);
        return entitiesStore.updateByUniqueAttributes(entityType, uniqueAttributes, entityInfo);
    } 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) 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