% for user, config in sorted(node.metadata.get('icinga2/api_users', {}).items()):
object ApiUser "${user}" {
    password = "${config['password']}"
    permissions = [ "${'", "'.join(sorted(config['permissions']))}" ]
}

% endfor
