def get_formatted_rule(rule=None):
    """Helper to format the rule into a user friendly format.

    :param dict rule: A dict containing one rule of the firewall
    :returns: a formatted string that get be pushed into the editor
    """
    rule = rule or {}
    return ('action: %s\n'
            'protocol: %s\n'
            'source_ip_address: %s\n'
            'source_ip_subnet_mask: %s\n'
            'destination_ip_address: %s\n'
            'destination_ip_subnet_mask: %s\n'
            'destination_port_range_start: %s\n'
            'destination_port_range_end: %s\n'
            'version: %s\n'
            % (rule.get('action', 'permit'),
               rule.get('protocol', 'tcp'),
               rule.get('sourceIpAddress', 'any'),
               rule.get('sourceIpSubnetMask', '255.255.255.255'),
               rule.get('destinationIpAddress', 'any'),
               rule.get('destinationIpSubnetMask', '255.255.255.255'),
               rule.get('destinationPortRangeStart', 1),
               rule.get('destinationPortRangeEnd', 1),
               rule.get('version', 4)))
def get_formatted_rule ( rule = None ) : rule = rule or { } return ( 'action: %s\n' 'protocol: %s\n' 'source_ip_address: %s\n' 'source_ip_subnet_mask: %s\n' 'destination_ip_address: %s\n' 'destination_ip_subnet_mask: %s\n' 'destination_port_range_start: %s\n' 'destination_port_range_end: %s\n' 'version: %s\n' % ( rule . get ( 'action' , 'permit' ) , rule . get ( 'protocol' , 'tcp' ) , rule . get ( 'sourceIpAddress' , 'any' ) , rule . get ( 'sourceIpSubnetMask' , '255.255.255.255' ) , rule . get ( 'destinationIpAddress' , 'any' ) , rule . get ( 'destinationIpSubnetMask' , '255.255.255.255' ) , rule . get ( 'destinationPortRangeStart' , 1 ) , rule . get ( 'destinationPortRangeEnd' , 1 ) , rule . get ( 'version' , 4 ) ) )
Helper to format the rule into a user friendly format.

    :param dict rule: A dict containing one rule of the firewall
    :returns: a formatted string that get be pushed into the editor