[WIP] data structures for resources

This PR introduced some data structure to represent resources.
Yes, I was intended to put it in api. But thought it may be better to put in a separate file, discuss it here and move it into api later. I'll do it today.