I am creating a RESTful web service that has the usual taste of CRUD operations for a set of data types. The mappings of the HTTP verbs for these APIs are obvious.
The interesting part is that the client can request that a long-term (i.e. hourly) operation be launched with one of the data objects; operation status is reported by querying the data type itself.
For example, suppose an object with the following characteristics:
SomeDataType
{
Name: "Some name",
CurrentOperation: "LongOperationA",
CurrentOperationPercent: 0.75,
CurrentOperationEtaSeconds: 3600
}
So my question is, what should be the best RESTful approach to run LongOperationA?
The most obvious approach would seem to make the operation the identifier itself, perhaps something like strings , but it seems a bit awkward, even if I don't specify the data identifier as a query parameter.POST https://my-web-service.com/api/StartLongOperationA?DataID=xxxx
It is also quite trivial to implement this as an idempotent action, so using POSTit seems like a waste; on the other hand, it PUTis inconvenient, because in fact the data is not written to the service.
Has anyone else come across this type of script in their services? What did you do to open up the API to initiate actions that are RESTful compliant?
TIA
-Mark
source
share