def delete_service(self, name=None, uuid=None): session = db.get_session() q = utils.model_query(models.HashMapService, session) if name: q = q.filter(models.HashMapService.name == name) elif uuid: q = q.filter(models.HashMapService.service_id == uuid) else: raise ValueError('You must specify either name or uuid.') r = q.delete() if not r: raise api.NoSuchService(name, uuid)
def get_service(self, name=None, uuid=None): session = db.get_session() try: q = session.query(models.HashMapService) if name: q = q.filter(models.HashMapService.name == name) elif uuid: q = q.filter(models.HashMapService.service_id == uuid) else: raise ValueError('You must specify either name or uuid.') res = q.one() return res except sqlalchemy.orm.exc.NoResultFound: raise api.NoSuchService(name=name, uuid=uuid)