class LogicalExprSchema(BaseSchema): """Expression combining multiple other query expressions.""" op = base.String(description="The operator.") # many=True does not work here for some reason. expr = base.List( base.Nested( lambda *a, **kw: ExprSchema(*a, **kw), # pylint: disable=unnecessary-lambda description="A list of query expressions to combine.", ))
class NotExprSchema(BaseSchema): """Expression negating another query expression. Examples: >>> from cmk.utils.livestatus_helpers.tables import Hosts >>> input_expr = {'op': '=', 'left': 'hosts.name', 'right': 'foo'} >>> q = {'op': 'not', 'expr': input_expr} >>> result = NotExprSchema(context={'table': Hosts}).load(q) >>> assert result == q """ op = base.String(description="The operator. In this case `not`.") expr = base.Nested( lambda: ExprSchema(), # pylint: disable=unnecessary-lambda description="The query expression to negate.", )