Skip to content

Commit 80cea97

Browse files
committed
Add groups.group_add_subscriber
1 parent b5acff9 commit 80cea97

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

infrahub_sdk/groups.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from typing import List
2+
3+
from infrahub_sdk import InfrahubClient
4+
from infrahub_sdk.node import InfrahubNode
5+
6+
7+
async def group_add_subscriber(
8+
client: InfrahubClient, group: InfrahubNode, subscribers: List[str], branch: str
9+
) -> dict:
10+
subscribers_str = ["{ id: " + f'"{subscriber}"' + " }" for subscriber in subscribers]
11+
query = """
12+
mutation {
13+
RelationshipAdd(
14+
data: {
15+
id: "%s",
16+
name: "subscribers",
17+
nodes: [ %s ]
18+
}
19+
) {
20+
ok
21+
}
22+
}
23+
""" % (
24+
group.id,
25+
", ".join(subscribers_str),
26+
)
27+
28+
return await client.execute_graphql(query=query, branch_name=branch, tracker="mutation-relationshipadd")

0 commit comments

Comments
 (0)