Page MenuHomePhabricator

REST API for data storage
Open, WishlistPublic

Description

Idea/rational:

  1. We already have REST infrastructure for our MITK Web feature set.
  2. Using this for a well defined REST-API to work with the data storage (locally) would be an easy was to offer better integration in other workflows (e.g. for a python/Matlab module that allows interaction with a data storage of a running MITK instance; as requested by our DLs to easily display and inspect there images)

The API could look something like

(: is indcating a variable in the url that must be replaced with the real value)

GET local/mitk/api1/datastorage

Returns the list of all node urls available in the storage
Possible parameters:

  • ~scope: all (default), toplevel, ...
  • :propertynames : only return the nodes/data with the given property and its value. (e.g. searching for all visible nodes with a certain name: GET local/mitk/api1/datastorage?name=cool_node&visible=true)
GET local/mitk/api1/datastorage/:node[/:subnode [..]]

Returns the data of the specified node. Depending on the requested type/content type only a URI/path is returned where to find the data, or the data is directly serialzed in the content of the message (e.g. the image packed in a nrrd and the nrrd is directly transfered).

GET local/mitk/api1/datastorage/:node[/:subnode [..]]/~children

Returns the list of URLs of all children nodes of a node (if existing).
Possible parameters:

  • :propertynames : only return the nodes/data with the given property and its value. (e.g. searching for all visible nodes with a certain name: GET local/mitk/api1/datastorage?name=cool_node&visible=true)
GET local/mitk/api1/datastorage/:node[/:subnode [..]]/~property

Returns the list of URLs of all properties of the node.
Parameter:

  • context: specifying the context/renderer (default: none/empty)
  • scope: data|node (default node -> so all properties node and data)
GET local/mitk/api1/datastorage/:node[/:subnode [..]]/~property/:propertyname

Returns the value of a property

  • context: specifying the context/renderer (default: none/empty)
  • scope: data|node (default node -> so all properties node and data)
POST local/mitk/api1/datastorage

Transfers the content into the data storage as top level node. Depending on the content of the request (just a URI/filepath or realy the data itself) MITK will load it accordingly.
Returns the URL of the added node.

POST local/mitk/api1/datastorage/:node[/:subnode [..]]/~children

Transfers the content into the data storage and adds it as children to the specified node. Depending on the content of the request (just a URI/filepath or realy the data itself) MITK will load it accordingly.
Returns the URL of the added node.

PUT local/mitk/api1/datastorage/:node[/:subnode [..]]

Transfers the content into the indicated data node either creating it or replacing the data. Depending on the content of the request (just a URI/filepath or realy the data itself) MITK will load it accordingly.

PUT local/mitk/api1/datastorage/:node[/:subnode [..]]/~property/:property_name

Sets a given property to the value in the content.
Parameter:

  • context: specifying the context/renderer (default: none/empty)
  • scope: data|node (default node)
DELETE local/mitk/api1/datastorage/:node[/:subnode [..]]

Removes the given node

Feel free to alter/comment/refine...

Event Timeline

floca added subscribers: gaoh, kalali, nolden.

@gaoh Are there synergies with what you are working on?
@nolden What do you think
@kalali Would that be a project for Jan? It would not be that/only c++ prone and would give him contact with web technologies?

Disclaimer: I am no rest expert so my specification might suck. But I at least tried to draft/outline my ideas. I think it could be realy usefull.

floca added a project: Restricted Project.Mar 4 2020, 9:09 AM

I'm not a REST expert neither but I will look into it.

The current way in the dicomweb-plugin is for GET, is to use with IHE (Invoke Image Display style).
The data is downloaded in a local temp folder (via SendWADO). And the data is then imported to the datanode via mitk::IOUtil::Load()
So basically, apart from listening to incoming IHE GET requests, it is only a DicomWeb client.
But this could be nice, to use MITK also a DicomWeb server. This Rest API could be used to build a wrapper around.
Also, it could be nice in the current implementation of loading the data to use this.

To the API:
Why is there no POST, but only PUT? To create a new node, a POST would be nice, a PUT would be to change a node?
And REMOVE should be called DELETE.

In T27189#195924, @gaoh wrote:

The current way in the dicomweb-plugin is for GET, is to use with IHE (Invoke Image Display style).
The data is downloaded in a local temp folder (via SendWADO). And the data is then imported to the datanode via mitk::IOUtil::Load()
So basically, apart from listening to incoming IHE GET requests, it is only a DicomWeb client.
But this could be nice, to use MITK also a DicomWeb server. This Rest API could be used to build a wrapper around.
Also, it could be nice in the current implementation of loading the data to use this.

Thanks for the update. Where we find synergies it makes sens to use it. But I think it is also no problem to offer different REST (sub)APIs for different purposes. Supporting IHE makes also totaly sense, but is not so close to the storage.

To the API:
Why is there no POST, but only PUT? To create a new node, a POST would be nice,

Because I deemed put more usefull (see below) but it would speak nothing angainst also offering POST. I'll add it.

a PUT would be to change a node?

Nope. Regarding the standard PUT always referes to a document. If this document is not existing it is totaly legal to generate it on the fly. POST basically means, i give you this new content but I dont know where to but it, so put it somewhere and tell me in the response its URL.

And REMOVE should be called DELETE.

Yes you are right. Changed it.

kislinsk triaged this task as Wishlist priority.Mar 16 2020, 3:38 PM
floca moved this task from Backlog to MaaS on the MITK (v2021.10) board.

@gaoh Please help me out. what was the final status of Elisabth's work here? Totaly dropped off the radar.

Oh yes, I also forgot about this, the final state was, as I remember correctly, that she did not succeed in producing meaningful results.

So the last changes in the branch, are basically the changes I made, so that she could modify the code, already used for the dicomweb/kaapana interaction, to simply apply it for this modul. Since it would have been quite similar. I guess, when the changes of the rest module are done: We (AIH-Cluster will take care of restarting the MITK-Kaapana interaction). I think this could be then a not so complicated add-on.

OK. Thanks for the clarification.

Deleted branch from rMITK MITK: feature/T27189-RestApiForDataStorage.

@gaoh gave green light in Slack to delete the branch during a housekeeping effort.