PUBAPI-1066 - refactor this to something much simpler.
PUBAPI-1066 - refactor this to something much simpler.

joyent/sdc-cloudapi,misterbisson/sdc-cloudapi,KrisShannon/sdc-cloudapi,arekinath/sdc-cloudapi,arekinath/sdc-cloudapi,KrisShannon/sdc-cloudapi,misterbisson/sdc-cloudapi,joyent/sdc-cloudapi