def serialize_rules(self, rules):
<EOL>serialized = []<EOL>for rule in rules:<EOL><INDENT>direction = rule["<STR_LIT>"]<EOL>source = '<STR_LIT>'<EOL>destination = '<STR_LIT>'<EOL>if rule.get("<STR_LIT>"):<EOL><INDENT>prefix = rule["<STR_LIT>"]<EOL>if direction == "<STR_LIT>":<EOL><INDENT>source = self._convert_remote_network(prefix)<EOL><DEDENT>else:<EOL><INDENT>if (Capabilities.EGRESS not in<EOL>CONF.QUARK.environment_capabilities):<EOL><INDENT>raise q_exc.EgressSecurityGroupRulesNotEnabled()<EOL><DEDENT>else:<EOL><INDENT>destination = self._convert_remote_network(prefix)<EOL><DEDENT><DEDENT><DEDENT>optional_fields = {}<EOL>protocol_map = protocols.PROTOCOL_MAP[rule["<STR_LIT>"]]<EOL>if rule["<STR_LIT>"] == protocol_map["<STR_LIT>"]:<EOL><INDENT>optional_fields["<STR_LIT>"] = rule["<STR_LIT>"]<EOL>optional_fields["<STR_LIT>"] = rule["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>optional_fields["<STR_LIT>"] = rule["<STR_LIT>"]<EOL>optional_fields["<STR_LIT>"] = rule["<STR_LIT>"]<EOL><DEDENT>payload = {"<STR_LIT>": rule["<STR_LIT>"],<EOL>"<STR_LIT>": rule["<STR_LIT>"],<EOL>"<STR_LIT>": source,<EOL>"<STR_LIT>": destination,<EOL>"<STR_LIT:action>": "<STR_LIT>",<EOL>"<STR_LIT>": direction}<EOL>payload.update(optional_fields)<EOL>serialized.append(payload)<EOL><DEDENT>return serialized<EOL>
Creates a payload for the redis server.