Whitelist email domain using Rails console

Hi, I need to whitelist an email domain for login. I need to add this domain to the allowlist as described here https://docs.gitlab.com/ee/user/admin_area/settings/sign_up_restrictions.html#create-email-domain-allowlist-or-denylist. I need to do this from the GitLab Rails console (not the website), but I can’t find any documentation about this. Does anyone know if is it possible to do?

It is possible to set domain_allowlist from the API, would that work rather than the rails console?

You would need to have and use an admin user’s access token.