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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations