Skip to content

Commit a32315c

Browse files
authored
Rename action methods without verb (#22)
* Alias addon action methods without verb * Rename action methods without verb
1 parent 0089da8 commit a32315c

File tree

12 files changed

+25
-18
lines changed

12 files changed

+25
-18
lines changed

aiohasupervisor/addons.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def restart_addon(self, addon: str) -> None:
5353
"""Restart an addon."""
5454
await self._client.post(f"addons/{addon}/restart", timeout=None)
5555

56-
async def addon_options(self, addon: str, options: AddonsOptions) -> None:
56+
async def set_addon_options(self, addon: str, options: AddonsOptions) -> None:
5757
"""Set options for addon."""
5858
await self._client.post(f"addons/{addon}/options", json=options.to_dict())
5959

@@ -79,11 +79,13 @@ async def rebuild_addon(self, addon: str) -> None:
7979
"""Rebuild an addon (only available for local addons built from source)."""
8080
await self._client.post(f"addons/{addon}/rebuild")
8181

82-
async def addon_stdin(self, addon: str, stdin: bytes) -> None:
82+
async def write_addon_stdin(self, addon: str, stdin: bytes) -> None:
8383
"""Write to stdin of an addon (if supported by addon)."""
8484
await self._client.post(f"addons/{addon}/stdin", data=stdin)
8585

86-
async def addon_security(self, addon: str, options: AddonsSecurityOptions) -> None:
86+
async def set_addon_security(
87+
self, addon: str, options: AddonsSecurityOptions
88+
) -> None:
8789
"""Set security options for addon."""
8890
await self._client.post(f"addons/{addon}/security", json=options.to_dict())
8991

aiohasupervisor/backups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def info(self) -> BackupsInfo:
3131
result = await self._client.get("backups/info")
3232
return BackupsInfo.from_dict(result.data)
3333

34-
async def options(self, options: BackupsOptions) -> None:
34+
async def set_options(self, options: BackupsOptions) -> None:
3535
"""Set options for backups."""
3636
await self._client.post("backups/options", json=options.to_dict())
3737

aiohasupervisor/homeassistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def stats(self) -> HomeAssistantStats:
2525
result = await self._client.get("core/stats")
2626
return HomeAssistantStats.from_dict(result.data)
2727

28-
async def options(self, options: HomeAssistantOptions) -> None:
28+
async def set_options(self, options: HomeAssistantOptions) -> None:
2929
"""Set Home Assistant options."""
3030
await self._client.post("core/options", json=options.to_dict())
3131

aiohasupervisor/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def reload(self) -> None:
3838
"""Reload host info cache."""
3939
await self._client.post("host/reload")
4040

41-
async def options(self, options: HostOptions) -> None:
41+
async def set_options(self, options: HostOptions) -> None:
4242
"""Set host options."""
4343
await self._client.post("host/options", json=options.to_dict())
4444

aiohasupervisor/os.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def green_info(self) -> GreenInfo:
5555
result = await self._client.get("os/boards/green")
5656
return GreenInfo.from_dict(result.data)
5757

58-
async def green_options(self, options: GreenOptions) -> None:
58+
async def set_green_options(self, options: GreenOptions) -> None:
5959
"""Set options for green board (if in use)."""
6060
await self._client.post("os/boards/green", json=options.to_dict())
6161

@@ -64,6 +64,6 @@ async def yellow_info(self) -> YellowInfo:
6464
result = await self._client.get("os/boards/yellow")
6565
return YellowInfo.from_dict(result.data)
6666

67-
async def yellow_options(self, options: YellowOptions) -> None:
67+
async def set_yellow_options(self, options: YellowOptions) -> None:
6868
"""Set options for yellow board (if in use)."""
6969
await self._client.post("os/boards/yellow", json=options.to_dict())

aiohasupervisor/supervisor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def restart(self) -> None:
5454
"""Restart supervisor."""
5555
await self._client.post("supervisor/restart")
5656

57-
async def options(self, options: SupervisorOptions) -> None:
57+
async def set_options(self, options: SupervisorOptions) -> None:
5858
"""Set supervisor options."""
5959
await self._client.post("supervisor/options", json=options.to_dict())
6060

tests/test_addons.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async def test_addons_options(
119119
"""Test addon options API."""
120120
responses.post(f"{SUPERVISOR_URL}/addons/core_ssh/options", status=200)
121121
assert (
122-
await supervisor_client.addons.addon_options(
122+
await supervisor_client.addons.set_addon_options(
123123
"core_ssh",
124124
AddonsOptions(
125125
config=None,
@@ -195,7 +195,8 @@ async def test_addons_stdin(
195195
"""Test addon stdin API."""
196196
responses.post(f"{SUPERVISOR_URL}/addons/core_ssh/stdin", status=200)
197197
assert (
198-
await supervisor_client.addons.addon_stdin("core_ssh", b"hello world") is None
198+
await supervisor_client.addons.write_addon_stdin("core_ssh", b"hello world")
199+
is None
199200
)
200201
assert len(responses.requests) == 1
201202
assert (
@@ -212,7 +213,7 @@ async def test_addons_security(
212213
"""Test addon security API."""
213214
responses.post(f"{SUPERVISOR_URL}/addons/core_ssh/security", status=200)
214215
assert (
215-
await supervisor_client.addons.addon_security(
216+
await supervisor_client.addons.set_addon_security(
216217
"core_ssh", AddonsSecurityOptions(protected=True)
217218
)
218219
is None

tests/test_backups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def test_backups_options(
6060
"""Test backups options API."""
6161
responses.post(f"{SUPERVISOR_URL}/backups/options", status=200)
6262
assert (
63-
await supervisor_client.backups.options(BackupsOptions(days_until_stale=10))
63+
await supervisor_client.backups.set_options(BackupsOptions(days_until_stale=10))
6464
is None
6565
)
6666
assert responses.requests.keys() == {

tests/test_homeassistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def test_homeassistant_options(
6161
"""Test Home Assistant options API."""
6262
responses.post(f"{SUPERVISOR_URL}/core/options", status=200)
6363
assert (
64-
await supervisor_client.homeassistant.options(
64+
await supervisor_client.homeassistant.set_options(
6565
HomeAssistantOptions(watchdog=False, backups_exclude_database=True)
6666
)
6767
is None

tests/test_host.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ async def test_host_options(
8787
) -> None:
8888
"""Test host options API."""
8989
responses.post(f"{SUPERVISOR_URL}/host/options", status=200)
90-
assert await supervisor_client.host.options(HostOptions(hostname="test")) is None
90+
assert (
91+
await supervisor_client.host.set_options(HostOptions(hostname="test")) is None
92+
)
9193
assert responses.requests.keys() == {
9294
("POST", URL(f"{SUPERVISOR_URL}/host/options"))
9395
}

0 commit comments

Comments
 (0)