[Fiware-ngsi] FIWARE NGSI API discussion points

Fermín Galán Márquez fermin.galanmarquez at telefonica.com
Mon Jul 6 13:41:01 CEST 2015


Dear Tobias,

Please find my comments inline.

El 01/07/2015 a las 10:45, Tobias Jacobs escribió:
Hi Fermin and all,

Please find my comments inline. Some questions I still have to discuss with my colleagues.

Best
Tobias

[TJ] The NGSI v2 proposal is very rich and there will be many different things to discuss or clarify. I am not sure what is the best “format” for the discussion, but let me start in this email with a few points (most of them questions). We are not done yet analyzing the complete proposal and more discussions will follow.
[FGM1] Email discussions are perfectly ok. Other alternative ways to provide feedback would be issues in github.com and even pull request suggesting modification to the specification or cookbook .apib files (.apib files at https://github.com/telefonicaid/fiware-orion/tree/develop/doc/apiary/v2 are the "source code" for Apiary web at http://telefonicaid.github.io/fiware-orion/api/v2/ and http://telefonicaid.github.io/fiware-orion/api/v2/cookbook)

(If you are not familiar with the pull request way of working in github.com, please tell me and we try to provide an introduction).

[TJ] OK; I think I prefer at the moment the email format for the basic discussions, and when it comes to the subtle details we can consider moving to pull requests. [Personally I am also not so well aware yet on how this works, but I have colleagues who can help me ☺]



1)      “flat” JSON message:
In general NEC agrees to reserve “id”, “type”, “value” to have special semantics. Even if this means that entities can have no attributes called “id”, “type” or “value”

Alternatively (and for maybe making the descriptions easier to understand) we might think about calling “id”, “type”, “value” special attributes with special semantics; some being mandatory (e.g. “id” is mandatory in entities).



2)      Predefined value types: in general NEC supports to have predefined types in order to improve interoperability



3)      JSON types as predefined value types: We understand that a JSON property whose value is not a JSON object (and thus has no explicitly stated type) is implicitly either of type “number”, “string” or “boolean”, depending on the type of the JSON property. So for example "temperature": 32.5 would be implicitly of type “number”.
[FGM2] Yes, that's the idea. I would recommend you to have a new look to the specification, as we have merged some changes this morning that (we hope) make this idea clearer.

(The diff of the newest changes is at https://github.com/telefonicaid/fiware-orion/pull/1042/files in the case you prefer to see only the modifications)

[TJ] It seems in the newest version that you removed the “implicit” types number, boolean and string, so that every attribute value now needs to be a JSON object. Is this correct?
[FGM1] Not exactly... Every attribute needs to be a JSON type, which can be one of the following ones: string, number, boolean, object or array (i.e. not necessarily an "object", which is only one among 5 possibilities).


4)      Further predefined value types: We also understand that there will be further predefined types like for example “geo:point”.  But we believe that attribute values having this kind of type will still need to be a JSON object with explicitly stated “type” property, because otherwise e.g. one cannot distinguish a “date” value from a “string” value. This would mean that the example "timestamp": "2017-06-17T07:21:24.238Z" is incorrect and would instead have to look like

“timestamp”:{
               “value”: "2017-06-17T07:21:24.238Z"
              “type”: date
}
[FGM3] In the new version of the spec, there are only two special NGSI types ("date" and "geo:point"), both associated to the JSON string type. I think it works in the way you suggest here, but a double checking the new version of the spec to get your feedback would be great.

[TJ] Yes, in the new versions the values are objects with explicitly given types.
[FGM2] Actually, values are JSON valid types, among string, number, boolean, object and array. For JSON strings, the attribute type (from a NGSI point of view) "date" and "geo:point" would have the special meaning described in the specification.


5)      Further predefined value types: We assume that some predefined value types can refer to specific JSON object formats, not only to specific string formats.
[FGM4] It could be so from a theoretical point of view. However, by the moment, the only two special types we have found make sense are "date" and "geo:point", both associated to JSON string. Maybe you have some other case in mind?

[TJ] I do not have a specific example in my mind at the moment, so it is indeed more a theoretical consideration. I imagine that for the sake of interoperability specific domains could publish something  like a catalogue of their entity types and the format of the values they are using.
[FGM3] To be precise, I understand you mean "a catalogue of their entity types and the format of the values of the entity attributes they are using"

