Move WebAPIResource and utility methods into webapi/base.py.

This introduces a base.py that contains WebAPIResource, and a bunch of
private utility functions from resources.py. Those have moved into
WebAPIResource as utility functions.