mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Upgrade aioazuredevops to 2.0.0 (#114537)
* Upgrade aioazuredevops to 2.0.0 * Refactor Azure DevOps config flow to use async_get_clientsession * Wrap conditional in parentesis
This commit is contained in:
parent
2e11a61726
commit
429b5d22cf
@ -16,6 +16,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||||
from homeassistant.helpers.entity import EntityDescription
|
from homeassistant.helpers.entity import EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
@ -43,7 +44,8 @@ class AzureDevOpsEntityDescription(EntityDescription):
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Azure DevOps from a config entry."""
|
"""Set up Azure DevOps from a config entry."""
|
||||||
client = DevOpsClient()
|
aiohttp_session = async_get_clientsession(hass)
|
||||||
|
client = DevOpsClient(session=aiohttp_session)
|
||||||
|
|
||||||
if entry.data.get(CONF_PAT) is not None:
|
if entry.data.get(CONF_PAT) is not None:
|
||||||
await client.authorize(entry.data[CONF_PAT], entry.data[CONF_ORG])
|
await client.authorize(entry.data[CONF_PAT], entry.data[CONF_ORG])
|
||||||
@ -62,7 +64,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Fetch data from Azure DevOps."""
|
"""Fetch data from Azure DevOps."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await client.get_builds(
|
builds = await client.get_builds(
|
||||||
entry.data[CONF_ORG],
|
entry.data[CONF_ORG],
|
||||||
entry.data[CONF_PROJECT],
|
entry.data[CONF_PROJECT],
|
||||||
BUILDS_QUERY,
|
BUILDS_QUERY,
|
||||||
@ -70,6 +72,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
except aiohttp.ClientError as exception:
|
except aiohttp.ClientError as exception:
|
||||||
raise UpdateFailed from exception
|
raise UpdateFailed from exception
|
||||||
|
|
||||||
|
if builds is None:
|
||||||
|
raise UpdateFailed("No builds found")
|
||||||
|
|
||||||
|
return builds
|
||||||
|
|
||||||
coordinator = DataUpdateCoordinator(
|
coordinator = DataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
@ -10,6 +10,7 @@ import aiohttp
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
|
from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Check the setup of the flow."""
|
"""Check the setup of the flow."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
client = DevOpsClient()
|
aiohttp_session = async_get_clientsession(self.hass)
|
||||||
|
client = DevOpsClient(session=aiohttp_session)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._pat is not None:
|
if self._pat is not None:
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/azure_devops",
|
"documentation": "https://www.home-assistant.io/integrations/azure_devops",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["aioazuredevops"],
|
"loggers": ["aioazuredevops"],
|
||||||
"requirements": ["aioazuredevops==1.4.3"]
|
"requirements": ["aioazuredevops==2.0.0"]
|
||||||
}
|
}
|
||||||
|
@ -39,19 +39,23 @@ async def async_setup_entry(
|
|||||||
AzureDevOpsSensor(
|
AzureDevOpsSensor(
|
||||||
coordinator,
|
coordinator,
|
||||||
AzureDevOpsSensorEntityDescription(
|
AzureDevOpsSensorEntityDescription(
|
||||||
key=f"{build.project.id}_{build.definition.id}_latest_build",
|
key=f"{build.project.project_id}_{build.definition.build_id}_latest_build",
|
||||||
translation_key="latest_build",
|
translation_key="latest_build",
|
||||||
translation_placeholders={"definition_name": build.definition.name},
|
translation_placeholders={"definition_name": build.definition.name},
|
||||||
attrs=lambda build: {
|
attrs=lambda build: {
|
||||||
"definition_id": build.definition.id,
|
"definition_id": (
|
||||||
"definition_name": build.definition.name,
|
build.definition.build_id if build.definition else None
|
||||||
"id": build.id,
|
),
|
||||||
|
"definition_name": (
|
||||||
|
build.definition.name if build.definition else None
|
||||||
|
),
|
||||||
|
"id": build.build_id,
|
||||||
"reason": build.reason,
|
"reason": build.reason,
|
||||||
"result": build.result,
|
"result": build.result,
|
||||||
"source_branch": build.source_branch,
|
"source_branch": build.source_branch,
|
||||||
"source_version": build.source_version,
|
"source_version": build.source_version,
|
||||||
"status": build.status,
|
"status": build.status,
|
||||||
"url": build.links.web,
|
"url": build.links.web if build.links else None,
|
||||||
"queue_time": build.queue_time,
|
"queue_time": build.queue_time,
|
||||||
"start_time": build.start_time,
|
"start_time": build.start_time,
|
||||||
"finish_time": build.finish_time,
|
"finish_time": build.finish_time,
|
||||||
|
@ -206,7 +206,7 @@ aioasuswrt==1.4.0
|
|||||||
aioautomower==2024.3.4
|
aioautomower==2024.3.4
|
||||||
|
|
||||||
# homeassistant.components.azure_devops
|
# homeassistant.components.azure_devops
|
||||||
aioazuredevops==1.4.3
|
aioazuredevops==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.baf
|
# homeassistant.components.baf
|
||||||
aiobafi6==0.9.0
|
aiobafi6==0.9.0
|
||||||
|
@ -185,7 +185,7 @@ aioasuswrt==1.4.0
|
|||||||
aioautomower==2024.3.4
|
aioautomower==2024.3.4
|
||||||
|
|
||||||
# homeassistant.components.azure_devops
|
# homeassistant.components.azure_devops
|
||||||
aioazuredevops==1.4.3
|
aioazuredevops==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.baf
|
# homeassistant.components.baf
|
||||||
aiobafi6==0.9.0
|
aiobafi6==0.9.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user