def METHOD_NAME(self):
    try:
        self.log.debug(
            "Connecting to the Unifi Controller Api %s with username %s...",
            self._config.url,
            self._config.user,
        )
        self.api.login()
        self.log.debug("Connected")
    except APIConnectionError:
        self.log.error("Cannot authenticate to Unifi Controller API. The check will not run.")
        self.service_check(
            "can_connect",
            AgentCheck.CRITICAL,
            tags=self._config.tags,
            hostname=None,
        )
        raise