Search code examples
onem2m

QueryString Structure of a Conditial Retrieve in OneM2M?


This is an example resource tree.

I need to retrieve latest 48 hours' data of cnt-2 and cnt-0 all together. What kind of query string should I put to the request ?

/in-cse
   /in-cse/ae-123
      /in-cse/cnt-2
         /in-cse/cin-21
         /in-cse/cin-22
         /in-cse/cin-23
   /in-cse/ae-124
      /in-cse/cnt-0
         /in-cse/cin-01
         /in-cse/cin-02
         /in-cse/cin-03
      /in-cse/cnt-1
         /in-cse/cin-11
         /in-cse/cin-22
         /in-cse/cin-33

Where should I put the ids of cnt-0 and cnt-2 in the querystring ?

/onem2m/api/v1/~/in-cse?fu=2&crb=20190808T000000&cra=20190806T000000&ty=4

Also should I use only querystring to make discovery or is it valid to make a POST request ?


Solution

  • With the example request in your question you will also get all the matching <contentInstance> resources of cnt-1, because you do the discovery on the level of the IN-CSE. Unfortunately, you cannot have multiple targets in a single request, but I see at least two solutions that could work for your use case:

    • You can add labels two <contentInstance> resources and add label to your search.
      /onem2m/api/v1/~/in-cse?fu=2&crb=20190808T000000&cra=20190806T000000&label=myLabel&ty=4
    • You can add a <group> that contains the <container> resources that are important to your use case (ie. cnt-0 and cnt-2) and make the <group>'s fanoutPoint the target of your discovery request. The CSE is then responsible to redirect the discovery to each member of the <group>.
      /onem2m/api/v1/~/in-cse/aGroup/fopt?fu=2&crb=20190808T000000&cra=20190806T000000&ty=4

    In my opinion the second method is the more "elegant" one because it makes the (application) relationship of the two <container> resources clearer , but the first one might also be feasible if your <contentInstance> resources are tagged using labels anyway.

    Regarding the POST request: For the HTTP binding query parameters are only allowed for filtering and discovery. Please have a look at TS-0009, section 6.2.2.2 Query component.

    Btw, there are currently ongoing discussions in oneM2M to describe the differences between retrieval and discovery a bit better.