def _rule_to_post_data(rule):
    post_data = {}
    post_data['ruleType'] = rule['ruleType']

    if 'filter' in rule:
        filter = rule['filter']
        if 'httpProtocol' in filter:
            post_data['filterProtocol'] = filter['httpProtocol']
        if 'method' in filter:
            post_data['filterMethod'] = filter['method']
        if 'url' in filter:
            post_data['filterUrl'] = filter['url']
        if 'statusCode' in filter:
            post_data['filterstatusCode'] = filter['statusCode']

    if 'action' in rule:
        action = rule['action']
        if 'type' in action:
            post_data['actionType'] = action['type']
        if 'httpProtocol' in action:
            post_data['actionProtocol'] = action['httpProtocol']
        if 'method' in action:
            post_data['actionMethod'] = action['method']
        if 'url' in action:
            post_data['actionUrl'] = action['url']
        if 'statusCode' in action:
            post_data['actionStatusCode'] = action['statusCode']
        if 'statusDescription' in action:
            post_data['actionStatusDescription'] = action['statusDescription']
        if 'payload' in action:
            post_data['actionPayload'] = action['payload']
        if 'setHeaders' in action:
            action['headers'] = action.pop('setHeaders')
    return post_data
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/webui/views/rule.py/_rule_to_post_data/original