From 374a2c1d2b5d4c763c73b0159c84e32509fbae8c Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Fri, 8 Sep 2023 14:20:44 +0900 Subject: [PATCH] Add admin.* APIs for managing automation platform apps --- slack_sdk/web/async_client.py | 256 ++++++++++++++++++ slack_sdk/web/client.py | 256 ++++++++++++++++++ slack_sdk/web/legacy_client.py | 256 ++++++++++++++++++ .../web/test_web_client_coverage.py | 40 ++- 4 files changed, 805 insertions(+), 3 deletions(-) diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py index 4ed813d5..8400e674 100644 --- a/slack_sdk/web/async_client.py +++ b/slack_sdk/web/async_client.py @@ -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}) + 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)}) + return await self.api_call("admin.apps.config.set", params=kwargs) + async def admin_auth_policy_getEntities( self, *, @@ -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}) + 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}) + 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)}) + else: + kwargs.update({"user_ids": user_ids}) + return await self.api_call("admin.functions.permissions.set", params=kwargs) + async def admin_roles_addAssignments( self, *, @@ -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)}) + else: + kwargs.update({"collaborator_ids": collaborator_ids}) + 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}) + 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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + 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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + 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}) + return await self.api_call("admin.workflows.unpublish", params=kwargs) + async def api_test( self, *, diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py index 3964381e..c99910c9 100644 --- a/slack_sdk/web/client.py +++ b/slack_sdk/web/client.py @@ -293,6 +293,82 @@ def admin_apps_uninstall( kwargs.update({"team_ids": team_ids}) return self.api_call("admin.apps.uninstall", http_verb="POST", params=kwargs) + 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, + ) -> SlackResponse: + """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 self.api_call("admin.apps.activities.list", params=kwargs) + + def admin_apps_config_lookup( + self, + *, + app_ids: Union[str, Sequence[str]], + **kwargs, + ) -> SlackResponse: + """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}) + return self.api_call("admin.apps.config.lookup", params=kwargs) + + def admin_apps_config_set( + self, + *, + app_id: str, + domain_restrictions: Optional[dict] = None, + workflow_auth_strategy: Optional[str] = None, + **kwargs, + ) -> SlackResponse: + """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)}) + return self.api_call("admin.apps.config.set", params=kwargs) + def admin_auth_policy_getEntities( self, *, @@ -939,6 +1015,72 @@ def admin_emoji_rename( kwargs.update({"name": name, "new_name": new_name}) return self.api_call("admin.emoji.rename", http_verb="GET", params=kwargs) + 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, + ) -> SlackResponse: + """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}) + kwargs.update( + { + "team_id": team_id, + "cursor": cursor, + "limit": limit, + } + ) + return self.api_call("admin.functions.list", params=kwargs) + + def admin_functions_permissions_lookup( + self, + *, + function_ids: Union[str, Sequence[str]], + **kwargs, + ) -> SlackResponse: + """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}) + return self.api_call("admin.functions.permissions.lookup", params=kwargs) + + def admin_functions_permissions_set( + self, + *, + function_id: str, + visibility: str, + user_ids: Optional[Union[str, Sequence[str]]] = None, + **kwargs, + ) -> SlackResponse: + """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)}) + else: + kwargs.update({"user_ids": user_ids}) + return self.api_call("admin.functions.permissions.set", params=kwargs) + def admin_roles_addAssignments( self, *, @@ -1607,6 +1749,120 @@ def admin_users_setRegular( kwargs.update({"team_id": team_id, "user_id": user_id}) return self.api_call("admin.users.setRegular", params=kwargs) + 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, + ) -> SlackResponse: + """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)}) + else: + kwargs.update({"collaborator_ids": collaborator_ids}) + 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 self.api_call("admin.workflows.search", params=kwargs) + + def admin_workflows_permissions_lookup( + self, + *, + workflow_ids: Union[str, Sequence[str]], + max_workflow_triggers: Optional[int] = None, + **kwargs, + ) -> SlackResponse: + """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}) + kwargs.update( + { + "max_workflow_triggers": max_workflow_triggers, + } + ) + return self.api_call("admin.workflows.permissions.lookup", params=kwargs) + + def admin_workflows_collaborators_add( + self, + *, + collaborator_ids: Union[str, Sequence[str]], + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> SlackResponse: + """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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + return self.api_call("admin.workflows.collaborators.add", params=kwargs) + + def admin_workflows_collaborators_remove( + self, + *, + collaborator_ids: Union[str, Sequence[str]], + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> SlackResponse: + """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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + return self.api_call("admin.workflows.collaborators.remove", params=kwargs) + + def admin_workflows_unpublish( + self, + *, + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> SlackResponse: + """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}) + return self.api_call("admin.workflows.unpublish", params=kwargs) + def api_test( self, *, diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py index c61b5f46..d0e11cde 100644 --- a/slack_sdk/web/legacy_client.py +++ b/slack_sdk/web/legacy_client.py @@ -304,6 +304,82 @@ def admin_apps_uninstall( kwargs.update({"team_ids": team_ids}) return self.api_call("admin.apps.uninstall", http_verb="POST", params=kwargs) + 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, + ) -> Union[Future, SlackResponse]: + """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 self.api_call("admin.apps.activities.list", params=kwargs) + + def admin_apps_config_lookup( + self, + *, + app_ids: Union[str, Sequence[str]], + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + return self.api_call("admin.apps.config.lookup", params=kwargs) + + def admin_apps_config_set( + self, + *, + app_id: str, + domain_restrictions: Optional[dict] = None, + workflow_auth_strategy: Optional[str] = None, + **kwargs, + ) -> Union[Future, SlackResponse]: + """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)}) + return self.api_call("admin.apps.config.set", params=kwargs) + def admin_auth_policy_getEntities( self, *, @@ -950,6 +1026,72 @@ def admin_emoji_rename( kwargs.update({"name": name, "new_name": new_name}) return self.api_call("admin.emoji.rename", http_verb="GET", params=kwargs) + 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, + ) -> Union[Future, SlackResponse]: + """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}) + kwargs.update( + { + "team_id": team_id, + "cursor": cursor, + "limit": limit, + } + ) + return self.api_call("admin.functions.list", params=kwargs) + + def admin_functions_permissions_lookup( + self, + *, + function_ids: Union[str, Sequence[str]], + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + return self.api_call("admin.functions.permissions.lookup", params=kwargs) + + def admin_functions_permissions_set( + self, + *, + function_id: str, + visibility: str, + user_ids: Optional[Union[str, Sequence[str]]] = None, + **kwargs, + ) -> Union[Future, SlackResponse]: + """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)}) + else: + kwargs.update({"user_ids": user_ids}) + return self.api_call("admin.functions.permissions.set", params=kwargs) + def admin_roles_addAssignments( self, *, @@ -1618,6 +1760,120 @@ def admin_users_setRegular( kwargs.update({"team_id": team_id, "user_id": user_id}) return self.api_call("admin.users.setRegular", params=kwargs) + 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, + ) -> Union[Future, SlackResponse]: + """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)}) + else: + kwargs.update({"collaborator_ids": collaborator_ids}) + 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 self.api_call("admin.workflows.search", params=kwargs) + + def admin_workflows_permissions_lookup( + self, + *, + workflow_ids: Union[str, Sequence[str]], + max_workflow_triggers: Optional[int] = None, + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + kwargs.update( + { + "max_workflow_triggers": max_workflow_triggers, + } + ) + return self.api_call("admin.workflows.permissions.lookup", params=kwargs) + + def admin_workflows_collaborators_add( + self, + *, + collaborator_ids: Union[str, Sequence[str]], + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + return self.api_call("admin.workflows.collaborators.add", params=kwargs) + + def admin_workflows_collaborators_remove( + self, + *, + collaborator_ids: Union[str, Sequence[str]], + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + if isinstance(workflow_ids, (list, Tuple)): + kwargs.update({"workflow_ids": ",".join(workflow_ids)}) + else: + kwargs.update({"workflow_ids": workflow_ids}) + return self.api_call("admin.workflows.collaborators.remove", params=kwargs) + + def admin_workflows_unpublish( + self, + *, + workflow_ids: Union[str, Sequence[str]], + **kwargs, + ) -> Union[Future, SlackResponse]: + """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}) + return self.api_call("admin.workflows.unpublish", params=kwargs) + def api_test( self, *, diff --git a/tests/slack_sdk_async/web/test_web_client_coverage.py b/tests/slack_sdk_async/web/test_web_client_coverage.py index b678dee3..eecb5fe2 100644 --- a/tests/slack_sdk_async/web/test_web_client_coverage.py +++ b/tests/slack_sdk_async/web/test_web_client_coverage.py @@ -15,9 +15,9 @@ class TestWebClientCoverage(unittest.TestCase): - # 248 endpoints as of April 6, 2023 + # 260 endpoints as of September 7, 2023 # Can be fetched by running `var methodNames = [].slice.call(document.getElementsByClassName('apiReferenceFilterableList__listItemLink')).map(e => e.href.replace("https://api.slack.com/methods/", ""));console.log(methodNames.toString());console.log(methodNames.length);` on https://api.slack.com/methods - all_api_methods = "admin.analytics.getFile,admin.apps.approve,admin.apps.clearResolution,admin.apps.restrict,admin.apps.uninstall,admin.apps.approved.list,admin.apps.requests.cancel,admin.apps.requests.list,admin.apps.restricted.list,admin.audit.anomaly.allow.getItem,admin.audit.anomaly.allow.updateItem,admin.auth.policy.assignEntities,admin.auth.policy.getEntities,admin.auth.policy.removeEntities,admin.barriers.create,admin.barriers.delete,admin.barriers.list,admin.barriers.update,admin.conversations.archive,admin.conversations.bulkArchive,admin.conversations.bulkDelete,admin.conversations.bulkMove,admin.conversations.convertToPrivate,admin.conversations.convertToPublic,admin.conversations.create,admin.conversations.delete,admin.conversations.disconnectShared,admin.conversations.getConversationPrefs,admin.conversations.getCustomRetention,admin.conversations.getTeams,admin.conversations.invite,admin.conversations.lookup,admin.conversations.removeCustomRetention,admin.conversations.rename,admin.conversations.search,admin.conversations.setConversationPrefs,admin.conversations.setCustomRetention,admin.conversations.setTeams,admin.conversations.unarchive,admin.conversations.ekm.listOriginalConnectedChannelInfo,admin.conversations.restrictAccess.addGroup,admin.conversations.restrictAccess.listGroups,admin.conversations.restrictAccess.removeGroup,admin.emoji.add,admin.emoji.addAlias,admin.emoji.list,admin.emoji.remove,admin.emoji.rename,admin.inviteRequests.approve,admin.inviteRequests.deny,admin.inviteRequests.list,admin.inviteRequests.approved.list,admin.inviteRequests.denied.list,admin.roles.addAssignments,admin.roles.listAssignments,admin.roles.removeAssignments,admin.teams.admins.list,admin.teams.create,admin.teams.list,admin.teams.owners.list,admin.teams.settings.info,admin.teams.settings.setDefaultChannels,admin.teams.settings.setDescription,admin.teams.settings.setDiscoverability,admin.teams.settings.setIcon,admin.teams.settings.setName,admin.usergroups.addChannels,admin.usergroups.addTeams,admin.usergroups.listChannels,admin.usergroups.removeChannels,admin.users.assign,admin.users.invite,admin.users.list,admin.users.remove,admin.users.setAdmin,admin.users.setExpiration,admin.users.setOwner,admin.users.setRegular,admin.users.session.clearSettings,admin.users.session.getSettings,admin.users.session.invalidate,admin.users.session.list,admin.users.session.reset,admin.users.session.resetBulk,admin.users.session.setSettings,admin.users.unsupportedVersions.export,api.test,apps.auth.external.delete,apps.auth.external.get,apps.connections.open,apps.uninstall,apps.datastore.delete,apps.datastore.get,apps.datastore.put,apps.datastore.query,apps.datastore.update,apps.event.authorizations.list,apps.manifest.create,apps.manifest.delete,apps.manifest.export,apps.manifest.update,apps.manifest.validate,auth.revoke,auth.test,auth.teams.list,bookmarks.add,bookmarks.edit,bookmarks.list,bookmarks.remove,bots.info,calls.add,calls.end,calls.info,calls.update,calls.participants.add,calls.participants.remove,chat.delete,chat.deleteScheduledMessage,chat.getPermalink,chat.meMessage,chat.postEphemeral,chat.postMessage,chat.scheduleMessage,chat.unfurl,chat.update,chat.scheduledMessages.list,conversations.acceptSharedInvite,conversations.approveSharedInvite,conversations.archive,conversations.close,conversations.create,conversations.declineSharedInvite,conversations.history,conversations.info,conversations.invite,conversations.inviteShared,conversations.join,conversations.kick,conversations.leave,conversations.list,conversations.listConnectInvites,conversations.mark,conversations.members,conversations.open,conversations.rename,conversations.replies,conversations.setPurpose,conversations.setTopic,conversations.unarchive,dialog.open,dnd.endDnd,dnd.endSnooze,dnd.info,dnd.setSnooze,dnd.teamInfo,emoji.list,files.completeUploadExternal,files.delete,files.getUploadURLExternal,files.info,files.list,files.revokePublicURL,files.sharedPublicURL,files.upload,files.comments.delete,files.remote.add,files.remote.info,files.remote.list,files.remote.remove,files.remote.share,files.remote.update,functions.workflows.steps.list,functions.workflows.steps.responses.export,migration.exchange,oauth.access,oauth.v2.access,oauth.v2.exchange,openid.connect.token,openid.connect.userInfo,pins.add,pins.list,pins.remove,reactions.add,reactions.get,reactions.list,reactions.remove,reminders.add,reminders.complete,reminders.delete,reminders.info,reminders.list,rtm.connect,rtm.start,search.all,search.files,search.messages,stars.add,stars.list,stars.remove,team.accessLogs,team.billableInfo,team.info,team.integrationLogs,team.billing.info,team.preferences.list,team.profile.get,tooling.tokens.rotate,usergroups.create,usergroups.disable,usergroups.enable,usergroups.list,usergroups.update,usergroups.users.list,usergroups.users.update,users.conversations,users.deletePhoto,users.getPresence,users.identity,users.info,users.list,users.lookupByEmail,users.setActive,users.setPhoto,users.setPresence,users.profile.get,users.profile.set,views.open,views.publish,views.push,views.update,workflows.stepCompleted,workflows.stepFailed,workflows.updateStep,channels.create,channels.info,channels.invite,channels.mark,groups.create,groups.info,groups.invite,groups.mark,groups.open,im.list,im.mark,im.open,mpim.list,mpim.mark,mpim.open".split( + all_api_methods = "admin.analytics.getFile,admin.apps.activities.list,admin.apps.approve,admin.apps.clearResolution,admin.apps.restrict,admin.apps.uninstall,admin.apps.approved.list,admin.apps.config.lookup,admin.apps.config.set,admin.apps.requests.cancel,admin.apps.requests.list,admin.apps.restricted.list,admin.audit.anomaly.allow.getItem,admin.audit.anomaly.allow.updateItem,admin.auth.policy.assignEntities,admin.auth.policy.getEntities,admin.auth.policy.removeEntities,admin.barriers.create,admin.barriers.delete,admin.barriers.list,admin.barriers.update,admin.conversations.archive,admin.conversations.bulkArchive,admin.conversations.bulkDelete,admin.conversations.bulkMove,admin.conversations.convertToPrivate,admin.conversations.convertToPublic,admin.conversations.create,admin.conversations.delete,admin.conversations.disconnectShared,admin.conversations.getConversationPrefs,admin.conversations.getCustomRetention,admin.conversations.getTeams,admin.conversations.invite,admin.conversations.lookup,admin.conversations.removeCustomRetention,admin.conversations.rename,admin.conversations.search,admin.conversations.setConversationPrefs,admin.conversations.setCustomRetention,admin.conversations.setTeams,admin.conversations.unarchive,admin.conversations.ekm.listOriginalConnectedChannelInfo,admin.conversations.restrictAccess.addGroup,admin.conversations.restrictAccess.listGroups,admin.conversations.restrictAccess.removeGroup,admin.emoji.add,admin.emoji.addAlias,admin.emoji.list,admin.emoji.remove,admin.emoji.rename,admin.functions.list,admin.functions.permissions.lookup,admin.functions.permissions.set,admin.inviteRequests.approve,admin.inviteRequests.deny,admin.inviteRequests.list,admin.inviteRequests.approved.list,admin.inviteRequests.denied.list,admin.roles.addAssignments,admin.roles.listAssignments,admin.roles.removeAssignments,admin.teams.admins.list,admin.teams.create,admin.teams.list,admin.teams.owners.list,admin.teams.settings.info,admin.teams.settings.setDefaultChannels,admin.teams.settings.setDescription,admin.teams.settings.setDiscoverability,admin.teams.settings.setIcon,admin.teams.settings.setName,admin.usergroups.addChannels,admin.usergroups.addTeams,admin.usergroups.listChannels,admin.usergroups.removeChannels,admin.users.assign,admin.users.invite,admin.users.list,admin.users.remove,admin.users.setAdmin,admin.users.setExpiration,admin.users.setOwner,admin.users.setRegular,admin.users.session.clearSettings,admin.users.session.getSettings,admin.users.session.invalidate,admin.users.session.list,admin.users.session.reset,admin.users.session.resetBulk,admin.users.session.setSettings,admin.users.unsupportedVersions.export,admin.workflows.collaborators.add,admin.workflows.collaborators.remove,admin.workflows.permissions.lookup,admin.workflows.search,admin.workflows.unpublish,api.test,apps.activities.list,apps.auth.external.delete,apps.auth.external.get,apps.connections.open,apps.datastore.delete,apps.datastore.get,apps.datastore.put,apps.datastore.query,apps.datastore.update,apps.event.authorizations.list,apps.manifest.create,apps.manifest.delete,apps.manifest.export,apps.manifest.update,apps.manifest.validate,apps.uninstall,auth.revoke,auth.test,auth.teams.list,bookmarks.add,bookmarks.edit,bookmarks.list,bookmarks.remove,bots.info,calls.add,calls.end,calls.info,calls.update,calls.participants.add,calls.participants.remove,chat.delete,chat.deleteScheduledMessage,chat.getPermalink,chat.meMessage,chat.postEphemeral,chat.postMessage,chat.scheduleMessage,chat.unfurl,chat.update,chat.scheduledMessages.list,conversations.acceptSharedInvite,conversations.approveSharedInvite,conversations.archive,conversations.close,conversations.create,conversations.declineSharedInvite,conversations.history,conversations.info,conversations.invite,conversations.inviteShared,conversations.join,conversations.kick,conversations.leave,conversations.list,conversations.listConnectInvites,conversations.mark,conversations.members,conversations.open,conversations.rename,conversations.replies,conversations.setPurpose,conversations.setTopic,conversations.unarchive,dialog.open,dnd.endDnd,dnd.endSnooze,dnd.info,dnd.setSnooze,dnd.teamInfo,emoji.list,files.comments.delete,files.completeUploadExternal,files.delete,files.getUploadURLExternal,files.info,files.list,files.revokePublicURL,files.sharedPublicURL,files.upload,files.remote.add,files.remote.info,files.remote.list,files.remote.remove,files.remote.share,files.remote.update,functions.workflows.steps.list,functions.workflows.steps.responses.export,migration.exchange,oauth.access,oauth.v2.access,oauth.v2.exchange,openid.connect.token,openid.connect.userInfo,pins.add,pins.list,pins.remove,reactions.add,reactions.get,reactions.list,reactions.remove,reminders.add,reminders.complete,reminders.delete,reminders.info,reminders.list,rtm.connect,rtm.start,search.all,search.files,search.messages,stars.add,stars.list,stars.remove,team.accessLogs,team.billableInfo,team.info,team.integrationLogs,team.billing.info,team.preferences.list,team.profile.get,tooling.tokens.rotate,usergroups.create,usergroups.disable,usergroups.enable,usergroups.list,usergroups.update,usergroups.users.list,usergroups.users.update,users.conversations,users.deletePhoto,users.getPresence,users.identity,users.info,users.list,users.lookupByEmail,users.setActive,users.setPhoto,users.setPresence,users.profile.get,users.profile.set,views.open,views.publish,views.push,views.update,workflows.stepCompleted,workflows.stepFailed,workflows.updateStep,channels.create,channels.info,channels.invite,channels.mark,groups.create,groups.info,groups.invite,groups.mark,groups.open,im.list,im.mark,im.open,mpim.list,mpim.mark,mpim.open".split( "," ) @@ -48,7 +48,8 @@ def setUp(self): "apps.manifest.update", "apps.manifest.validate", "tooling.tokens.rotate", - # TODO: next-generation platform related stuff + # automation platform token required ones + "apps.activities.list", "apps.auth.external.delete", "apps.auth.external.get", "apps.datastore.delete", @@ -91,6 +92,15 @@ async def run_method(self, method_name, method, async_method): elif method_name == "admin_apps_clearResolution": self.api_methods_to_call.remove(method(app_id="AID123")["method"]) await async_method(app_id="AID123") + elif method_name == "admin_apps_activities_list": + self.api_methods_to_call.remove(method()["method"]) + await async_method() + elif method_name == "admin_apps_config_lookup": + self.api_methods_to_call.remove(method(app_ids=["A111"])["method"]) + await async_method(app_ids=["A111"]) + elif method_name == "admin_apps_config_set": + self.api_methods_to_call.remove(method(app_id="A111")["method"]) + await async_method(app_id="A111") elif method_name == "admin_auth_policy_getEntities": self.api_methods_to_call.remove(method(policy_name="policyname")["method"]) await async_method(policy_name="policyname") @@ -155,6 +165,15 @@ async def run_method(self, method_name, method, async_method): elif method_name == "admin_emoji_rename": self.api_methods_to_call.remove(method(name="eyes", new_name="eyez")["method"]) await async_method(name="eyes", new_name="eyez") + elif method_name == "admin_functions_list": + self.api_methods_to_call.remove(method(app_ids=["A111"])["method"]) + await async_method(app_ids=["A111"]) + elif method_name == "admin_functions_permissions_lookup": + self.api_methods_to_call.remove(method(function_ids=["A111"])["method"]) + await async_method(function_ids=["A111"]) + elif method_name == "admin_functions_permissions_set": + self.api_methods_to_call.remove(method(function_id="F", visibility="everyone")["method"]) + await async_method(function_id="F", visibility="everyone") elif method_name == "admin_inviteRequests_approve": self.api_methods_to_call.remove(method(invite_request_id="ID123")["method"]) await async_method(invite_request_id="ID123") @@ -332,6 +351,21 @@ async def run_method(self, method_name, method, async_method): elif method_name == "admin_users_session_clearSettings": self.api_methods_to_call.remove(method(user_ids=["W111"])["method"]) await async_method(user_ids=["W111"]) + elif method_name == "admin_workflows_search": + self.api_methods_to_call.remove(method()["method"]) + await async_method() + elif method_name == "admin_workflows_permissions_lookup": + self.api_methods_to_call.remove(method(workflow_ids=["W"])["method"]) + await async_method(workflow_ids=["W"]) + elif method_name == "admin_workflows_collaborators_add": + self.api_methods_to_call.remove(method(workflow_ids=["W"], collaborator_ids=["W111"])["method"]) + await async_method(workflow_ids=["W"], collaborator_ids=["W111"]) + elif method_name == "admin_workflows_collaborators_remove": + self.api_methods_to_call.remove(method(workflow_ids=["W"], collaborator_ids=["W111"])["method"]) + await async_method(workflow_ids=["W"], collaborator_ids=["W111"]) + elif method_name == "admin_workflows_unpublish": + self.api_methods_to_call.remove(method(workflow_ids=["W"])["method"]) + await async_method(workflow_ids=["W"]) elif method_name == "apps_event_authorizations_list": self.api_methods_to_call.remove(method(event_context="xxx")["method"]) await async_method(event_context="xxx")