Remove the Google Domains integration (#127278)

pull/127294/head
Erik Montnemery 2024-10-02 13:58:19 +02:00 committed by GitHub
parent d21d6c2e4a
commit 2fdde24024
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 0 additions and 187 deletions

View File

@ -5,7 +5,6 @@
"google_assistant",
"google_assistant_sdk",
"google_cloud",
"google_domains",
"google_generative_ai_conversation",
"google_mail",
"google_maps",

View File

@ -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

View File

@ -1,7 +0,0 @@
{
"domain": "google_domains",
"name": "Google Domains",
"codeowners": [],
"documentation": "https://www.home-assistant.io/integrations/google_domains",
"iot_class": "cloud_polling"
}

View File

@ -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,

View File

@ -1 +0,0 @@
"""Tests for the google_domains component."""

View File

@ -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