-
Notifications
You must be signed in to change notification settings - Fork 852
Add v3.3 documents #939 #943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2e7f242
Add v3.3 documents #939
seratch 235a2c9
Apply suggestions from code review
seratch 22572ae
Update GitHub templates
seratch 70415f7
Apply more suggestions by Alissa
seratch 5923a4b
Run ./docs.sh
seratch fb73c37
Update docs-src/scim/index.rst
seratch 7caaf02
Apply suggestions from code review
seratch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| ============================================== | ||
| Audit Logs API Client | ||
| ============================================== | ||
|
|
||
| `Audit Logs API <https://api.slack.com/admins/audit-logs>`_ is a set of APIs for monitoring what’s happening in your `Enterprise Grid <https://api.slack.com/enterprise/grid>`_ organization. | ||
|
|
||
| The Audit Logs API can be used by security information and event management (SIEM) tools to provide an analysis of how your Slack organization is being accessed. You can also use this API to write your own applications to see how members of your organization are using Slack. | ||
|
|
||
| Follow the instructions in `the API document <https://api.slack.com/admins/audit-logs>`_ to get a valid token for using Audit Logs API. The Slack app using the Audit Logs API needs to be installed in the Enterprise Grid Organization, not an individual workspace within the organization. | ||
|
|
||
| AuditLogsClient | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| An OAuth token with `the admin scope <https://api.slack.com/scopes/admin>`_ is required to access this API. | ||
|
|
||
| You will likely use the ``/logs`` endpoint as it's the essential part of this API. | ||
|
|
||
| To learn about the available parameters for this endpoint, check out `this guide <https://api.slack.com/admins/audit-logs#how_to_call_the_audit_logs_api>`_. You can also learn more about the data structure of ``api_response.typed_body`` from `the class source code <https://github.com/slackapi/python-slack-sdk/blob/main/slack_sdk/audit_logs/v1/logs.py>`_. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import os | ||
| from slack_sdk.audit_logs import AuditLogsClient | ||
|
|
||
| client = AuditLogsClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"]) | ||
|
|
||
| api_response = self.client.logs(action="user_login", limit=1) | ||
| api_response.typed_body # slack_sdk.audit_logs.v1.LogsResponse | ||
|
|
||
| If you would like to access ``/schemes`` or ``/actions``, you can use the following methods: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| api_response = self.client.schemas() | ||
| api_response = self.client.actions() | ||
|
|
||
| AsyncAuditLogsClient | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| If you are keen to use asyncio for SCIM API calls, we offer AsyncSCIMClient for it. This client relies on aiohttp library. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from slack_sdk.audit_logs.async_client import AsyncAuditLogsClient | ||
| client = AsyncAuditLogsClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"]) | ||
|
|
||
| api_response = await self.client.logs(action="user_login", limit=1) | ||
| api_response.typed_body # slack_sdk.audit_logs.v1.LogsResponse | ||
|
|
||
|
|
||
| .. include:: ../metadata.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| ============================================== | ||
| SCIM API Client | ||
| ============================================== | ||
|
|
||
| `SCIM API <https://api.slack.com/scim>`_ is a set of APIs for provisioning and managing user accounts and groups. SCIM is used by Single Sign-On (SSO) services and identity providers to manage people across a variety of tools, including Slack. | ||
|
|
||
| `SCIM (System for Cross-domain Identity Management) <http://www.simplecloud.info/>`_ is supported by a myriad of services. It behaves slightly differently from other Slack APIs. | ||
|
|
||
| Refer to `the API document <https://api.slack.com/scim>`_ for more details. | ||
|
|
||
| SCIMClient | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| An OAuth token with `the admin scope <https://api.slack.com/scopes/admin>`_ is required to access the SCIM API. | ||
|
|
||
| To fetch provisioned user data, you can use the ``search_users`` method in the client. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import os | ||
| from slack_sdk.scim import SCIMClient | ||
|
|
||
| client = SCIMClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"]) | ||
|
|
||
| response = client.search_users( | ||
| start_index=1, | ||
| count=100, | ||
| filter="""filter=userName Eq "Carly"""", | ||
| ) | ||
| response.users # List[User] | ||
|
|
||
| Check out `the class source code <https://github.com/slackapi/python-slack-sdk/blob/main/slack_sdk/scim/v1/user.py>`_ to learn more about the structure of the ``user`` in ``response.users``. | ||
|
|
||
| Similarly, the ``search_groups`` method is available and the shape of the ``Group`` object can be `found here <https://github.com/slackapi/python-slack-sdk/blob/main/slack_sdk/scim/v1/group.py>`_. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| response = client.search_groups( | ||
| start_index=1, | ||
| count=10, | ||
| ) | ||
| response.groups # List[Group] | ||
|
|
||
| For creating, updating, and deleting users/groups: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # POST /Users | ||
| # Creates a user. Must include the user_name argument and at least one email address. | ||
| # You may provide an email address as the user_name value, | ||
| # but it will be automatically converted to a Slack-appropriate username. | ||
| user = User( | ||
| user_name="cal", | ||
| name=UserName(given_name="C", family_name="Henderson"), | ||
| emails=[UserEmail(value="your-unique-name@example.com")], | ||
| ) | ||
| creation_result = self.client.create_user(user) | ||
|
|
||
| # PATCH /Users/{user_id} | ||
| # Updates an existing user resource, overwriting values for specified attributes. | ||
| patch_result = self.client.patch_user( | ||
| id=creation_result.user.id, | ||
| partial_user=User(user_name="chenderson"), | ||
| ) | ||
|
|
||
| # PUT /Users/{user_id} | ||
| # Updates an existing user resource, overwriting all values for a user | ||
| # even if an attribute is empty or not provided. | ||
| user_to_update = patch_result.user | ||
| user_to_update.name = UserName(given_name="Cal", family_name="Henderson") | ||
| update_result = self.client.update_user(user=user_to_update) | ||
|
|
||
| # DELETE /Users/{user_id} | ||
| # Sets a Slack user to deactivated. The value of the {id} | ||
| # should be the user's corresponding Slack ID, beginning with either U or W. | ||
| delete_result = self.client.delete_user(user_to_update.id) | ||
|
|
||
| AsyncSCIMClient | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Lastly, if you are keen to use asyncio for SCIM API calls, we offer ``AsyncSCIMClient`` for it. This client relies on aiohttp library. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import asyncio | ||
| import os | ||
| from slack_sdk.scim.async_client import AsyncSCIMClient | ||
|
|
||
| client = AsyncSCIMClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"]) | ||
|
|
||
| async def main(): | ||
| response = await client.search_groups(start_index=1, count=2) | ||
| print(response.groups) | ||
|
|
||
| asyncio.run(main()) | ||
|
|
||
| .. include:: ../metadata.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very helpful comment to add to the docs!