def create_rule_spec(client_factory, rule, operation='add'):
    """Create a ClusterRuleSpec object"""
    rule_spec = client_factory.create('ns0:ClusterRuleSpec')
    rule_spec.operation = operation
    rule_spec.info = rule
    if operation == 'remove':
        rule_spec.removeKey = rule.key
    return rule_spec