Skip to main content

Slack SCIM API Client

Reason this release was yanked:

had a critical bug

Project description

slack-scim - Slack SCIM API Client

PyPI version Build Status

This library provides ways to call Slack's SCIM APIs in the Pythonic way.

Getting Started

Installation

pip install slack-scim

User Management

https://api.slack.com/scim#users

import os
from slack_scim import Users, User
from slack_scim import SCIMClient, SCIMApiError

# `admin` scope required
token = os.environ["SLACK_ADMIN_TOKEN"]
client = SCIMClient(token=token)
try:
    search_result: Users = client.search_users(filter="restricted eq '1'", count=3)
    user_id = search_result.resources[0].id
    read_result: User = client.read_user(user_id)
except SCIMApiError as err:
    if err.status == 429:
        # handle rate limit errors
        pass

new_user: User = User.from_dict({
    "name": {
        "givenName": "Kazuhiro",
        "familyName": "Sera",
    },
    "emails": [{"value": "your-name@example.com"}],
    "userName": "seratch",
})
creation_result: User = client.create_user(new_user)
user_id = creation_result.id

patch_result: User = client.patch_user(user_id, {
    "name": {
        "givenName": "Kaz"
    }
})

patch_result.name.given_name = "K"
update_result: User = client.update_user(user_id, patch_result)

client.delete_user(user_id)

Group Management

https://api.slack.com/scim#groups

import os
from slack_scim import Groups, Group, GroupMember, SCIMClient, User

# `admin` scope required
token = os.environ["SLACK_ADMIN_TOKEN"]
client = SCIMClient(token=token)

display_name = "test-group-123"
new_group: Group = Group.from_dict({"displayName": display_name})
created_user: User = client.create_user(User.from_dict({
    "name": {
        "givenName": "Kazuhiro",
        "familyName": "Sera",
    },
    "emails": [{"value": "your-name@example.com"}],
    "userName": "seratch",
}))
new_group.members = [GroupMember.from_dict(created_user.to_dict())]
creation_result: Group = client.create_group(new_group)
if not creation_result:
    search_result: Groups = client.search_groups(filter=f"displayName eq {display_name}", count=1)
    creation_result: Group = search_result.resources[0]
group_id = creation_result.id

client.patch_group(group_id, {"displayName": display_name + "-2"})
patch_result: Group = client.read_group(group_id)

patch_result.display_name = display_name + "-3"
client.update_group(group_id, patch_result)
update_result = client.read_group(group_id)

client.delete_group(group_id)

License

The MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slack-scim-1.0.2.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

slack_scim-1.0.2-py2.py3-none-any.whl (18.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file slack-scim-1.0.2.tar.gz.

File metadata

  • Download URL: slack-scim-1.0.2.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for slack-scim-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fc738e8a8cdad29c3456255d79021ba98587689c2455abaec47996eb6e91cad4
MD5 05293ff558a634f0b87bb861bd9e4783
BLAKE2b-256 1228e4dae500ad8764574176449710ac1509b8aec0e54b2990fc075edc006939

See more details on using hashes here.

File details

Details for the file slack_scim-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: slack_scim-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for slack_scim-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5e647cb269ce324ba6429ec9f79d9fcbab7a841ed81b52443b10766be8d8be92
MD5 9e5e235cc9aa07b40cc682e5bd9303f3
BLAKE2b-256 1fbb62d0d0d43ec1e5623cc6735ea4d46b52c2988aa1337944e9f21390ed9781

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page