Skip to content

Commit a671c0d

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

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

infrahub_sdk/branch.py

Lines changed: 15 additions & 3 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,20 @@ async def create(
7778
branch_name: str,
7879
sync_with_git: bool = True,
7980
description: str = "",
80-
background_execution: bool = False,
81+
wait_until_completion: bool = False,
82+
background_execution: Optional[bool] = False,
8183
) -> BranchData:
84+
85+
if background_execution is not None:
86+
warnings.warn(
87+
"`background_execution` is deprecated, please use `wait_until_completion` instead.",
88+
DeprecationWarning,
89+
stacklevel=2
90+
)
91+
92+
wait_until_completion = background_execution or wait_until_completion
8293
input_data = {
83-
"background_execution": background_execution,
94+
"wait_until_completion": wait_until_completion,
8495
"data": {
8596
"name": branch_name,
8697
"description": description,
@@ -90,7 +101,8 @@ async def create(
90101

91102
query = Mutation(mutation="BranchCreate", input_data=input_data, query=MUTATION_QUERY_DATA)
92103
response = await self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create")
93-
104+
if not wait_until_completion:
105+
return BranchData(**response["BranchCreate"]["task"])
94106
return BranchData(**response["BranchCreate"]["object"])
95107

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

0 commit comments

Comments
 (0)