Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for local=true in the ATTRIBUTE discovery endpoints #1723

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
IMAGE_NAME: orion-ld
IMAGE_TAG_LATEST: latest
IMAGE_TAG_DEBUG: debug
IMAGE_TAG_PRE: 1.9.0-PRE-${{ github.run_number }}
IMAGE_TAG_PRE: 1.8.0-PRE-${{ github.run_number }}

jobs:

Expand Down
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Fixed Issues:
#XXXX: Complex @contexts of subscriptions weren't persisted in mongodb
#1707: Support for local=true in the type discovery endpoints (GET /ngsi-ld/v1/types[/{typeName}]
#XXXX: Support for local=true in the ATTRIBUTE discovery endpoints (GET /ngsi-ld/v1/attributes}]
#1708: Reloaded hosted contexts were not persisted in mongo, only the context cache

## New Features:
Expand Down
10 changes: 5 additions & 5 deletions src/lib/orionld/db/dbEntityAttributesGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static void remoteAttrNamesExtract(KjNode* outArray, KjNode* remote)
//
// dbEntityAttributesGetWithoutDetails -
//
static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP)
static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP, bool local)
{
//
// This is a bit ugly ...
Expand Down Expand Up @@ -238,9 +238,9 @@ static KjNode* dbEntityAttributesGetWithoutDetails(OrionldProblemDetails* pdP)
//
// GET external attributes - i.e. from the "registrations" collection
//
KjNode* remote = entityTypesFromRegistrationsGet(true);
KjNode* remote = (local == false)? entityTypesFromRegistrationsGet(true) : NULL;

if (remote)
if (remote != NULL)
remoteAttrNamesExtract(outArray, remote);

return getEntityAttributesResponse(outArray);
Expand Down Expand Up @@ -577,12 +577,12 @@ static KjNode* dbEntityAttributesGetWithDetails(OrionldProblemDetails* pdP, char
//
// dbEntityAttributesGet -
//
KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details)
KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details, bool local)
{
bzero(pdP, sizeof(OrionldProblemDetails));

if (details == false)
return dbEntityAttributesGetWithoutDetails(pdP);
return dbEntityAttributesGetWithoutDetails(pdP, local);
else
return dbEntityAttributesGetWithDetails(pdP, attribute);
}
2 changes: 1 addition & 1 deletion src/lib/orionld/db/dbEntityAttributesGet.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ extern "C"
//
// dbEntityAttributesGet -
//
extern KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details);
extern KjNode* dbEntityAttributesGet(OrionldProblemDetails* pdP, char* attribute, bool details, bool local);

#endif // SRC_LIB_ORIONLD_DB_DBENTITYATTRIBUTESGET_H_
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool orionldGetEntityAttribute(void)
OrionldProblemDetails pd;
char* attrLongName = orionldAttributeExpand(orionldState.contextP, orionldState.wildcard[0], true, NULL);

orionldState.responseTree = dbEntityAttributesGet(&pd, attrLongName, true);
orionldState.responseTree = dbEntityAttributesGet(&pd, attrLongName, true, orionldState.uriParams.local);

if (orionldState.responseTree == NULL)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool orionldGetEntityAttributes(void)
{
OrionldProblemDetails pd;

orionldState.responseTree = dbEntityAttributesGet(&pd, NULL, orionldState.uriParams.details);
orionldState.responseTree = dbEntityAttributesGet(&pd, NULL, orionldState.uriParams.details, orionldState.uriParams.local);
if (orionldState.responseTree == NULL)
{
// dbEntityAttributesGet calls orionldError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ orionldStart CB
# 07. GET Entity Attributes - see four attributes (P1, P2, P3, and R1)
# 08. Create a registration R2 with attributes P4 and R2
# 09. GET Entity Attributes - see six attributes (P1-P4, and R1-R2)
# 10. GET Entity Attributes with local=true - see four attributes (P1, P2, P3, and R1)
# 10. Create a registration R3 with attributes P1-P5 and R1-R5
# 11. GET Entity Attributes - see ten attributes (P1-P5, and R1-R5)
# 12. Remove R3, R1, E0 and E1
Expand Down Expand Up @@ -177,6 +178,13 @@ echo
echo


echo "10. GET Entity Attributes with local=true - see four attributes (P1, P2, P3, and R1)"
echo "===================================================================================="
orionCurl --url /ngsi-ld/v1/attributes?local=true
echo
echo


echo "10. Create a registration R3 with attributes P1-P5 and R1-R5"
echo "============================================================"
payload='{
Expand Down Expand Up @@ -366,6 +374,26 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
}


10. GET Entity Attributes with local=true - see four attributes (P1, P2, P3, and R1)
====================================================================================
HTTP/1.1 200 OK
Content-Length: 132
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)

{
"attributeList": [
"P1",
"P2",
"P3",
"R1"
],
"id": "urn:ngsi-ld:AttributeList:REGEX(.*)",
"type": "AttributeList"
}


10. Create a registration R3 with attributes P1-P5 and R1-R5
============================================================
HTTP/1.1 201 Created
Expand Down
Loading