diff --git a/homeassistant/brands/google.json b/homeassistant/brands/google.json index 460c92076d8..028fa544a5f 100644 --- a/homeassistant/brands/google.json +++ b/homeassistant/brands/google.json @@ -5,7 +5,6 @@ "google_assistant", "google_assistant_sdk", "google_cloud", - "google_domains", "google_generative_ai_conversation", "google_mail", "google_maps", diff --git a/homeassistant/components/google_domains/__init__.py b/homeassistant/components/google_domains/__init__.py deleted file mode 100644 index a4dcef62964..00000000000 --- a/homeassistant/components/google_domains/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -"""Support for Google Domains.""" - -import asyncio -from datetime import timedelta -import logging - -import aiohttp -import voluptuous as vol - -from homeassistant.const import CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME -from homeassistant.core import HomeAssistant -from homeassistant.helpers.aiohttp_client import async_get_clientsession -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.event import async_track_time_interval -from homeassistant.helpers.typing import ConfigType - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = "google_domains" - -INTERVAL = timedelta(minutes=5) - -DEFAULT_TIMEOUT = 10 - -CONFIG_SCHEMA = vol.Schema( - { - DOMAIN: vol.Schema( - { - vol.Required(CONF_DOMAIN): cv.string, - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int, - } - ) - }, - extra=vol.ALLOW_EXTRA, -) - - -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Initialize the Google Domains component.""" - domain = config[DOMAIN].get(CONF_DOMAIN) - user = config[DOMAIN].get(CONF_USERNAME) - password = config[DOMAIN].get(CONF_PASSWORD) - timeout = config[DOMAIN].get(CONF_TIMEOUT) - - session = async_get_clientsession(hass) - - result = await _update_google_domains( - hass, session, domain, user, password, timeout - ) - - if not result: - return False - - async def update_domain_interval(now): - """Update the Google Domains entry.""" - await _update_google_domains(hass, session, domain, user, password, timeout) - - async_track_time_interval(hass, update_domain_interval, INTERVAL) - - return True - - -async def _update_google_domains(hass, session, domain, user, password, timeout): - """Update Google Domains.""" - url = f"https://{user}:{password}@domains.google.com/nic/update" - - params = {"hostname": domain} - - try: - async with asyncio.timeout(timeout): - resp = await session.get(url, params=params) - body = await resp.text() - - if body.startswith(("good", "nochg")): - return True - - _LOGGER.warning("Updating Google Domains failed: %s => %s", domain, body) - - except aiohttp.ClientError: - _LOGGER.warning("Can't connect to Google Domains API") - - except TimeoutError: - _LOGGER.warning("Timeout from Google Domains API for domain: %s", domain) - - return False diff --git a/homeassistant/components/google_domains/manifest.json b/homeassistant/components/google_domains/manifest.json deleted file mode 100644 index 83d9320e818..00000000000 --- a/homeassistant/components/google_domains/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "domain": "google_domains", - "name": "Google Domains", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/google_domains", - "iot_class": "cloud_polling" -} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index d43a2aec5a2..2972aabbbfc 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -2280,12 +2280,6 @@ "iot_class": "cloud_push", "name": "Google Cloud" }, - "google_domains": { - "integration_type": "hub", - "config_flow": false, - "iot_class": "cloud_polling", - "name": "Google Domains" - }, "google_generative_ai_conversation": { "integration_type": "service", "config_flow": true, diff --git a/tests/components/google_domains/__init__.py b/tests/components/google_domains/__init__.py deleted file mode 100644 index 3466a3be489..00000000000 --- a/tests/components/google_domains/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the google_domains component.""" diff --git a/tests/components/google_domains/test_init.py b/tests/components/google_domains/test_init.py deleted file mode 100644 index bb27cf7b483..00000000000 --- a/tests/components/google_domains/test_init.py +++ /dev/null @@ -1,85 +0,0 @@ -"""Test the Google Domains component.""" - -from datetime import timedelta - -import pytest - -from homeassistant.components import google_domains -from homeassistant.core import HomeAssistant -from homeassistant.setup import async_setup_component -from homeassistant.util.dt import utcnow - -from tests.common import async_fire_time_changed -from tests.test_util.aiohttp import AiohttpClientMocker - -DOMAIN = "test.example.com" -USERNAME = "abc123" -PASSWORD = "xyz789" - -UPDATE_URL = f"https://{USERNAME}:{PASSWORD}@domains.google.com/nic/update" - - -@pytest.fixture -def setup_google_domains( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker -) -> None: - """Fixture that sets up NamecheapDNS.""" - aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="ok 0.0.0.0") - - hass.loop.run_until_complete( - async_setup_component( - hass, - google_domains.DOMAIN, - { - "google_domains": { - "domain": DOMAIN, - "username": USERNAME, - "password": PASSWORD, - } - }, - ) - ) - - -async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None: - """Test setup works if update passes.""" - aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nochg 0.0.0.0") - - result = await async_setup_component( - hass, - google_domains.DOMAIN, - { - "google_domains": { - "domain": DOMAIN, - "username": USERNAME, - "password": PASSWORD, - } - }, - ) - assert result - assert aioclient_mock.call_count == 1 - - async_fire_time_changed(hass, utcnow() + timedelta(minutes=5)) - await hass.async_block_till_done() - assert aioclient_mock.call_count == 2 - - -async def test_setup_fails_if_update_fails( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker -) -> None: - """Test setup fails if first update fails.""" - aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nohost") - - result = await async_setup_component( - hass, - google_domains.DOMAIN, - { - "google_domains": { - "domain": DOMAIN, - "username": USERNAME, - "password": PASSWORD, - } - }, - ) - assert not result - assert aioclient_mock.call_count == 1