diff --git a/src/foxops_client/client_async.py b/src/foxops_client/client_async.py index 837175a..576c48a 100644 --- a/src/foxops_client/client_async.py +++ b/src/foxops_client/client_async.py @@ -10,7 +10,7 @@ IncarnationDoesNotExistError, ) from foxops_client.retries import default_retry -from foxops_client.types import Incarnation, IncarnationWithDetails +from foxops_client.types import Incarnation, IncarnationWithDetails, TemplateData class AsyncFoxopsClient: @@ -103,7 +103,7 @@ async def patch_incarnation( incarnation_id: int, automerge: bool, requested_version: str | None = None, - requested_data: dict[str, Any] | None = None, + requested_data: TemplateData | None = None, ): data: dict[str, Any] = { "automerge": automerge, @@ -132,15 +132,15 @@ async def put_incarnation( incarnation_id: int, automerge: bool, template_repository_version: str, - template_data: dict[str, Any], + template_data: TemplateData, ) -> IncarnationWithDetails: - data: dict[str, Any] = { + request: dict[str, Any] = { "automerge": automerge, "template_repository_version": template_repository_version, "template_data": template_data, } - resp = await self.retry_function(self.client.put)(f"/api/incarnations/{incarnation_id}", json=data) + resp = await self.retry_function(self.client.put)(f"/api/incarnations/{incarnation_id}", json=request) match resp.status_code: case httpx.codes.OK: @@ -159,7 +159,7 @@ async def create_incarnation( incarnation_repository: str, template_repository: str, template_repository_version: str, - template_data: dict[str, Any], + template_data: TemplateData, target_directory: str | None = None, automerge: bool | None = None, ) -> IncarnationWithDetails: diff --git a/src/foxops_client/client_sync.py b/src/foxops_client/client_sync.py index 4a716eb..3308cfd 100644 --- a/src/foxops_client/client_sync.py +++ b/src/foxops_client/client_sync.py @@ -1,8 +1,7 @@ import asyncio -from typing import Any from foxops_client.client_async import AsyncFoxopsClient -from foxops_client.types import Incarnation, IncarnationWithDetails +from foxops_client.types import Incarnation, IncarnationWithDetails, TemplateData class FoxopsClient: @@ -41,7 +40,7 @@ def patch_incarnation( incarnation_id: int, automerge: bool, requested_version: str | None = None, - requested_data: dict[str, Any] | None = None, + requested_data: TemplateData | None = None, ): return self.loop.run_until_complete( self.client.patch_incarnation( @@ -57,7 +56,7 @@ def put_incarnation( incarnation_id: int, automerge: bool, template_repository_version: str, - template_data: dict[str, Any], + template_data: TemplateData, ) -> IncarnationWithDetails: return self.loop.run_until_complete( self.client.put_incarnation( @@ -73,7 +72,7 @@ def create_incarnation( incarnation_repository: str, template_repository: str, template_repository_version: str, - template_data: dict[str, Any], + template_data: TemplateData, target_directory: str | None = None, automerge: bool | None = None, ) -> IncarnationWithDetails: diff --git a/src/foxops_client/types.py b/src/foxops_client/types.py index b2b1526..13e2b12 100644 --- a/src/foxops_client/types.py +++ b/src/foxops_client/types.py @@ -2,6 +2,8 @@ from enum import Enum from typing import Any, Self +TemplateData = dict[str, Any] + class MergeRequestStatus(Enum): OPEN = "open" @@ -42,7 +44,8 @@ class IncarnationWithDetails(Incarnation): template_repository: str | None template_repository_version: str | None template_repository_version_hash: str | None - template_data: dict[str, Any] | None + template_data: TemplateData | None + template_data_full: TemplateData | None @classmethod def from_dict(cls, data: dict[str, Any]) -> Self: @@ -56,5 +59,6 @@ def from_dict(cls, data: dict[str, Any]) -> Self: template_repository_version=data["template_repository_version"], template_repository_version_hash=data["template_repository_version_hash"], template_data=data["template_data"], + template_data_full=data["template_data_full"], **asdict(Incarnation.from_dict(data)), )