jeudi 5 septembre 2019

Push massive data through subsequent calls to HTTP API: verb to commit operation

I'm going to implement a set of APIs to enable a client to push a large dataset to a server through HTTP calls.

Attempting to be REST-compliant, I designed my API so that if a set of resources is available at the (relative) URL:

/myEntities

the following calls are provided:

   POST /myEntities/Partials
  • create a new partial resource and returns its Id
   PATCH /myEntities/Partials/{id}
  • send a subset of the whole dataset, according to the Id retrieved (created) previously
   DELETE /myEntities/Partials/{id}
  • notify the server that the whole set of data has been sent. By receiving this call, the server performs calculations and restructuring of all the partial data received, deletes all myEntities and replace them with the newly calculated structure. After that, it deletes all partial data related to the specified id

I'm not really happy with the last call, as, despite the verb (DELETE), it not only deletes a set of (partial) resources, but it also creates new (complete) resources.

I also thought to replace the last call with something like:

   POST /myEntities (requires {id} as parameter in the body)

This way, the problem is just reverted: verb (POST) not only creates a new set of resources, but it also deletes a set of partial ones.

I wonder if there is a correct verb to perform such an atomic operation of creating a new set of entities and removing partial ones.

Related question: How to design HTTP API to push massive data?

Aucun commentaire:

Enregistrer un commentaire