6)      User-defined types: It is currently written that “The values of user-defined informative types are represented by JSON string”, but we believe that user-defined types should be representable by numbers, Booleans and JSON objects as well.
[FGM5] This has  changed in the new version of the spec and I guess now works in the way you suggest. Now, NGSI type and JSON type are "orthogonal" aspects on the attribute.

[TJ] OK, I read that even arrays would be allowed. Makes sense to me.


7)      Error format: Currently an error code is not specified. Is this because it is intended to use the status code in the HTTP header instead? Can this lead to conflicts between standard HTTP error codes (e.g. 404 resource not found) and NGSI error codes (eg. 404 context element not found)?
[FGM6] Exactly. The idea is to use HTTP status code for the numeric error code, so no conflict should occur. Note that one of the criticized aspects in NGSI v1 is not using HTTP code to convey the error code, as this is not the common way of working in RESTful APIs. E.g. this would be a "not found" error response in NGSIv2:

HTTP/1.1 404 Not Found
Content-Length: 95
Content-Type: application/json
Date: ...

{
    "error": "NotFound",
    "description": "The requested entity has not been found. Check type and id"
}

[TJ] I need to further discuss with my colleagues about this before agreeing or proposing an alternative.
One concern is that not having the status code in the response message forces applications to also look into the response header, which is not always convenient.
[FGM4] (I understand that your refer to the status line, i.e. "HTTP/1.1 404 Not Found", not to response headers, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html)

On the other side, one of the concerns (that I have personally listened several times when presenting Orion in FIWARE events) is exactly the opposite :), i.e. that with the current way of working in NGSI you always need to check the payload to know the error. Even worse, depending on the request type (queryContext, updateContext, etc.) the error may be in different places on the payload, which is a little bit crazy from the point of view of the client programmer.

Anyway, the above approach should make both people happy, I mean:

  *   For people not wanting to check the status code, they can access to the payload and check the "error" message.
  *   For people not wanting to check the payload, they can get the status code in the status line.


8)      API entry point
In general NEC agrees to make this resource somehow an overview of the main API urls. Would you make the format if this link list predefined, or would you leave the specific format to the API developer?
[FGM7] I think Jose Manuel could answer this better than me.


9)


10)  Pagination: In principle NEC supports the concept of pagination. However we are not sure how it can be realized in practice, as query results are dynamic (especially when getting the queried data live from a distributed system like IoT systems do). What the user probably expects is that the query results are “frozen” for him and then delivered page by page. But then something like a query ID is needed to collect the query results.
Alternatively the query result could be represented by a specific http resource (which is similar to a query id).
In both cases things become slightly more complex…

Do you have a proposal how to deal with that issue?
[FGM8] Frozen the query at NGSI server implementation could have an important performance impact (as the frozen results would need to be maintained in memory from an undefined amount of time while the client gets all the result) and would make NGSI sever implementation stateful, which is very bad from the point of view of HA and horizontal scaling.

Some ordering criteria may alleviate the problem In particular, entity creation date, which ensures that any new entity have to be put at the end. However, even in this case, there could be some problems if an entity already seen page is deleted (as it would introduce a shift in the next pages).

Thus, the solution based on limit/offset is not perfect, but may suffice most of the cases and have a good simplicity tradeoff. So, it is probably "the best of the worse" solution. But this point is still opened.

[TJ] I understand the scalability aspect.
On the other hand, NGSI systems who do not have the information ready in a database but need to assemble it from various sources anyway somehow have to cache the query result when it is retrieved page by page, as otherwise they would have to run the same queries on the subsystem again and again.
>From this point of view the question is whether clients should have separate control on data generation and on data retrieval, or if this difference should be transparent to applications. To be discussed.


[FGM5] I agree that pagination in a distributed context (as the architecture based on CB + CPrs is) is hard. We have been discussing about it at https://github.com/telefonicaid/fiware-orion/issues/847 long time, but without having found a perfect solution.

Best regards,

------
Fermín

________________________________

Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.

The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.

Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fiware.org/private/fiware-ngsi/attachments/20150706/5af9ae98/attachment.html>


More information about the Fiware-ngsi mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy