Skip to content

Commit 7cc6931

Browse files
authored
Add support for cancelling executions (#39)
1 parent fab2e57 commit 7cc6931

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pyhoma/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ async def execute_command(
163163
command = Command(command)
164164
return await self.execute_commands(device_url, [command], label)
165165

166+
async def cancel_command(self, exec_id: str) -> None:
167+
""" Cancel a running setup-level execution """
168+
await self.__delete(f"/exec/current/setup/{exec_id}")
169+
166170
async def execute_commands(
167171
self,
168172
device_url: str,
@@ -203,6 +207,11 @@ async def __post(
203207
await self.check_response(response)
204208
return await response.json()
205209

210+
async def __delete(self, endpoint: str) -> None:
211+
""" Make a DELETE request to the TaHoma API """
212+
async with self.session.delete(f"{self.api_url}{endpoint}") as response:
213+
await self.check_response(response)
214+
206215
@staticmethod
207216
async def check_response(response: ClientResponse) -> None:
208217
""" Check the response returned by the TaHoma API"""

0 commit comments

Comments
 (0)