Example #1
0
handle = rules.create_ruleset(
    'rules',
    json.dumps({
        'r1': {
            'whenSome': {
                '$and': [{
                    'amount': 10000
                }, {
                    'subject': 'approve'
                }]
            },
            'run': 'pending'
        }
    }))

rules.delete_ruleset(handle)
print('created rules1')

handle = rules.create_ruleset(
    'rules',
    json.dumps({
        'r1': {
            'when': {
                '$and': [{
                    'amount': 10000
                }, {
                    'subject': 'approve'
                }]
            },
            'run': 'pending'
        }
Example #2
0
}))
rules.assert_event(handle, json.dumps({
    'id': 1,
    'sid': 'first',
    'item': 'book',
    'status': 'available',
    'country': 'US',
    'seller': 'bookstore'
}))
result = rules.start_action(handle)

print(repr(json.loads(result[0])))
print(repr(json.loads(result[1])))

rules.complete_action(handle, result[2], result[0])
rules.delete_ruleset(handle)

print('books2 ******')

handle = rules.create_ruleset(5, 'books2',  json.dumps({
    'ship': {
        'all': [ 
            {'m': {'$and': [
                {'country': 'US'},
                {'seller': 'bookstore'},
                {'currency': 'US'},
                {'$lte': {'amount': 1000}},
            ]}}
        ]
    },
    'order': {