mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Pass in the config_entry in azure_devops coordinator init (#137722)
explicitly pass in the config_entry in azure_devops coordinator init
This commit is contained in:
parent
9a202b5e56
commit
2eb6a03640
@ -9,9 +9,7 @@ from homeassistant.const import Platform
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import CONF_PAT, CONF_PROJECT
|
from .const import CONF_PAT, CONF_PROJECT
|
||||||
from .coordinator import AzureDevOpsDataUpdateCoordinator
|
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
|
||||||
|
|
||||||
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -22,11 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AzureDevOpsConfigEntry)
|
|||||||
"""Set up Azure DevOps from a config entry."""
|
"""Set up Azure DevOps from a config entry."""
|
||||||
|
|
||||||
# Create the data update coordinator
|
# Create the data update coordinator
|
||||||
coordinator = AzureDevOpsDataUpdateCoordinator(
|
coordinator = AzureDevOpsDataUpdateCoordinator(hass, entry, _LOGGER)
|
||||||
hass,
|
|
||||||
_LOGGER,
|
|
||||||
entry=entry,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Store the coordinator in runtime data
|
# Store the coordinator in runtime data
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
@ -28,6 +28,8 @@ from .data import AzureDevOpsData
|
|||||||
BUILDS_QUERY: Final = "?queryOrder=queueTimeDescending&maxBuildsPerDefinition=1"
|
BUILDS_QUERY: Final = "?queryOrder=queueTimeDescending&maxBuildsPerDefinition=1"
|
||||||
IGNORED_CATEGORIES: Final[list[Category]] = [Category.COMPLETED, Category.REMOVED]
|
IGNORED_CATEGORIES: Final[list[Category]] = [Category.COMPLETED, Category.REMOVED]
|
||||||
|
|
||||||
|
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
|
||||||
|
|
||||||
|
|
||||||
def ado_exception_none_handler(func: Callable) -> Callable:
|
def ado_exception_none_handler(func: Callable) -> Callable:
|
||||||
"""Handle exceptions or None to always return a value or raise."""
|
"""Handle exceptions or None to always return a value or raise."""
|
||||||
@ -50,28 +52,29 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
|
|||||||
"""Class to manage and fetch Azure DevOps data."""
|
"""Class to manage and fetch Azure DevOps data."""
|
||||||
|
|
||||||
client: DevOpsClient
|
client: DevOpsClient
|
||||||
|
config_entry: AzureDevOpsConfigEntry
|
||||||
organization: str
|
organization: str
|
||||||
project: Project
|
project: Project
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: AzureDevOpsConfigEntry,
|
||||||
logger: logging.Logger,
|
logger: logging.Logger,
|
||||||
*,
|
|
||||||
entry: ConfigEntry,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize global Azure DevOps data updater."""
|
"""Initialize global Azure DevOps data updater."""
|
||||||
self.title = entry.title
|
self.title = config_entry.title
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
logger=logger,
|
logger=logger,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=300),
|
update_interval=timedelta(seconds=300),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.client = DevOpsClient(session=async_get_clientsession(hass))
|
self.client = DevOpsClient(session=async_get_clientsession(hass))
|
||||||
self.organization = entry.data[CONF_ORG]
|
self.organization = config_entry.data[CONF_ORG]
|
||||||
|
|
||||||
@ado_exception_none_handler
|
@ado_exception_none_handler
|
||||||
async def authorize(
|
async def authorize(
|
||||||
|
@ -21,8 +21,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from . import AzureDevOpsConfigEntry
|
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
|
||||||
from .coordinator import AzureDevOpsDataUpdateCoordinator
|
|
||||||
from .entity import AzureDevOpsEntity
|
from .entity import AzureDevOpsEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user