How do I programmatically create a view whose structure is defined at runtime? I know I am able to create a view programatically here: "How do I programatically create a view?" - only this requires knowing the structure of the view (e.g. which fields / filters / relationships to use) already.  

How can I dynamically create a view at runtime?  Either the view would get stored in the same place as typical views (in the views database) - or it could exist 'In code' except the code is dynamically generated.  E.g. is it possible just to create views ad hoc in hook_views_default_views()?
Ok - no answers and I've figured out two ways to do this.  

1. hook_views_default_views()

One way is to define the view in hook_views_default_views() and then to rest the cache for instance with views_invalidate_cache(). These views end up being 'in code' but not actually set.  This didn't seem like the most desirable method for my use - but might be better for some applications.

2. save the $view

Create the view e.g. $view = new view(); and fill all the fields, and then $view-&gt;save() saves it to the views database. Keeping a record of the name of the view allows you to delete it later if necessary etc.