This is a similar way to get from $ds^2 = g_{\mu \nu} dx^{\mu} dx^{\nu}$ to the simpler form, probably more general (using Killing vectors). As you see for the Schwarzschild case, any further constraints on $f(r)$ and $g(r)$ are found by plugging them into the Einstein Field equations