Skip to content

Commit f5f8f8c

Browse files
seratchkian2attari
andauthored
Add admin.usergroups.addTeams, calls.participants.remove API #757 (#758)
Co-authored-by: Kian Attari <[email protected]>
1 parent 1f252e0 commit f5f8f8c

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

integration_tests/web/test_admin_usergroups.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def test_sync(self):
4444
)
4545
self.assertIsNotNone(list_channels)
4646

47+
add_teams = client.admin_usergroups_addTeams(
48+
usergroup_id=self.idp_usergroup_id,
49+
team_ids=self.team_id,
50+
)
51+
self.assertIsNotNone(add_teams)
52+
4753
add_channels = client.admin_usergroups_addChannels(
4854
team_id=self.team_id,
4955
usergroup_id=self.idp_usergroup_id,
@@ -67,6 +73,12 @@ async def test_async(self):
6773
)
6874
self.assertIsNotNone(list_channels)
6975

76+
add_teams = await client.admin_usergroups_addTeams(
77+
usergroup_id=self.idp_usergroup_id,
78+
team_ids=self.team_id,
79+
)
80+
self.assertIsNotNone(add_teams)
81+
7082
add_channels = await client.admin_usergroups_addChannels(
7183
team_id=self.team_id,
7284
usergroup_id=self.idp_usergroup_id,

integration_tests/web/test_calls.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ def test_sync(self):
6969
])
7070
self.assertIsNotNone(new_participants)
7171

72+
participants_removal = client.calls_participants_remove(id=call_id, users=[
73+
{
74+
"external_id": "anon-222",
75+
"avatar_url": "https://assets.brandfolder.com/pmix53-32t4so-a6439g/original/slackbot.png",
76+
"display_name": "anonymous user 2",
77+
}
78+
])
79+
self.assertIsNotNone(participants_removal)
80+
7281
modified_call = client.calls_update(id=call_id, join_url="https://www.example.com/calls/99999")
7382
self.assertIsNotNone(modified_call)
7483

slack/web/client.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,24 @@ def admin_usergroups_addChannels(
355355
kwargs.update({"channel_ids": channel_ids})
356356
return self.api_call("admin.usergroups.addChannels", json=kwargs)
357357

358+
def admin_usergroups_addTeams(
359+
self, *, usergroup_id: str, team_ids: Union[str, List[str]], **kwargs
360+
) -> Union[Future, SlackResponse]:
361+
"""Associate one or more default workspaces with an organization-wide IDP group.
362+
363+
Args:
364+
usergroup_id (str): ID of the IDP group. e.g. 'S1234'
365+
team_ids (str or list): A comma separated list of encoded team (workspace) IDs.
366+
Each workspace MUST belong to the organization associated with the token.
367+
e.g. 'T12345678,T98765432' or ['T12345678', 'T98765432']
368+
"""
369+
kwargs.update({"usergroup_id": usergroup_id})
370+
if isinstance(team_ids, list):
371+
kwargs.update({"team_ids": ",".join(team_ids)})
372+
else:
373+
kwargs.update({"team_ids": team_ids})
374+
return self.api_call("admin.usergroups.addTeams", json=kwargs)
375+
358376
def admin_usergroups_listChannels(
359377
self, *, usergroup_id: str, **kwargs
360378
) -> Union[Future, SlackResponse]:
@@ -549,6 +567,21 @@ def calls_participants_add(
549567
self._update_call_participants(kwargs, users)
550568
return self.api_call("calls.participants.add", http_verb="POST", params=kwargs)
551569

570+
def calls_participants_remove(
571+
self, *, id: str, users: Union[str, List[Dict[str, str]]], **kwargs
572+
) -> Union[Future, SlackResponse]:
573+
"""Registers participants removed from a Call.
574+
575+
Args:
576+
id (str): id returned when registering the call using the calls.add method.
577+
users: (list): The list of users to remove as participants in the Call.
578+
"""
579+
kwargs.update({"id": id})
580+
self._update_call_participants(kwargs, users)
581+
return self.api_call(
582+
"calls.participants.remove", http_verb="POST", params=kwargs
583+
)
584+
552585
def calls_update(self, *, id: str, **kwargs) -> Union[Future, SlackResponse]:
553586
"""Updates information about a Call.
554587

tests/web/test_web_client_coverage.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ def setUp(self):
2929
"admin.conversations.whitelist.add", # deprecated
3030
"admin.conversations.whitelist.listGroupsLinkedToChannel", # deprecated
3131
"admin.conversations.whitelist.remove", # deprecated
32-
"admin.usergroups.addTeams", # TODO
33-
"calls.participants.remove", # TODO
3432
]:
3533
continue
3634
self.api_methods_to_call.append(api_method)
@@ -88,6 +86,17 @@ def test_coverage(self):
8886
usergroup_id="S123",
8987
channel_ids="C1A2B3C4D,C26Z25Y24",
9088
)
89+
elif method_name == "admin_usergroups_addTeams":
90+
self.api_methods_to_call.remove(method(
91+
team_id="T123",
92+
usergroup_id="S123",
93+
team_ids=["T111", "T222"],
94+
)["method"])
95+
method(
96+
team_id="T123",
97+
usergroup_id="S123",
98+
team_ids="T111,T222",
99+
)
91100
elif method_name == "admin_usergroups_listChannels":
92101
self.api_methods_to_call.remove(method(usergroup_id="S123")["method"])
93102
method(usergroup_id="S123", include_num_members=True, team_id="T123")
@@ -157,6 +166,20 @@ def test_coverage(self):
157166
}
158167
],
159168
)["method"])
169+
elif method_name == "calls_participants_remove":
170+
self.api_methods_to_call.remove(method(
171+
id="R111",
172+
users=[
173+
{
174+
"slack_id": "U1H77"
175+
},
176+
{
177+
"external_id": "54321678",
178+
"display_name": "External User",
179+
"avatar_url": "https://example.com/users/avatar1234.jpg"
180+
}
181+
],
182+
)["method"])
160183
elif method_name == "calls_update":
161184
self.api_methods_to_call.remove(method(id="R111")["method"])
162185
elif method_name == "chat_delete":

0 commit comments

Comments
 (0)