Skip to content

Commit baf9f38

Browse files
authored
update types and API interface to foxops version 2.2 (#34)
update types and API interface to foxops version 2.2
1 parent 4853104 commit baf9f38

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/foxops_client/client_async.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
IncarnationDoesNotExistError,
1111
)
1212
from foxops_client.retries import default_retry
13-
from foxops_client.types import Incarnation, IncarnationWithDetails
13+
from foxops_client.types import Incarnation, IncarnationWithDetails, TemplateData
1414

1515

1616
class AsyncFoxopsClient:
@@ -103,7 +103,7 @@ async def patch_incarnation(
103103
incarnation_id: int,
104104
automerge: bool,
105105
requested_version: str | None = None,
106-
requested_data: dict[str, Any] | None = None,
106+
requested_data: TemplateData | None = None,
107107
):
108108
data: dict[str, Any] = {
109109
"automerge": automerge,
@@ -132,15 +132,15 @@ async def put_incarnation(
132132
incarnation_id: int,
133133
automerge: bool,
134134
template_repository_version: str,
135-
template_data: dict[str, Any],
135+
template_data: TemplateData,
136136
) -> IncarnationWithDetails:
137-
data: dict[str, Any] = {
137+
request: dict[str, Any] = {
138138
"automerge": automerge,
139139
"template_repository_version": template_repository_version,
140140
"template_data": template_data,
141141
}
142142

143-
resp = await self.retry_function(self.client.put)(f"/api/incarnations/{incarnation_id}", json=data)
143+
resp = await self.retry_function(self.client.put)(f"/api/incarnations/{incarnation_id}", json=request)
144144

145145
match resp.status_code:
146146
case httpx.codes.OK:
@@ -159,7 +159,7 @@ async def create_incarnation(
159159
incarnation_repository: str,
160160
template_repository: str,
161161
template_repository_version: str,
162-
template_data: dict[str, Any],
162+
template_data: TemplateData,
163163
target_directory: str | None = None,
164164
automerge: bool | None = None,
165165
) -> IncarnationWithDetails:

src/foxops_client/client_sync.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import asyncio
2-
from typing import Any
32

43
from foxops_client.client_async import AsyncFoxopsClient
5-
from foxops_client.types import Incarnation, IncarnationWithDetails
4+
from foxops_client.types import Incarnation, IncarnationWithDetails, TemplateData
65

76

87
class FoxopsClient:
@@ -41,7 +40,7 @@ def patch_incarnation(
4140
incarnation_id: int,
4241
automerge: bool,
4342
requested_version: str | None = None,
44-
requested_data: dict[str, Any] | None = None,
43+
requested_data: TemplateData | None = None,
4544
):
4645
return self.loop.run_until_complete(
4746
self.client.patch_incarnation(
@@ -57,7 +56,7 @@ def put_incarnation(
5756
incarnation_id: int,
5857
automerge: bool,
5958
template_repository_version: str,
60-
template_data: dict[str, Any],
59+
template_data: TemplateData,
6160
) -> IncarnationWithDetails:
6261
return self.loop.run_until_complete(
6362
self.client.put_incarnation(
@@ -73,7 +72,7 @@ def create_incarnation(
7372
incarnation_repository: str,
7473
template_repository: str,
7574
template_repository_version: str,
76-
template_data: dict[str, Any],
75+
template_data: TemplateData,
7776
target_directory: str | None = None,
7877
automerge: bool | None = None,
7978
) -> IncarnationWithDetails:

src/foxops_client/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from enum import Enum
33
from typing import Any, Self
44

5+
TemplateData = dict[str, Any]
6+
57

68
class MergeRequestStatus(Enum):
79
OPEN = "open"
@@ -42,7 +44,8 @@ class IncarnationWithDetails(Incarnation):
4244
template_repository: str | None
4345
template_repository_version: str | None
4446
template_repository_version_hash: str | None
45-
template_data: dict[str, Any] | None
47+
template_data: TemplateData | None
48+
template_data_full: TemplateData | None
4649

4750
@classmethod
4851
def from_dict(cls, data: dict[str, Any]) -> Self:
@@ -56,5 +59,6 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
5659
template_repository_version=data["template_repository_version"],
5760
template_repository_version_hash=data["template_repository_version_hash"],
5861
template_data=data["template_data"],
62+
template_data_full=data["template_data_full"],
5963
**asdict(Incarnation.from_dict(data)),
6064
)

0 commit comments

Comments
 (0)