Modify rest api endpoint from verb to noun

Viewed 18

I have a some rest end points...That look like this

PUT --> /container/{vendorID}/{pluginID}/{containerName}/start
PUT --> /container/{vendorID}/{pluginID}/{containerName}/restart
PUT --> /container/{vendorID}/{pluginID}/{containerName}/stop

I see that start, stop are kind of actions/verbs. Now sure how to convert them into the nouns.

Looking for some suggestions.

1 Answers

I see that start, stop are kind of actions/verbs. Now sure how to convert them into the nouns.

Recognize that resources are generalizations of documents. We are triggering useful work as a side effect of manipulating these documents. See Webber 2011.

The "nouns" are the names of the documents.

There are lots of possible ways you might design your documents (aka your "resource model"). You might have a single start document for a container. You might have a different start document for each occasion you want to start it. You might have a schedule for each container, and you edit the schedule indicating when you want things to start. You might just have a single document for the container itself, and edit that.

A thing to keep in mind is that REST/HTTP care a lot about caching, so you should pay attention to the rules for cache invalidation; general purpose HTTP components today don't support invalidation of arbitrary resources, so you may want to consider these limits as you design your resource model.

Related