eero-api 8.4.1__tar.gz → 8.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {eero_api-8.4.1/src/eero_api.egg-info → eero_api-8.4.2}/PKG-INFO +1 -1
- {eero_api-8.4.1 → eero_api-8.4.2}/pyproject.toml +2 -2
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/__init__.py +1 -1
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/client.py +99 -3
- {eero_api-8.4.1 → eero_api-8.4.2/src/eero_api.egg-info}/PKG-INFO +1 -1
- {eero_api-8.4.1 → eero_api-8.4.2}/LICENSE +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/README.md +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/setup.cfg +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/setup.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/__init__.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/_params.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/_writes.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/ac_compat.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/account.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/auth.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/auth_storage.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/backup.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/backup_access_points.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/base.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/blacklist.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/burst_reporters.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/data_usage.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/ddns.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/devices.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/dhcp.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/diagnostics.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/dns.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/dns_policies.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/eeros.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/entitlements.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/events.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/forwards.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/insights.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/links.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/members.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/networks.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/notifications.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/ouicheck.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/permissions.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/power_saving.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/profiles.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/reservations.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/routing.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/schedule.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/security.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/sqm.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/subnets.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/support.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/thread.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/transfer.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/updates.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/wan.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/api/wpa3.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/const.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/errors.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/exceptions.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/logging.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero/py.typed +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero_api.egg-info/SOURCES.txt +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero_api.egg-info/dependency_links.txt +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero_api.egg-info/requires.txt +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/src/eero_api.egg-info/top_level.txt +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/tests/test_errors.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/tests/test_exceptions.py +0 -0
- {eero_api-8.4.1 → eero_api-8.4.2}/tests/test_logging.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "eero-api"
|
|
7
|
-
version = "8.4.
|
|
7
|
+
version = "8.4.2"
|
|
8
8
|
description = "Modern async Python client for Eero network management"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -121,7 +121,7 @@ asyncio_mode = "auto"
|
|
|
121
121
|
|
|
122
122
|
[tool.commitizen]
|
|
123
123
|
name = "cz_conventional_commits"
|
|
124
|
-
version = "8.4.
|
|
124
|
+
version = "8.4.2"
|
|
125
125
|
version_files = [
|
|
126
126
|
"pyproject.toml:project.version",
|
|
127
127
|
"src/eero/__init__.py:__version__",
|
|
@@ -9,7 +9,7 @@ import copy
|
|
|
9
9
|
import logging
|
|
10
10
|
import re
|
|
11
11
|
import time
|
|
12
|
-
from typing import Any, Dict, List, Mapping, Optional, Union
|
|
12
|
+
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
|
|
13
13
|
|
|
14
14
|
from aiohttp import ClientSession, ClientTimeout
|
|
15
15
|
|
|
@@ -617,6 +617,18 @@ class EeroClient:
|
|
|
617
617
|
as the account having no networks. Only a successful fallback
|
|
618
618
|
that finds no networks yields a cacheable empty result.
|
|
619
619
|
|
|
620
|
+
/networks lists only the networks the account owns. When it is
|
|
621
|
+
not empty, networks the account administers through eero
|
|
622
|
+
Multi-Admin (listed only on /account) are appended after the
|
|
623
|
+
owned networks, de-duplicated by network id. A fresh cached
|
|
624
|
+
/account response is reused rather than refetched, even when
|
|
625
|
+
``refresh_cache`` is set. If /account cannot be read in this
|
|
626
|
+
path, the owned networks are returned but not cached, and any
|
|
627
|
+
older cached list is dropped, so the next call tries again.
|
|
628
|
+
When ``data.networks`` is the nested ``{"count": N, "data": [...]}``
|
|
629
|
+
container, admin networks are added to its inner list and the
|
|
630
|
+
container keeps its shape.
|
|
631
|
+
|
|
620
632
|
Raises:
|
|
621
633
|
EeroException: If the account fallback fails, e.g.
|
|
622
634
|
``EeroAuthenticationException`` or ``EeroRateLimitException``.
|
|
@@ -627,6 +639,9 @@ class EeroClient:
|
|
|
627
639
|
return cached
|
|
628
640
|
|
|
629
641
|
cache_epoch = self._cache_epoch
|
|
642
|
+
# The entry this read may supersede; _update_cache replaces the entry
|
|
643
|
+
# object, so identity tells whether another call stored a newer one.
|
|
644
|
+
superseded_entry = self._cache.get("networks")
|
|
630
645
|
response = await self._api.networks.get_networks()
|
|
631
646
|
|
|
632
647
|
# Check if response has networks
|
|
@@ -637,6 +652,7 @@ class EeroClient:
|
|
|
637
652
|
elif isinstance(data, dict):
|
|
638
653
|
networks = data.get("networks") or data.get("data") or []
|
|
639
654
|
|
|
655
|
+
cacheable = True
|
|
640
656
|
# If /networks returns empty, fall back to /account endpoint
|
|
641
657
|
if not networks:
|
|
642
658
|
_LOGGER.debug("Networks endpoint returned empty, falling back to account endpoint")
|
|
@@ -648,8 +664,22 @@ class EeroClient:
|
|
|
648
664
|
"meta": response.get("meta", {}),
|
|
649
665
|
"data": {"networks": networks},
|
|
650
666
|
}
|
|
651
|
-
|
|
652
|
-
|
|
667
|
+
else:
|
|
668
|
+
# /networks lists only networks the account owns; networks it
|
|
669
|
+
# administers through eero Multi-Admin appear only on /account.
|
|
670
|
+
response, cacheable = await self._merge_admin_networks(response, networks)
|
|
671
|
+
|
|
672
|
+
if cacheable:
|
|
673
|
+
self._update_cache("networks", None, response, epoch=cache_epoch)
|
|
674
|
+
elif self._cache.get("networks") is superseded_entry:
|
|
675
|
+
# This read could not consult /account, so its result may be
|
|
676
|
+
# incomplete. Drop the older entry it was meant to replace (for
|
|
677
|
+
# example when refresh_cache was set) so the next call retries
|
|
678
|
+
# /account; an entry another call stored meanwhile is left alone.
|
|
679
|
+
# Remove the entry rather than zeroing its timestamp: freshness is
|
|
680
|
+
# measured against time.monotonic(), which on a recently booted
|
|
681
|
+
# host can still be within the cache timeout of 0.
|
|
682
|
+
self._cache.pop("networks", None)
|
|
653
683
|
|
|
654
684
|
# Set preferred network ID if not already set
|
|
655
685
|
if not self._preferred_network_id:
|
|
@@ -694,6 +724,72 @@ class EeroClient:
|
|
|
694
724
|
networks_data = networks_data.get("data")
|
|
695
725
|
return networks_data if isinstance(networks_data, list) else []
|
|
696
726
|
|
|
727
|
+
@staticmethod
|
|
728
|
+
def _network_key(network: Any) -> Optional[str]:
|
|
729
|
+
"""Identify a network entry by its ``id``, or the last segment of its ``url``."""
|
|
730
|
+
if not isinstance(network, dict):
|
|
731
|
+
return None
|
|
732
|
+
net_id = network.get("id")
|
|
733
|
+
if net_id is None and isinstance(network.get("url"), str):
|
|
734
|
+
net_id = network["url"].rstrip("/").split("/")[-1] or None
|
|
735
|
+
return str(net_id) if net_id is not None else None
|
|
736
|
+
|
|
737
|
+
async def _merge_admin_networks(
|
|
738
|
+
self, response: Dict[str, Any], networks: Union[List[Any], Dict[str, Any]]
|
|
739
|
+
) -> Tuple[Dict[str, Any], bool]:
|
|
740
|
+
"""Append networks listed on ``/account`` but missing from ``/networks``.
|
|
741
|
+
|
|
742
|
+
``/networks`` returns only the networks the account owns. Networks the
|
|
743
|
+
account was invited to as an admin are listed only on ``/account``, so
|
|
744
|
+
without this they never appear. The owned networks keep their place at
|
|
745
|
+
the front, which leaves auto-selection of the preferred network as it
|
|
746
|
+
was. A fresh cached ``/account`` response is reused to stay within the
|
|
747
|
+
rate limit. If ``/account`` cannot be read, the ``/networks`` result
|
|
748
|
+
is returned unchanged rather than failing a read that succeeded, and
|
|
749
|
+
is flagged as not cacheable because it may be missing networks.
|
|
750
|
+
|
|
751
|
+
Args:
|
|
752
|
+
response: Raw, non-empty ``/networks`` response.
|
|
753
|
+
networks: The network listing extracted from ``response``: a list,
|
|
754
|
+
or the nested ``{"count": N, "data": [...]}`` container.
|
|
755
|
+
|
|
756
|
+
Returns:
|
|
757
|
+
A ``(response, cacheable)`` tuple: ``response`` with any
|
|
758
|
+
admin-only networks appended to its list, and whether it is
|
|
759
|
+
complete enough to cache. A nested container keeps its shape.
|
|
760
|
+
"""
|
|
761
|
+
# data["networks"] may be the nested {"count": N, "data": [...]}
|
|
762
|
+
# container (see wiki/Raw-Response-Format.md); merge into its list.
|
|
763
|
+
container = networks if isinstance(networks, dict) else None
|
|
764
|
+
owned = container.get("data") if container is not None else networks
|
|
765
|
+
if not isinstance(owned, list):
|
|
766
|
+
return response, True
|
|
767
|
+
|
|
768
|
+
try:
|
|
769
|
+
account_response = await self.get_account()
|
|
770
|
+
except EeroException as exc:
|
|
771
|
+
_LOGGER.debug("Could not read /account to find admin networks: %s", exc)
|
|
772
|
+
return response, False
|
|
773
|
+
|
|
774
|
+
seen = {key for key in map(self._network_key, owned) if key is not None}
|
|
775
|
+
extra = []
|
|
776
|
+
for network in self._networks_from_account(account_response):
|
|
777
|
+
key = self._network_key(network)
|
|
778
|
+
if key is None or key in seen:
|
|
779
|
+
continue
|
|
780
|
+
seen.add(key)
|
|
781
|
+
extra.append(network)
|
|
782
|
+
if not extra:
|
|
783
|
+
return response, True
|
|
784
|
+
|
|
785
|
+
merged = owned + extra
|
|
786
|
+
listing = {**container, "data": merged} if container is not None else merged
|
|
787
|
+
data = response.get("data")
|
|
788
|
+
if isinstance(data, dict):
|
|
789
|
+
list_key = "networks" if data.get("networks") else "data"
|
|
790
|
+
return {**response, "data": {**data, list_key: listing}}, True
|
|
791
|
+
return {**response, "data": listing}, True
|
|
792
|
+
|
|
697
793
|
async def get_network(
|
|
698
794
|
self, network_id: Optional[str] = None, refresh_cache: bool = False
|
|
699
795
|
) -> Dict[str, Any]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|