[%-
json = '';

IF !c.user_exists;
    IF c.stash.ngcp_api_realm == "subscriber";
        json_file = "/etc/ngcp-defaults/csc_defaults_public.json";
    ELSE;
        json_file = "/etc/ngcp-defaults/admin_defaults_public.json";
    END;
ELSE;
    IF c.user.roles == 'subscriber' || c.user.roles == 'subscriberadmin';
        json_file = "/etc/ngcp-defaults/csc_defaults_private.json";
    ELSE;
        json_file = "/etc/ngcp-defaults/admin_defaults_private.json";
    END;
END;

TRY;
    IF !c.user_exists;
        INCLUDE $json_file;
    ELSE;
        json = c.stash.process_json_file_cb(json_file);
    END;
CATCH;
    json = '{"error": "an internal error when fetching the config data"}';
END;

json;

-%]
