def get(self, id): context = request.environ.get('context') try: cell_obj = dbapi.cells_get_by_id(context, id) except exceptions.NotFound: return self.error_response(404, 'Not Found') except Exception as err: LOG.error("Error during Cell get by id: %s" % err) return self.error_response(500, 'Unknown Error') cell_obj.data = cell_obj.variables cell = jsonutils.to_primitive(cell_obj) return cell, 200, None
def get(self, context, region_id, filters): """Get cells for the region, with optional filtering.""" if 'name' in filters: cell_obj = dbapi.cells_get_by_name(context, region_id, filters['name']) cell_obj.data = cell_obj.variables cells_obj = [cell_obj] elif 'id' in filters: cell_obj = dbapi.cells_get_by_id(context, filters['id']) cell_obj.data = cell_obj.variables cells_obj = [cell_obj] else: cells_obj = dbapi.cells_get_all(context, region_id) return jsonutils.to_primitive(cells_obj), 200, None
def get(self, context, region_id, filters): """Get cells for the region, with optional filtering.""" if 'name' in filters: cell_obj = dbapi.cells_get_by_name( context, region_id, filters['name']) cell_obj.data = cell_obj.variables cells_obj = [cell_obj] elif 'id' in filters: cell_obj = dbapi.cells_get_by_id(context, filters['id']) cell_obj.data = cell_obj.variables cells_obj = [cell_obj] else: cells_obj = dbapi.cells_get_all(context, region_id) return jsonutils.to_primitive(cells_obj), 200, None
def get(self): """Get cell(s) for the project. Get cell details if for a particular region. """ region = g.args["region"] cell_name = g.args["name"] cell_id = g.args["id"] context = request.environ.get('context') if not region: msg = "`region` is required to get cells" return self.error_response(400, msg) if region and cell_name: # Get this particular cell along with its data try: cell_obj = dbapi.cells_get_by_name(context, region, cell_name) except exceptions.NotFound: return self.error_response(404, 'Not Found') except Exception as err: LOG.error("Error during cells get: %s" % err) return self.error_response(500, 'Unknown Error') cell_obj.data = cell_obj.variables cell = jsonutils.to_primitive(cell_obj) return [cell], 200, None if region and cell_id: # Get this particular cell along with its data try: cell_obj = dbapi.cells_get_by_id(context, cell_id) except exceptions.NotFound: return self.error_response(404, 'Not Found') except Exception as err: LOG.error("Error during cells get: %s" % err) return self.error_response(500, 'Unknown Error') cell_obj.data = cell_obj.variables cell = jsonutils.to_primitive(cell_obj) return [cell], 200, None # No cell id or name so get all cells for this region only try: cells_obj = dbapi.cells_get_all(context, region) cells = jsonutils.to_primitive(cells_obj) return cells, 200, None except exceptions.NotFound: return self.error_response(404, 'Not Found')
def get(self, id): """Get data for given cell.""" context = request.environ.get('context') obj = dbapi.cells_get_by_id(context, id) resp = {"data": jsonutils.to_primitive(obj.variables)} return resp, 200, None
def get(self, id): context = request.environ.get('context') cell_obj = dbapi.cells_get_by_id(context, id) cell_obj.data = cell_obj.variables cell = jsonutils.to_primitive(cell_obj) return cell, 200, None
def get(self, context, id, request_args): cell_obj = dbapi.cells_get_by_id(context, id) cell = utils.get_resource_with_vars(request_args, cell_obj) return cell, 200, None