Esempio n. 1
0
/* ****************************************************************************
*
* getEntityType -
*
* GET /v2/type/<entityType>
*
* Payload In:  None
* Payload Out: EntityTypeAttributesResponse
*/
std::string getEntityType
(
  ConnectionInfo*            ciP,
  int                        components,
  std::vector<std::string>&  compV,
  ParseData*                 parseDataP
)
{
  EntityTypeAttributesResponse  response;
  std::string                   entityTypeName = compV[2];
  std::string                   answer;

  mongoAttributesForEntityType(entityTypeName, &response, ciP->tenant, ciP->servicePathV, ciP->uriParam);

  answer = response.toJson(ciP);
  response.release();

  return answer;
}
/* ****************************************************************************
*
* getAttributesForEntityType -
*/
std::string getAttributesForEntityType
(
  ConnectionInfo*            ciP,
  int                        components,
  std::vector<std::string>&  compV,
  ParseData*                 parseDataP
)
{
  EntityTypeAttributesResponse  response;
  std::string                   entityTypeName = compV[2];

  response.statusCode.fill(SccOk);
  mongoAttributesForEntityType(entityTypeName, &response, ciP->tenant, ciP->servicePathV, ciP->uriParam);

  std::string rendered = response.render(ciP, "");
  response.release();

  return rendered;
}
Esempio n. 3
0
/* ****************************************************************************
*
* getEntityType -
*
* GET /v2/types/<entityType>
*
* Payload In:  None
* Payload Out: EntityTypeResponse
*
* URI parameters:
*   - options=noAttrDetail
*
*/
std::string getEntityType
(
  ConnectionInfo*            ciP,
  int                        components,
  std::vector<std::string>&  compV,
  ParseData*                 parseDataP
)
{
  EntityTypeResponse  response;
  std::string         entityTypeName = compV[2];
  std::string         answer;
  bool                noAttrDetail   = ciP->uriParamOptions[OPT_NO_ATTR_DETAIL];

  if (entityTypeName == "")
  {
    OrionError oe(SccBadRequest, EMPTY_ENTITY_TYPE, "BadRequest");
    ciP->httpStatusCode = oe.code;
    return oe.toJson();
  }

  TIMED_MONGO(mongoAttributesForEntityType(entityTypeName, &response, ciP->tenant, ciP->servicePathV, ciP->uriParam, noAttrDetail, ciP->apiVersion));

  if (response.entityType.count == 0)
  {
    OrionError oe(SccContextElementNotFound, "Entity type not found", "NotFound");
    TIMED_RENDER(answer = oe.toJson());
    ciP->httpStatusCode = oe.code;
  }
  else
  {
    TIMED_RENDER(answer = response.toJson(ciP));
  }

  response.release();

  return answer;
}