Skip to content

Commit da85da4

Browse files
committed
Add wait_until_completion to InfrahubBranchManager.create
1 parent a0afaa0 commit da85da4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

infrahub_sdk/branch.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import warnings
34
from typing import TYPE_CHECKING, Any, Optional, Union
45
from urllib.parse import urlencode
56

@@ -77,10 +78,19 @@ async def create(
7778
branch_name: str,
7879
sync_with_git: bool = True,
7980
description: str = "",
80-
background_execution: bool = False,
81-
) -> BranchData:
81+
wait_until_completion: bool = False,
82+
background_execution: Optional[bool] = False,
83+
) -> BranchData | str:
84+
if background_execution is not None:
85+
warnings.warn(
86+
"`background_execution` is deprecated, please use `wait_until_completion` instead.",
87+
DeprecationWarning,
88+
stacklevel=1,
89+
)
90+
91+
wait_until_completion = background_execution or wait_until_completion
8292
input_data = {
83-
"background_execution": background_execution,
93+
"wait_until_completion": wait_until_completion,
8494
"data": {
8595
"name": branch_name,
8696
"description": description,
@@ -90,7 +100,8 @@ async def create(
90100

91101
query = Mutation(mutation="BranchCreate", input_data=input_data, query=MUTATION_QUERY_DATA)
92102
response = await self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create")
93-
103+
if not wait_until_completion:
104+
return BranchData(**response["BranchCreate"]["task"]["id"])
94105
return BranchData(**response["BranchCreate"]["object"])
95106

96107
async def delete(self, branch_name: str) -> bool:

0 commit comments

Comments
 (0)