Reusing the index method in the API

I have a tip for some of the developers working on the Katello API. You can add filters to the index action to get back results for a lot of different things. Optimally, the index method ought to be the one place to get back any kind of results for a particular object (although there may be some exceptions).

For instance, suppose you were working on a way to add possible content views to assign to a content host. Instead of making an "available_content_views" method in the content host controller, try using the content_views index. You may have to add a filter or two to get back the results you need but the nice thing is that these filters can help other api users to filter results too. Plus, it helps reduce the number of actions and complexity in our API.

I realize that sometimes it's easier to add an extra action but next time you're in the situation, try giving the index method a try first.