Use Config instead of globals

Converts the API module to use new factory function introduced
in Ieb8549, allowing for proper dependency injection of a Config
instance.

Change-Id: I78cdb5098a6c816f84b3efffeaadf789ca822df7
Merge "Use Config instead of globals"