fiware-orion icon indicating copy to clipboard operation
fiware-orion copied to clipboard

attrs=! (and maybe also metadata=!) as alias for "no attribute/metadata at all"

Open fgalan opened this issue 4 years ago • 7 comments

Some uses case (see issue https://github.com/telefonicaid/fiware-orion/issues/3777) could take advantage of this.

Suggestions for alternatives to ! are welcome.

fgalan avatar Feb 19 '21 15:02 fgalan

CC: @fisuda @kzangeli

fgalan avatar Feb 19 '21 15:02 fgalan

Upon completion of this issue, some other repositories may need to change the usage of the workaround attrs=__NONE to attrs=! (or whichever alternative we implemented at the end). In particular, see:

  • https://github.com/lets-fiware/ngsi-go/pull/88
  • https://github.com/FIWARE/tutorials.CRUD-Operations/pull/15

fgalan avatar Feb 22 '21 10:02 fgalan

Hi @fgalan sir,

I think this issue is already fixed. So I would suggest, please close this issue.

Anjali-NEC avatar Jan 31 '22 08:01 Anjali-NEC

I don't think so...

Why do you think this is already fixed? Do we have some existing .test covering this case?

fgalan avatar Jan 31 '22 08:01 fgalan

I don't think so...

Why do you think this is already fixed? Do we have some existing .test covering this case?

As per my understanding of this issue Get /v2/entities?attrs=! and Get /v2/entities?attrs=__NONE is used for getting only entity ids and types in the response.

I'm getting entity ids and types in the response using both the API Get /v2/entities?attrs=! and Get /v2/entities?attrs=__NONE. Below is the output for same. So what we need fix in this issue? can you please confirm?

att

att1

Anjali-NEC avatar Jan 31 '22 08:01 Anjali-NEC

@Anjali-NEC

Whether it is suitable to use ! is under discussion.

I'm getting entity ids and types in the response using both the API Get /v2/entities?attrs=! and Get /v2/entities?attrs=__NONE. Below is the output for same.

Really? The output is different in the following case.

curl -sX POST "http://localhost:1026/v2/op/update" \
--header "Content-Type: application/json" \
--data '{
  "actionType": "append",
  "entities": [
    {"id": "Room1", "type": "Room", "temperature": {"type": "Number", "value": 1}},
    {"id": "Room2", "type": "Room", "temperature": {"type": "Number", "value": 2}},
    {"id": "Room70133", "type": "Room", "temperature": {"type": "Number", "value": 3}},
    {"id": "E", "type": "T", "!": {"type": "Number", "value": 4}}
  ]
}'
$ curl -s localhost:1026/v2/entities?attrs=__NONE | jq .
[
  {
    "id": "Room1",
    "type": "Room"
  },
  {
    "id": "Room2",
    "type": "Room"
  },
  {
    "id": "Room70133",
    "type": "Room"
  },
  {
    "id": "E",
    "type": "T"
  }
]
$ curl -s localhost:1026/v2/entities?attrs=! | jq .
[
  {
    "id": "Room1",
    "type": "Room"
  },
  {
    "id": "Room2",
    "type": "Room"
  },
  {
    "id": "Room70133",
    "type": "Room"
  },
  {
    "id": "E",
    "type": "T",
    "!": {
      "type": "Number",
      "value": 4,
      "metadata": {}
    }
  }
]
$ curl -s localhost:1026/version | jq .orion.version
"3.5.0"

fisuda avatar Feb 01 '22 03:02 fisuda

@fisuda is right (thanks for the example!). The feature has not been yet implemented. @Anjali-NEC your case is apparently working because ! is interpreted as an actual attribute name and you don't have it in any entity. Note that GET /v2/entities?attrs=fooobaaar would have the same effect, and doesn't means the feature it's working ;)

Note that, according with the rules in "Field Syntax Restriction" section in http://telefonicaid.github.io/fiware-orion/api/v2/stable/ ! is a valid attribute name in NGSIv2, but it so weird that nobody is using it and I think we can use ! to mean "no attributes" in attrs= for GET requests. However, suggestions of alternatives are welcome! :)

  • Allowed characters are the ones in the plain ASCII set, except the following ones: control characters, whitespace, &, ?, / and #.
  • ...
  • Minimum field length is 1 character.

fgalan avatar Feb 01 '22 08:02 fgalan