Muditha Sumanathunga even though this is irrelevant to the article, I would like to give you some points related to what you are asking here. According to your requirements, there are 4 operations in your API, such as;
In order to give a proper answer to your question, I would like to think this as a design problem. In Computer Science there are a few key design principles that you may want to look at;
- Separation of concerns is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern.
- Each significant piece of functionality in a program should be implemented in just one place in the source code. Where similar functions are carried out by distinct pieces of code, it is generally beneficial to combine them into one by abstracting out the varying parts.
- Every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. Responsibility can be defined as a reason to change, so a class or module should have one, and only one, a reason to change. (Even though this is relevant to classes or the modules, I believe we can adapt this to function levels as well.)
- The KISS principle is descriptive to keep the code simple and clear which is easy to understand for a human being.
By applying those principles and to my knowledge, in your case, it seems like you have 3 concerns to address such as, Indexing, Compaction and Controlling an Application State(i.e SLEEP, SHUTDOWN, REBOOT etc). Then if I’m to design your API I would have 3 endpoints. Then again it matters with what you are really doing behind the scene of each operation. I hope that answered to your question.