/**
   * Fetch the complete definition of an entity given its qualified name.
   *
   * @param entityType
   * @param attribute
   * @param value
   */
  public Response getEntityDefinitionByAttribute(
      String entityType, String attribute, String value) {
    try {
      LOG.debug("Fetching entity definition for type={}, qualified name={}", entityType, value);
      ParamChecker.notEmpty(entityType, "Entity type cannot be null");
      ParamChecker.notEmpty(attribute, "attribute name cannot be null");
      ParamChecker.notEmpty(value, "attribute value cannot be null");

      final String entityDefinition =
          metadataService.getEntityDefinition(entityType, attribute, value);

      JSONObject response = new JSONObject();
      response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());

      Response.Status status = Response.Status.NOT_FOUND;
      if (entityDefinition != null) {
        response.put(AtlasClient.DEFINITION, new JSONObject(entityDefinition));
        status = Response.Status.OK;
      } else {
        response.put(
            AtlasClient.ERROR,
            Servlets.escapeJsonString(
                String.format(
                    "An entity with type={%s}, " + "qualifiedName={%s} does not exist",
                    entityType, value)));
      }

      return Response.status(status).entity(response).build();

    } catch (EntityNotFoundException e) {
      LOG.error("An entity with type={} and qualifiedName={} does not exist", entityType, value, e);
      throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
    } catch (AtlasException | IllegalArgumentException e) {
      LOG.error("Bad type={}, qualifiedName={}", entityType, value, e);
      throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (Throwable e) {
      LOG.error(
          "Unable to get instance definition for type={}, qualifiedName={}", entityType, value, e);
      throw new WebApplicationException(
          Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    }
  }
  /**
   * Fetch the complete definition of an entity given its GUID.
   *
   * @param guid GUID for the entity
   */
  @GET
  @Path("{guid}")
  @Produces(Servlets.JSON_MEDIA_TYPE)
  public Response getEntityDefinition(@PathParam("guid") String guid) {
    try {
      LOG.debug("Fetching entity definition for guid={} ", guid);
      ParamChecker.notEmpty(guid, "guid cannot be null");
      final String entityDefinition = metadataService.getEntityDefinition(guid);

      JSONObject response = new JSONObject();
      response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());

      Response.Status status = Response.Status.NOT_FOUND;
      if (entityDefinition != null) {
        response.put(AtlasClient.DEFINITION, new JSONObject(entityDefinition));
        status = Response.Status.OK;
      } else {
        response.put(
            AtlasClient.ERROR,
            Servlets.escapeJsonString(
                String.format("An entity with GUID={%s} does not exist", guid)));
      }

      return Response.status(status).entity(response).build();

    } catch (EntityNotFoundException e) {
      LOG.error("An entity with GUID={} does not exist ", guid, e);
      throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
    } catch (AtlasException | IllegalArgumentException e) {
      LOG.error("Bad GUID={} ", guid, e);
      throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (Throwable e) {
      LOG.error("Unable to get instance definition for GUID {}", guid, e);
      throw new WebApplicationException(
          Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    }
  }