Skip to content

Commit bc6627f

Browse files
committed
update with new url and format
1 parent a57ef2e commit bc6627f

File tree

4 files changed

+161
-115
lines changed

4 files changed

+161
-115
lines changed

aiohasupervisor/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def services(self) -> list[Service]:
5151
async def get_disk_usage(self, max_depth: int = 1) -> DiskUsage:
5252
"""Get disk usage."""
5353
result = await self._client.get(
54-
"host/disk/default/usage",
54+
"host/disks/default/usage",
5555
params={"max_depth": str(max_depth)},
5656
)
5757
return DiskUsage.from_dict(result.data)

aiohasupervisor/models/host.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class ServiceList(ResponseData):
102102
class DiskUsage(ResponseData):
103103
"""DiskUsage model."""
104104

105-
total_space: int | None
106-
used_space: int
107-
children: dict[str, "DiskUsage"] | None
105+
id: str
106+
used_bytes: int
107+
label: str | None = None
108+
total_bytes: int | None = None
109+
children: list["DiskUsage"] | None = None
Lines changed: 106 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,149 @@
11
{
22
"result": "ok",
33
"data": {
4-
"total_space": 503312781312,
5-
"used_space": 430243422208,
6-
"children": {
7-
"addons_data": {
8-
"total_space": null,
9-
"used_space": 42347618720,
10-
"children": {
11-
"77f1785d_remote_api": {
12-
"total_space": null,
13-
"used_space": 2,
4+
"id": "default",
5+
"label": "Default",
6+
"total_bytes": 503312781312,
7+
"used_bytes": 430243422208,
8+
"children": [
9+
{
10+
"id": "addons_data",
11+
"label": "Addons Data",
12+
"used_bytes": 42347618720,
13+
"children": [
14+
{
15+
"id": "77f1785d_remote_api",
16+
"label": "Remote API",
17+
"used_bytes": 2,
1418
"children": null
1519
},
16-
"core_samba": {
17-
"total_space": null,
18-
"used_space": 517,
20+
{
21+
"id": "core_samba",
22+
"label": "Core Samba",
23+
"used_bytes": 517,
1924
"children": null
2025
},
21-
"a0d7b954_plex": {
22-
"total_space": null,
23-
"used_space": 757750613,
26+
{
27+
"id": "a0d7b954_plex",
28+
"label": "Plex",
29+
"used_bytes": 757750613,
2430
"children": null
2531
},
26-
"core_whisper": {
27-
"total_space": null,
28-
"used_space": 560933406,
32+
{
33+
"id": "core_whisper",
34+
"label": "Core Whisper",
35+
"used_bytes": 560933406,
2936
"children": null
3037
}
31-
}
38+
]
3239
},
33-
"addons_config": {
34-
"total_space": null,
35-
"used_space": 5283318814,
36-
"children": {
37-
"core_zwave_js": {
38-
"total_space": null,
39-
"used_space": 258064,
40+
{
41+
"id": "addons_config",
42+
"label": "Addons Config",
43+
"used_bytes": 5283318814,
44+
"children": [
45+
{
46+
"id": "core_zwave_js",
47+
"label": "Core Z-Wave JS",
48+
"used_bytes": 258064,
4049
"children": null
4150
},
42-
"db21ed7f_qbittorrent": {
43-
"total_space": null,
44-
"used_space": 9508283,
51+
{
52+
"id": "db21ed7f_qbittorrent",
53+
"label": "QBittorrent",
54+
"used_bytes": 9508283,
4555
"children": null
4656
}
47-
}
57+
]
4858
},
49-
"media": {
50-
"total_space": null,
51-
"used_space": 476680019,
52-
"children": {
53-
"jellyfin": {
54-
"total_space": null,
55-
"used_space": 409122725,
59+
{
60+
"id": "media",
61+
"label": "Media",
62+
"used_bytes": 476680019,
63+
"children": [
64+
{
65+
"id": "jellyfin",
66+
"label": "Jellyfin",
67+
"used_bytes": 409122725,
5668
"children": null
5769
}
58-
}
70+
]
5971
},
60-
"share": {
61-
"total_space": null,
62-
"used_space": 37477206419,
63-
"children": {
64-
"supervisor": {
65-
"total_space": null,
66-
"used_space": 929143825,
72+
{
73+
"id": "share",
74+
"label": "Share",
75+
"used_bytes": 37477206419,
76+
"children": [
77+
{
78+
"id": "supervisor",
79+
"label": "Supervisor",
80+
"used_bytes": 929143825,
6781
"children": null
6882
},
69-
"openwakeword": {
70-
"total_space": null,
71-
"used_space": 2263836,
83+
{
84+
"id": "openwakeword",
85+
"label": "OpenWakeword",
86+
"used_bytes": 2263836,
7287
"children": null
7388
}
74-
}
89+
]
7590
},
76-
"backup": {
77-
"total_space": null,
78-
"used_space": 268350699520,
91+
{
92+
"id": "backup",
93+
"label": "Backup",
94+
"used_bytes": 268350699520,
7995
"children": null
8096
},
81-
"ssl": {
82-
"total_space": null,
83-
"used_space": 202912633,
84-
"children": {
85-
"nginxproxymanager": {
86-
"total_space": null,
87-
"used_space": 202879859,
97+
{
98+
"id": "ssl",
99+
"label": "SSL",
100+
"used_bytes": 202912633,
101+
"children": [
102+
{
103+
"id": "nginxproxymanager",
104+
"label": "Nginx Proxy Manager",
105+
"used_bytes": 202879859,
88106
"children": null
89107
},
90-
"openvpn_server": {
91-
"total_space": null,
92-
"used_space": 27500,
108+
{
109+
"id": "openvpn_server",
110+
"label": "OpenVPN Server",
111+
"used_bytes": 27500,
93112
"children": null
94113
}
95-
}
114+
]
96115
},
97-
"homeassistant": {
98-
"total_space": null,
99-
"used_space": 444089236,
100-
"children": {
101-
"image": {
102-
"total_space": null,
103-
"used_space": 571875,
116+
{
117+
"id": "homeassistant",
118+
"label": "Home Assistant",
119+
"used_bytes": 444089236,
120+
"children": [
121+
{
122+
"id": "image",
123+
"label": "Image",
124+
"used_bytes": 571875,
104125
"children": null
105126
},
106-
"custom_components": {
107-
"total_space": null,
108-
"used_space": 58343146,
127+
{
128+
"id": "custom_components",
129+
"label": "Custom Components",
130+
"used_bytes": 58343146,
109131
"children": null
110132
},
111-
"www": {
112-
"total_space": null,
113-
"used_space": 70562846,
133+
{
134+
"id": "www",
135+
"label": "www",
136+
"used_bytes": 70562846,
114137
"children": null
115138
}
116-
}
139+
]
117140
},
118-
"system": {
119-
"total_space": null,
120-
"used_space": 75660896847,
141+
{
142+
"id": "system",
143+
"label": "System",
144+
"used_bytes": 75660896847,
121145
"children": null
122146
}
123-
}
147+
]
124148
}
125149
}

tests/test_host.py

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,53 +118,73 @@ async def test_host_disk_usage(
118118
) -> None:
119119
"""Test host disk usage API."""
120120
responses.get(
121-
f"{SUPERVISOR_URL}/host/disk/default/usage?max_depth=1",
121+
f"{SUPERVISOR_URL}/host/disks/default/usage?max_depth=1",
122122
status=200,
123123
body=load_fixture("host_disk_usage.json"),
124124
)
125125
result = await supervisor_client.host.get_disk_usage()
126126

127127
# Test top-level properties
128-
assert result.total_space == 503312781312
129-
assert result.used_space == 430243422208
128+
assert result.total_bytes == 503312781312
129+
assert result.used_bytes == 430243422208
130130
assert result.children is not None
131131

132132
# Test children structure
133133
children = result.children
134-
assert "addons_data" in children
135-
assert "addons_config" in children
136-
assert "media" in children
137-
assert "share" in children
138-
assert "backup" in children
139-
assert "ssl" in children
140-
assert "homeassistant" in children
141-
assert "system" in children
134+
assert children is not None
135+
assert len(children) == 8 # Should have 8 children
136+
137+
# Find specific children by id
138+
assert (
139+
addons_data := next(child for child in children if child.id == "addons_data")
140+
)
141+
assert next(child for child in children if child.id == "addons_config")
142+
assert next(child for child in children if child.id == "media")
143+
assert next(child for child in children if child.id == "share")
144+
assert (backup := next(child for child in children if child.id == "backup"))
145+
assert next(child for child in children if child.id == "ssl")
146+
assert (
147+
homeassistant := next(
148+
child for child in children if child.id == "homeassistant"
149+
)
150+
)
151+
assert next(child for child in children if child.id == "system")
142152

143153
# Test nested children (recursive structure)
144-
addons_data = children["addons_data"]
145-
assert addons_data.used_space == 42347618720
154+
assert addons_data.used_bytes == 42347618720
146155
assert addons_data.children is not None
147-
assert "77f1785d_remote_api" in addons_data.children
148-
assert "core_samba" in addons_data.children
149-
assert "a0d7b954_plex" in addons_data.children
150-
assert "core_whisper" in addons_data.children
156+
assert len(addons_data.children) == 4
157+
158+
# Find specific nested children
159+
assert next(
160+
child for child in addons_data.children if child.id == "77f1785d_remote_api"
161+
)
162+
assert next(child for child in addons_data.children if child.id == "core_samba")
163+
assert (
164+
plex_addon := next(
165+
child for child in addons_data.children if child.id == "a0d7b954_plex"
166+
)
167+
)
168+
assert next(child for child in addons_data.children if child.id == "core_whisper")
151169

152170
# Test deeper nesting
153-
plex_addon = addons_data.children["a0d7b954_plex"]
154-
assert plex_addon.used_space == 757750613
171+
assert plex_addon.used_bytes == 757750613
155172
assert plex_addon.children is None # Leaf node
156173

157174
# Test another branch
158-
homeassistant = children["homeassistant"]
159-
assert homeassistant.used_space == 444089236
175+
assert homeassistant.used_bytes == 444089236
160176
assert homeassistant.children is not None
161-
assert "image" in homeassistant.children
162-
assert "custom_components" in homeassistant.children
163-
assert "www" in homeassistant.children
177+
assert len(homeassistant.children) == 3
178+
179+
# Find specific homeassistant children
180+
assert next(child for child in homeassistant.children if child.id == "image")
181+
assert next(
182+
child for child in homeassistant.children if child.id == "custom_components"
183+
)
184+
assert next(child for child in homeassistant.children if child.id == "www")
164185

165186
# Test leaf node without children
166-
backup = children["backup"]
167-
assert backup.used_space == 268350699520
187+
assert backup.used_bytes == 268350699520
168188
assert backup.children is None
169189

170190

@@ -173,12 +193,12 @@ async def test_host_disk_usage_with_custom_depth(
173193
) -> None:
174194
"""Test host disk usage API with custom max_depth."""
175195
responses.get(
176-
f"{SUPERVISOR_URL}/host/disk/default/usage?max_depth=3",
196+
f"{SUPERVISOR_URL}/host/disks/default/usage?max_depth=3",
177197
status=200,
178198
body=load_fixture("host_disk_usage.json"),
179199
)
180200
result = await supervisor_client.host.get_disk_usage(max_depth=3)
181201

182202
# Test that the custom max_depth parameter was used
183-
assert result.total_space == 503312781312
184-
assert result.used_space == 430243422208
203+
assert result.total_bytes == 503312781312
204+
assert result.used_bytes == 430243422208

0 commit comments

Comments
 (0)