-
-
Notifications
You must be signed in to change notification settings - Fork 318
/
create_from_group.py
33 lines (26 loc) · 843 Bytes
/
create_from_group.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Create team from group
https://learn.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0
"""
from office365.graph_client import GraphClient
from tests import (
create_unique_name,
test_client_id,
test_password,
test_tenant,
test_username,
)
def print_failure(retry_number, ex):
print(f"{retry_number}: Team creation still in progress, waiting...")
client = GraphClient.with_username_and_password(
test_tenant, test_client_id, test_username, test_password
)
group_name = create_unique_name("Flight")
group = client.groups.create_m365(group_name)
team = group.add_team().execute_query_retry(
max_retry=10, failure_callback=print_failure
)
print("Team has been created: {0}".format(team.web_url))
# clean up resources
print("Deleting a group...")
group.delete_object(True).execute_query()