def __init__(self): # Object manager self._objects = ObjectsManager() # Cached data / filters / values self._cache = True self._filters = None self._values = None
class APIExtractor(object): """ Class object used to extract values from the database internal to the APIQuerySet object. """ def __init__(self): # Object manager self._objects = ObjectsManager() # Cached data / filters / values self._cache = True self._filters = None self._values = None def _get(self, obj_type, obj_id=None): """ Worker method for retrieving API objects. """ return self._objects.get(obj_type=obj_type, obj_id=obj_id, cache=self._cache, filters=self._filters, values=self._values) def values(self, values=None): """ Set an query values. """ self._values = values def filter(self, filters=None): """ Set any query filters. """ self._filters = filters def cache(self, toggle=True): """ Enable/disable the cached data flag. """ self._cache = toggle def datacenters(self): """ Extract all datacenter definitions. """ return self._get(obj_type='datacenter') def routers(self): """ Extract all router definitions. """ return self._get(obj_type='net_router')