Skip to content

Commit

Permalink
Add admin.* APIs for managing automation platform apps
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Sep 8, 2023
1 parent abc6a28 commit 374a2c1
Show file tree
Hide file tree
Showing 4 changed files with 805 additions and 3 deletions.
256 changes: 256 additions & 0 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,82 @@ async def admin_apps_uninstall(
kwargs.update({"team_ids": team_ids})
return await self.api_call("admin.apps.uninstall", http_verb="POST", params=kwargs)

async def admin_apps_activities_list(
self,
*,
app_id: Optional[str] = None,
component_id: Optional[str] = None,
component_type: Optional[str] = None,
log_event_type: Optional[str] = None,
max_date_created: Optional[int] = None,
min_date_created: Optional[int] = None,
min_log_level: Optional[str] = None,
sort_direction: Optional[str] = None,
source: Optional[str] = None,
team_id: Optional[str] = None,
trace_id: Optional[str] = None,
cursor: Optional[str] = None,
limit: Optional[int] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Get logs for a specified team/org
https://api.slack.com/methods/admin.apps.activities.list
"""
kwargs.update(
{
"app_id": app_id,
"component_id": component_id,
"component_type": component_type,
"log_event_type": log_event_type,
"max_date_created": max_date_created,
"min_date_created": min_date_created,
"min_log_level": min_log_level,
"sort_direction": sort_direction,
"source": source,
"team_id": team_id,
"trace_id": trace_id,
"cursor": cursor,
"limit": limit,
}
)
return await self.api_call("admin.apps.activities.list", params=kwargs)

async def admin_apps_config_lookup(
self,
*,
app_ids: Union[str, Sequence[str]],
**kwargs,
) -> AsyncSlackResponse:
"""Look up the app config for connectors by their IDs
https://api.slack.com/methods/admin.apps.config.lookup
"""
if isinstance(app_ids, (list, Tuple)):
kwargs.update({"app_ids": ",".join(app_ids)})
else:
kwargs.update({"app_ids": app_ids})

Check warning on line 357 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L357

Added line #L357 was not covered by tests
return await self.api_call("admin.apps.config.lookup", params=kwargs)

async def admin_apps_config_set(
self,
*,
app_id: str,
domain_restrictions: Optional[dict] = None,
workflow_auth_strategy: Optional[str] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Set the app config for a connector
https://api.slack.com/methods/admin.apps.config.set
"""
kwargs.update(
{
"app_id": app_id,
"workflow_auth_strategy": workflow_auth_strategy,
}
)
if domain_restrictions is not None:
kwargs.update({"domain_restrictions", json.dumps(domain_restrictions)})

Check warning on line 378 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L378

Added line #L378 was not covered by tests
return await self.api_call("admin.apps.config.set", params=kwargs)

async def admin_auth_policy_getEntities(
self,
*,
Expand Down Expand Up @@ -948,6 +1024,72 @@ async def admin_emoji_rename(
kwargs.update({"name": name, "new_name": new_name})
return await self.api_call("admin.emoji.rename", http_verb="GET", params=kwargs)

async def admin_functions_list(
self,
*,
app_ids: Union[str, Sequence[str]],
team_id: Optional[str] = None,
cursor: Optional[str] = None,
limit: Optional[int] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Look up functions by a set of apps
https://api.slack.com/methods/admin.functions.list
"""
if isinstance(app_ids, (list, Tuple)):
kwargs.update({"app_ids": ",".join(app_ids)})
else:
kwargs.update({"app_ids": app_ids})

Check warning on line 1042 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1042

Added line #L1042 was not covered by tests
kwargs.update(
{
"team_id": team_id,
"cursor": cursor,
"limit": limit,
}
)
return await self.api_call("admin.functions.list", params=kwargs)

async def admin_functions_permissions_lookup(
self,
*,
function_ids: Union[str, Sequence[str]],
**kwargs,
) -> AsyncSlackResponse:
"""Lookup the visibility of multiple Slack functions
and include the users if it is limited to particular named entities.
https://api.slack.com/methods/admin.functions.permissions.lookup
"""
if isinstance(function_ids, (list, Tuple)):
kwargs.update({"function_ids": ",".join(function_ids)})
else:
kwargs.update({"function_ids": function_ids})

Check warning on line 1065 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1065

Added line #L1065 was not covered by tests
return await self.api_call("admin.functions.permissions.lookup", params=kwargs)

async def admin_functions_permissions_set(
self,
*,
function_id: str,
visibility: str,
user_ids: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Set the visibility of a Slack function
and define the users or workspaces if it is set to named_entities
https://api.slack.com/methods/admin.functions.permissions.set
"""
kwargs.update(
{
"function_id": function_id,
"visibility": visibility,
}
)
if user_ids is not None:
if isinstance(user_ids, (list, Tuple)):
kwargs.update({"user_ids": ",".join(user_ids)})

Check warning on line 1088 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1087-L1088

Added lines #L1087 - L1088 were not covered by tests
else:
kwargs.update({"user_ids": user_ids})

Check warning on line 1090 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1090

Added line #L1090 was not covered by tests
return await self.api_call("admin.functions.permissions.set", params=kwargs)

async def admin_roles_addAssignments(
self,
*,
Expand Down Expand Up @@ -1616,6 +1758,120 @@ async def admin_users_setRegular(
kwargs.update({"team_id": team_id, "user_id": user_id})
return await self.api_call("admin.users.setRegular", params=kwargs)

async def admin_workflows_search(
self,
*,
app_id: Optional[str] = None,
collaborator_ids: Optional[Union[str, Sequence[str]]] = None,
cursor: Optional[str] = None,
limit: Optional[int] = None,
no_collaborators: Optional[bool] = None,
num_trigger_ids: Optional[int] = None,
query: Optional[str] = None,
sort: Optional[str] = None,
sort_dir: Optional[str] = None,
source: Optional[str] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Search workflows within the team or enterprise
https://api.slack.com/methods/admin.workflows.search
"""
if collaborator_ids is not None:
if isinstance(collaborator_ids, (list, Tuple)):
kwargs.update({"collaborator_ids": ",".join(collaborator_ids)})

Check warning on line 1781 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1780-L1781

Added lines #L1780 - L1781 were not covered by tests
else:
kwargs.update({"collaborator_ids": collaborator_ids})

Check warning on line 1783 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1783

Added line #L1783 was not covered by tests
kwargs.update(
{
"app_id": app_id,
"cursor": cursor,
"limit": limit,
"no_collaborators": no_collaborators,
"num_trigger_ids": num_trigger_ids,
"query": query,
"sort": sort,
"sort_dir": sort_dir,
"source": source,
}
)
return await self.api_call("admin.workflows.search", params=kwargs)

async def admin_workflows_permissions_lookup(
self,
*,
workflow_ids: Union[str, Sequence[str]],
max_workflow_triggers: Optional[int] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Look up the permissions for a set of workflows
https://api.slack.com/methods/admin.workflows.permissions.lookup
"""
if isinstance(workflow_ids, (list, Tuple)):
kwargs.update({"workflow_ids": ",".join(workflow_ids)})
else:
kwargs.update({"workflow_ids": workflow_ids})

Check warning on line 1812 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1812

Added line #L1812 was not covered by tests
kwargs.update(
{
"max_workflow_triggers": max_workflow_triggers,
}
)
return await self.api_call("admin.workflows.permissions.lookup", params=kwargs)

async def admin_workflows_collaborators_add(
self,
*,
collaborator_ids: Union[str, Sequence[str]],
workflow_ids: Union[str, Sequence[str]],
**kwargs,
) -> AsyncSlackResponse:
"""Add collaborators to workflows within the team or enterprise
https://api.slack.com/methods/admin.workflows.collaborators.add
"""
if isinstance(collaborator_ids, (list, Tuple)):
kwargs.update({"collaborator_ids": ",".join(collaborator_ids)})
else:
kwargs.update({"collaborator_ids": collaborator_ids})

Check warning on line 1833 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1833

Added line #L1833 was not covered by tests
if isinstance(workflow_ids, (list, Tuple)):
kwargs.update({"workflow_ids": ",".join(workflow_ids)})
else:
kwargs.update({"workflow_ids": workflow_ids})

Check warning on line 1837 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1837

Added line #L1837 was not covered by tests
return await self.api_call("admin.workflows.collaborators.add", params=kwargs)

async def admin_workflows_collaborators_remove(
self,
*,
collaborator_ids: Union[str, Sequence[str]],
workflow_ids: Union[str, Sequence[str]],
**kwargs,
) -> AsyncSlackResponse:
"""Remove collaborators from workflows within the team or enterprise
https://api.slack.com/methods/admin.workflows.collaborators.remove
"""
if isinstance(collaborator_ids, (list, Tuple)):
kwargs.update({"collaborator_ids": ",".join(collaborator_ids)})
else:
kwargs.update({"collaborator_ids": collaborator_ids})

Check warning on line 1853 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1853

Added line #L1853 was not covered by tests
if isinstance(workflow_ids, (list, Tuple)):
kwargs.update({"workflow_ids": ",".join(workflow_ids)})
else:
kwargs.update({"workflow_ids": workflow_ids})

Check warning on line 1857 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1857

Added line #L1857 was not covered by tests
return await self.api_call("admin.workflows.collaborators.remove", params=kwargs)

async def admin_workflows_unpublish(
self,
*,
workflow_ids: Union[str, Sequence[str]],
**kwargs,
) -> AsyncSlackResponse:
"""Unpublish workflows within the team or enterprise
https://api.slack.com/methods/admin.workflows.unpublish
"""
if isinstance(workflow_ids, (list, Tuple)):
kwargs.update({"workflow_ids": ",".join(workflow_ids)})
else:
kwargs.update({"workflow_ids": workflow_ids})

Check warning on line 1872 in slack_sdk/web/async_client.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/async_client.py#L1872

Added line #L1872 was not covered by tests
return await self.api_call("admin.workflows.unpublish", params=kwargs)

async def api_test(
self,
*,
Expand Down
Loading

0 comments on commit 374a2c1

Please sign in to comment.