### Taking gcd with respect to one variable

I want to compute $$ gcd_{X}((X-y)^2 -a , ~~X^{q-1}-1)$$ ~~X^{\frac{q-1}{2}}-1)$$ with respect to X(taking y as a field constant).

I can't see any direct implementation of this in sage. Can any one suggest how to implement it.

Here Arithmetic is over $GF(p)$ and y is root of cyclotomic polynomial of degree r over $GF(p)$ and $q = p^r$