Skip to content

Commit b88b8cf

Browse files
authored
Adding new admin and remote files API methods. (#501)
* Adding new admin and remote files API methods. * Adding validation for 'admin.apps.approve' API
1 parent add2757 commit b88b8cf

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

slack/web/client.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,56 @@ class WebClient(BaseClient):
6666
removed at anytime.
6767
"""
6868

69+
def admin_apps_approve(
70+
self, *, app_id: str = None, request_id: str = None, **kwargs
71+
) -> Union[Future, SlackResponse]:
72+
"""Approve an app for installation on a workspace.
73+
74+
Either app_id or request_id is required.
75+
These IDs can be obtained either directly via the app_requested event,
76+
or by the admin.apps.requests.list method.
77+
78+
Args:
79+
app_id (str): The id of the app to approve. e.g. 'A12345'
80+
request_id (str): The id of the request to approve. e.g. 'Ar12345'
81+
Raises:
82+
SlackRequestError: If niether or both the `app_id` and `request_id` args are specified.
83+
"""
84+
self._validate_xoxp_token()
85+
86+
if app_id:
87+
kwargs.update({"app_id": app_id})
88+
elif request_id:
89+
kwargs.update({"request_id": request_id})
90+
else:
91+
raise e.SlackRequestError(
92+
"The app_id or request_id argument must be specified."
93+
)
94+
95+
return self.api_call("admin.apps.approve", json=kwargs)
96+
97+
def admin_apps_requests_list(self, **kwargs) -> Union[Future, SlackResponse]:
98+
"""List app requests for a team/workspace."""
99+
self._validate_xoxp_token()
100+
return self.api_call("admin.apps.requests.list", http_verb="GET", params=kwargs)
101+
102+
def admin_apps_restrict(self, **kwargs) -> Union[Future, SlackResponse]:
103+
"""Restrict an app for installation on a workspace."""
104+
self._validate_xoxp_token()
105+
return self.api_call("admin.apps.restrict", json=kwargs)
106+
107+
def admin_users_session_reset(
108+
self, *, user_id: str, **kwargs
109+
) -> Union[Future, SlackResponse]:
110+
"""Wipes all valid sessions on all devices for a given user.
111+
112+
Args:
113+
user_id (str): The ID of the user to wipe sessions for. e.g. 'W12345678'
114+
"""
115+
self._validate_xoxp_token()
116+
kwargs.update({"user_id": user_id})
117+
return self.api_call("admin.users.session.reset", json=kwargs)
118+
69119
def api_test(self, **kwargs) -> Union[Future, SlackResponse]:
70120
"""Checks API calling code."""
71121
return self.api_call("api.test", json=kwargs)
@@ -667,6 +717,49 @@ def files_list(self, **kwargs) -> Union[Future, SlackResponse]:
667717
self._validate_xoxp_token()
668718
return self.api_call("files.list", http_verb="GET", params=kwargs)
669719

720+
def files_remote_info(self, **kwargs) -> Union[Future, SlackResponse]:
721+
"""Retrieve information about a remote file added to Slack."""
722+
return self.api_call("files.remote.info", http_verb="GET", params=kwargs)
723+
724+
def files_remote_list(self, **kwargs) -> Union[Future, SlackResponse]:
725+
"""Retrieve information about a remote file added to Slack."""
726+
return self.api_call("files.remote.list", http_verb="GET", params=kwargs)
727+
728+
def files_remote_add(
729+
self, *, external_id: str, external_url: str, title: str, **kwargs
730+
) -> Union[Future, SlackResponse]:
731+
"""Adds a file from a remote service.
732+
733+
Args:
734+
external_id (str): Creator defined GUID for the file. e.g. '123456'
735+
external_url (str): URL of the remote file. e.g. 'http://example.com/my_cloud_service_file/abc123'
736+
title (str): Title of the file being shared. e.g. 'Danger, High Voltage!'
737+
"""
738+
kwargs.update(
739+
{"external_id": external_id, "external_url": external_url, "title": title}
740+
)
741+
return self.api_call("files.remote.add", http_verb="GET", params=kwargs)
742+
743+
def files_remote_update(self, **kwargs) -> Union[Future, SlackResponse]:
744+
"""Updates an existing remote file."""
745+
return self.api_call("files.remote.update", http_verb="GET", params=kwargs)
746+
747+
def files_remote_remove(self, **kwargs) -> Union[Future, SlackResponse]:
748+
"""Remove a remote file."""
749+
return self.api_call("files.remote.remove", http_verb="GET", params=kwargs)
750+
751+
def files_remote_share(
752+
self, *, channels: Union[str, List[str]], **kwargs
753+
) -> Union[Future, SlackResponse]:
754+
"""Share a remote file into a channel.
755+
756+
Args:
757+
channels (list): Comma-separated list of channel IDs where the file will be shared.
758+
e.g. ['C1234567890', 'C2345678901']
759+
"""
760+
kwargs.update({"channels": channels})
761+
return self.api_call("files.remote.share", http_verb="GET", params=kwargs)
762+
670763
def files_revokePublicURL(
671764
self, *, file: str, **kwargs
672765
) -> Union[Future, SlackResponse]:

0 commit comments

Comments
 (0)