cdupont
cdupont

Reputation: 1188

FIWARE Orion: How to retrieve the servicePath of an entity?

How to retrieve the servicePath of an entity given its ID?

I also have some design questions about the service path:

So all in all, it is advised to use service path at all?

Thanks

Upvotes: 1

Views: 317

Answers (2)

fgalan
fgalan

Reputation: 12294

I'll try to answer your questions inline, as a complement to the answer already provided by @Dalton.

How to retrieve the servicePath of an entity given its ID?

Current Orion version (1.7.0) doesn't implement that as part of the API. It assumes that the client application already knows which service path to use. However, it has been identified as part of a future enhancement.

Note that the opposite is possible, i.e. to retrieve all the entities given a servicePath. For instance:

GET /v2/entities
Fiware-ServicePath: /A

why is it implemented as an HTTP header? It would be simpler if it was an attribute.

Because it is aimed at being a cross-GE multitenancy mechanism in FIWARE. Note the concept of "attribute" is meaningful for Orion Context Broker, but other GEs use different concepts. Using an HTTP header keeps the same mechanism for all FIWARE GEs in an API-agnostic way.

Disclaimer: having said that, note the it is aimed at being above, instead of it is. I mean, I'm not sure how others GEs (apart from Orion) are implementing this in FIWARE at the present moment.

the usage seems to be broken: for example I can GET an entity using the default service path, but then I cannot DELETE it because it might belong to a different service path.

the API is not explorable: I can discover an entity, but then I cannot do anything on it because I don't know its service path.

As mentioned above, current implementation assumes that the client application already knows which service path to use. Taking that into account, I understand that the problem you mention in the above two questions would not occur.

So all in all, it is advised to use service path at all?

It depends on the use case. If you can assume that the client application already knows which service path to use or there is an implicit service path structure in place (e.g. your services paths are the cities in Spain, /Madrid, /Barcelona, etc.) then it can be an interesting way of structuring you context information.

More information on service paths can be found in the Orion Context Broker documentation.

Upvotes: 1

Dalton Cézane
Dalton Cézane

Reputation: 3782

I think it is not possible, as you can see in Multitenancy section of this presentation.

Besides, you can have the same Entity ID for different Fiware-Services and Fiware-ServicePaths.

Attributes are flexible. Fiware-Service and Fiware-ServicePath are mandatory when you need to separate things (like Projects and Domains of OpenStack).

If you create an entity with Fiware-Service and Fiware-ServicePath, you need to specify those headers when doing GET and DELETE operations. If you get something different from this, I guess maybe you are doing something strange or missing something.

It is supposed that when you use Fiware-Service and Fiware-ServicePath your application already know this information. So, you do not have to discover it. Just use for the right entity with the right Fiware-Service and Fiware-ServicePath headers.

I hope this can help you. @fgalan , please correct me if I answered something wrong.

Upvotes: 2

Related Questions