slack-objects 0.0.post31__tar.gz → 0.0.post34__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. slack_objects-0.0.post34/PKG-INFO +157 -0
  2. slack_objects-0.0.post34/README.md +141 -0
  3. slack_objects-0.0.post34/dist/slack_objects-0.0.post31-py3-none-any.whl +0 -0
  4. slack_objects-0.0.post34/dist/slack_objects-0.0.post31.tar.gz +0 -0
  5. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/pyproject.toml +1 -1
  6. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/_version.py +3 -3
  7. slack_objects-0.0.post34/src/slack_objects.egg-info/PKG-INFO +157 -0
  8. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects.egg-info/SOURCES.txt +2 -0
  9. slack_objects-0.0.post31/PKG-INFO +0 -201
  10. slack_objects-0.0.post31/README.md +0 -185
  11. slack_objects-0.0.post31/src/slack_objects.egg-info/PKG-INFO +0 -201
  12. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/.gitignore +0 -0
  13. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/.vs/VSWorkspaceState.json +0 -0
  14. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/.vs/slnx.sqlite +0 -0
  15. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/LICENSE +0 -0
  16. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/pytest.ini +0 -0
  17. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/setup.cfg +0 -0
  18. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/__init__.py +0 -0
  19. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/api_caller.py +0 -0
  20. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/base.py +0 -0
  21. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/client.py +0 -0
  22. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/config.py +0 -0
  23. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/conversations.py +0 -0
  24. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/files.py +0 -0
  25. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/idp_groups.py +0 -0
  26. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/messages.py +0 -0
  27. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/rate_limits.py +0 -0
  28. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/users.py +0 -0
  29. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects/workspaces.py +0 -0
  30. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects.egg-info/dependency_links.txt +0 -0
  31. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects.egg-info/requires.txt +0 -0
  32. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/src/slack_objects.egg-info/top_level.txt +0 -0
  33. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/_smoke_harness.py +0 -0
  34. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/conversations_example_test.py +0 -0
  35. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/conversations_smoke_test.py +0 -0
  36. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/files_example_test.py +0 -0
  37. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/files_smoke_test.py +0 -0
  38. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/idp_groups_example_test.py +0 -0
  39. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/idp_groups_smoke_test.py +0 -0
  40. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/messages_example_test.py +0 -0
  41. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/messages_smoke_test.py +0 -0
  42. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/run_all_smoke.py +0 -0
  43. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/users_example_test.py +0 -0
  44. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/users_smoke_test.py +0 -0
  45. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/users_test_AzureKeyVault.py +0 -0
  46. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/workspaces_example_test.py +0 -0
  47. {slack_objects-0.0.post31 → slack_objects-0.0.post34}/tests/workspaces_smoke_test.py +0 -0
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: slack-objects
3
+ Version: 0.0.post34
4
+ Summary: Opinionated, testable Python wrappers for Slack’s Web, Admin, and SCIM APIs, organized by object domain (users, conversations, messages, files, workspaces, and IdP groups). Designed for automation and administration workflows.
5
+ Author-email: "Marcos E. Mercado" <marcos_elias@hotmail.com>
6
+ Keywords: slack,objects,classes,slack objects,utilities,slack utilities,slack object types,slack types,types
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: slack-sdk
14
+ Requires-Dist: PC_Utils
15
+ Dynamic: license-file
16
+
17
+ # slack-objects
18
+
19
+ A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
20
+
21
+ `slack-objects` provides **opinionated, testable wrappers** around the Slack Web API, Admin API, and SCIM API—favoring object-based access over raw endpoint calls.
22
+
23
+ ---
24
+
25
+ ## Supported Slack Objects
26
+
27
+ The following Slack object types are supported:
28
+
29
+ - **Users**
30
+ - **Conversations** (e.g, channels)
31
+ - **Messages**
32
+ - **Files**
33
+ - **Workspaces**
34
+ - **IDP Groups** (SCIM - e.g., Okta groups)
35
+
36
+ ---
37
+
38
+ ## Overview
39
+
40
+ `slack-objects` is designed for:
41
+
42
+ - Slack administration automation
43
+ - Identity and access management (IAM) workflows
44
+ - Internal tooling and bots
45
+ - Auditing and cleanup scripts
46
+
47
+ This package is **not** a replacement for `slack_sdk`.
48
+ Instead, it focuses on higher-level object operations that typically require:
49
+
50
+ - multiple API calls
51
+ - pagination
52
+ - rate limiting
53
+ - Admin API or SCIM usage
54
+ - non-trivial orchestration logic
55
+
56
+ ---
57
+
58
+ ## Design Highlights
59
+
60
+ ### Factory-based API
61
+
62
+ All object helpers are created from a single entry point:
63
+
64
+ ```python
65
+ from slack_objects.client import SlackObjectsClient
66
+
67
+ slack = SlackObjectsClient(cfg)
68
+
69
+ users = slack.users()
70
+ alice = slack.users("U123")
71
+
72
+ conversations = slack.conversations()
73
+ general = slack.conversations("C123")
74
+ ```
75
+
76
+ This avoids global state while keeping usage concise and consistent.
77
+
78
+ ---
79
+
80
+ ### Explicit token model
81
+
82
+ Slack APIs have different authorization requirements.
83
+ This package keeps tokens **explicit and separate**:
84
+
85
+ | Token | Used for |
86
+ |-----|---------|
87
+ | `bot_token` | Slack Web API (most read/write operations) |
88
+ | `user_token` | Slack Admin API |
89
+ | `scim_token` | Slack SCIM API (IdP / provisioning) |
90
+
91
+ Tokens are **optional in configuration**, but **required by methods that need them**.
92
+ Errors are raised at call time with clear messages.
93
+
94
+ ---
95
+
96
+ ### Strict method boundaries
97
+
98
+ Each object follows a consistent internal structure:
99
+
100
+ ```
101
+ public method
102
+ → wrapper method
103
+ → SlackApiCaller / SCIM request
104
+ ```
105
+
106
+ ---
107
+
108
+ ### Keyword-only APIs
109
+
110
+ Methods with multiple optional parameters use **keyword-only arguments** to avoid ambiguity and future breaking changes.
111
+
112
+ ---
113
+
114
+ ### Testability
115
+
116
+ The codebase is designed to be tested **without hitting Slack**.
117
+
118
+ ---
119
+
120
+ ## Installation
121
+
122
+ ```bash
123
+ pip install slack-objects
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Configuration
129
+
130
+ ```python
131
+ from slack_objects.config import SlackObjectsConfig, RateTier
132
+
133
+ cfg = SlackObjectsConfig(
134
+ bot_token="xoxb-...",
135
+ user_token="xoxp-...",
136
+ scim_token="xoxp-...",
137
+ default_rate_tier=RateTier.TIER_3,
138
+ )
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Testing
144
+
145
+ Run all smoke tests:
146
+
147
+ ```bash
148
+ python -m tests.run_all_smoke
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Notes
154
+
155
+ - SCIM v1 is the default; v2 is supported where applicable
156
+ - Guest expiration dates use `PC_Utils.Datetime` if installed
157
+ - This package is intended for automation and administration workflows
@@ -0,0 +1,141 @@
1
+ # slack-objects
2
+
3
+ A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
4
+
5
+ `slack-objects` provides **opinionated, testable wrappers** around the Slack Web API, Admin API, and SCIM API—favoring object-based access over raw endpoint calls.
6
+
7
+ ---
8
+
9
+ ## Supported Slack Objects
10
+
11
+ The following Slack object types are supported:
12
+
13
+ - **Users**
14
+ - **Conversations** (e.g, channels)
15
+ - **Messages**
16
+ - **Files**
17
+ - **Workspaces**
18
+ - **IDP Groups** (SCIM - e.g., Okta groups)
19
+
20
+ ---
21
+
22
+ ## Overview
23
+
24
+ `slack-objects` is designed for:
25
+
26
+ - Slack administration automation
27
+ - Identity and access management (IAM) workflows
28
+ - Internal tooling and bots
29
+ - Auditing and cleanup scripts
30
+
31
+ This package is **not** a replacement for `slack_sdk`.
32
+ Instead, it focuses on higher-level object operations that typically require:
33
+
34
+ - multiple API calls
35
+ - pagination
36
+ - rate limiting
37
+ - Admin API or SCIM usage
38
+ - non-trivial orchestration logic
39
+
40
+ ---
41
+
42
+ ## Design Highlights
43
+
44
+ ### Factory-based API
45
+
46
+ All object helpers are created from a single entry point:
47
+
48
+ ```python
49
+ from slack_objects.client import SlackObjectsClient
50
+
51
+ slack = SlackObjectsClient(cfg)
52
+
53
+ users = slack.users()
54
+ alice = slack.users("U123")
55
+
56
+ conversations = slack.conversations()
57
+ general = slack.conversations("C123")
58
+ ```
59
+
60
+ This avoids global state while keeping usage concise and consistent.
61
+
62
+ ---
63
+
64
+ ### Explicit token model
65
+
66
+ Slack APIs have different authorization requirements.
67
+ This package keeps tokens **explicit and separate**:
68
+
69
+ | Token | Used for |
70
+ |-----|---------|
71
+ | `bot_token` | Slack Web API (most read/write operations) |
72
+ | `user_token` | Slack Admin API |
73
+ | `scim_token` | Slack SCIM API (IdP / provisioning) |
74
+
75
+ Tokens are **optional in configuration**, but **required by methods that need them**.
76
+ Errors are raised at call time with clear messages.
77
+
78
+ ---
79
+
80
+ ### Strict method boundaries
81
+
82
+ Each object follows a consistent internal structure:
83
+
84
+ ```
85
+ public method
86
+ → wrapper method
87
+ → SlackApiCaller / SCIM request
88
+ ```
89
+
90
+ ---
91
+
92
+ ### Keyword-only APIs
93
+
94
+ Methods with multiple optional parameters use **keyword-only arguments** to avoid ambiguity and future breaking changes.
95
+
96
+ ---
97
+
98
+ ### Testability
99
+
100
+ The codebase is designed to be tested **without hitting Slack**.
101
+
102
+ ---
103
+
104
+ ## Installation
105
+
106
+ ```bash
107
+ pip install slack-objects
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Configuration
113
+
114
+ ```python
115
+ from slack_objects.config import SlackObjectsConfig, RateTier
116
+
117
+ cfg = SlackObjectsConfig(
118
+ bot_token="xoxb-...",
119
+ user_token="xoxp-...",
120
+ scim_token="xoxp-...",
121
+ default_rate_tier=RateTier.TIER_3,
122
+ )
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Testing
128
+
129
+ Run all smoke tests:
130
+
131
+ ```bash
132
+ python -m tests.run_all_smoke
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Notes
138
+
139
+ - SCIM v1 is the default; v2 is supported where applicable
140
+ - Guest expiration dates use `PC_Utils.Datetime` if installed
141
+ - This package is intended for automation and administration workflows
@@ -9,7 +9,7 @@ dynamic = ["version"]
9
9
  authors = [
10
10
  {name="Marcos E. Mercado", email="marcos_elias@hotmail.com"},
11
11
  ]
12
- description = "This package defines classes for working with slack objects like users, conversations, messages, etc."
12
+ description = "Opinionated, testable Python wrappers for Slack’s Web, Admin, and SCIM APIs, organized by object domain (users, conversations, messages, files, workspaces, and IdP groups). Designed for automation and administration workflows."
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.8"
15
15
  classifiers=[
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.post31'
32
- __version_tuple__ = version_tuple = (0, 0, 'post31')
31
+ __version__ = version = '0.0.post34'
32
+ __version_tuple__ = version_tuple = (0, 0, 'post34')
33
33
 
34
- __commit_id__ = commit_id = 'gcf17794dd'
34
+ __commit_id__ = commit_id = 'g37a2879de'
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: slack-objects
3
+ Version: 0.0.post34
4
+ Summary: Opinionated, testable Python wrappers for Slack’s Web, Admin, and SCIM APIs, organized by object domain (users, conversations, messages, files, workspaces, and IdP groups). Designed for automation and administration workflows.
5
+ Author-email: "Marcos E. Mercado" <marcos_elias@hotmail.com>
6
+ Keywords: slack,objects,classes,slack objects,utilities,slack utilities,slack object types,slack types,types
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: slack-sdk
14
+ Requires-Dist: PC_Utils
15
+ Dynamic: license-file
16
+
17
+ # slack-objects
18
+
19
+ A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
20
+
21
+ `slack-objects` provides **opinionated, testable wrappers** around the Slack Web API, Admin API, and SCIM API—favoring object-based access over raw endpoint calls.
22
+
23
+ ---
24
+
25
+ ## Supported Slack Objects
26
+
27
+ The following Slack object types are supported:
28
+
29
+ - **Users**
30
+ - **Conversations** (e.g, channels)
31
+ - **Messages**
32
+ - **Files**
33
+ - **Workspaces**
34
+ - **IDP Groups** (SCIM - e.g., Okta groups)
35
+
36
+ ---
37
+
38
+ ## Overview
39
+
40
+ `slack-objects` is designed for:
41
+
42
+ - Slack administration automation
43
+ - Identity and access management (IAM) workflows
44
+ - Internal tooling and bots
45
+ - Auditing and cleanup scripts
46
+
47
+ This package is **not** a replacement for `slack_sdk`.
48
+ Instead, it focuses on higher-level object operations that typically require:
49
+
50
+ - multiple API calls
51
+ - pagination
52
+ - rate limiting
53
+ - Admin API or SCIM usage
54
+ - non-trivial orchestration logic
55
+
56
+ ---
57
+
58
+ ## Design Highlights
59
+
60
+ ### Factory-based API
61
+
62
+ All object helpers are created from a single entry point:
63
+
64
+ ```python
65
+ from slack_objects.client import SlackObjectsClient
66
+
67
+ slack = SlackObjectsClient(cfg)
68
+
69
+ users = slack.users()
70
+ alice = slack.users("U123")
71
+
72
+ conversations = slack.conversations()
73
+ general = slack.conversations("C123")
74
+ ```
75
+
76
+ This avoids global state while keeping usage concise and consistent.
77
+
78
+ ---
79
+
80
+ ### Explicit token model
81
+
82
+ Slack APIs have different authorization requirements.
83
+ This package keeps tokens **explicit and separate**:
84
+
85
+ | Token | Used for |
86
+ |-----|---------|
87
+ | `bot_token` | Slack Web API (most read/write operations) |
88
+ | `user_token` | Slack Admin API |
89
+ | `scim_token` | Slack SCIM API (IdP / provisioning) |
90
+
91
+ Tokens are **optional in configuration**, but **required by methods that need them**.
92
+ Errors are raised at call time with clear messages.
93
+
94
+ ---
95
+
96
+ ### Strict method boundaries
97
+
98
+ Each object follows a consistent internal structure:
99
+
100
+ ```
101
+ public method
102
+ → wrapper method
103
+ → SlackApiCaller / SCIM request
104
+ ```
105
+
106
+ ---
107
+
108
+ ### Keyword-only APIs
109
+
110
+ Methods with multiple optional parameters use **keyword-only arguments** to avoid ambiguity and future breaking changes.
111
+
112
+ ---
113
+
114
+ ### Testability
115
+
116
+ The codebase is designed to be tested **without hitting Slack**.
117
+
118
+ ---
119
+
120
+ ## Installation
121
+
122
+ ```bash
123
+ pip install slack-objects
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Configuration
129
+
130
+ ```python
131
+ from slack_objects.config import SlackObjectsConfig, RateTier
132
+
133
+ cfg = SlackObjectsConfig(
134
+ bot_token="xoxb-...",
135
+ user_token="xoxp-...",
136
+ scim_token="xoxp-...",
137
+ default_rate_tier=RateTier.TIER_3,
138
+ )
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Testing
144
+
145
+ Run all smoke tests:
146
+
147
+ ```bash
148
+ python -m tests.run_all_smoke
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Notes
154
+
155
+ - SCIM v1 is the default; v2 is supported where applicable
156
+ - Guest expiration dates use `PC_Utils.Datetime` if installed
157
+ - This package is intended for automation and administration workflows
@@ -5,6 +5,8 @@ pyproject.toml
5
5
  pytest.ini
6
6
  .vs/VSWorkspaceState.json
7
7
  .vs/slnx.sqlite
8
+ dist/slack_objects-0.0.post31-py3-none-any.whl
9
+ dist/slack_objects-0.0.post31.tar.gz
8
10
  src/slack_objects/__init__.py
9
11
  src/slack_objects/_version.py
10
12
  src/slack_objects/api_caller.py
@@ -1,201 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: slack-objects
3
- Version: 0.0.post31
4
- Summary: This package defines classes for working with slack objects like users, conversations, messages, etc.
5
- Author-email: "Marcos E. Mercado" <marcos_elias@hotmail.com>
6
- Keywords: slack,objects,classes,slack objects,utilities,slack utilities,slack object types,slack types,types
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: slack-sdk
14
- Requires-Dist: PC_Utils
15
- Dynamic: license-file
16
-
17
- # slack-objects
18
-
19
- A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
20
-
21
- The following Slack object types will be supported:
22
-
23
- - **Users**
24
- - **Conversations**
25
- - **Messages**
26
- - **Files**
27
- - **Workspaces**
28
- - **IDP_groups**
29
-
30
-
31
- ---
32
-
33
- ## Overview
34
-
35
- `slack-objects` provides lightweight, reusable classes that wrap Slack Web API, Admin API, and SCIM operations in a consistent, object-oriented way. It is designed for:
36
-
37
- - Slack administration automation
38
- - Identity and access management flows
39
- - Internal tooling and bots
40
- - Auditing and cleanup scripts
41
-
42
- The package does **not** aim to be a full Slack SDK replacement. Instead, it focuses on common higher-level tasks that typically require multiple API calls and boilerplate logic.
43
-
44
- ---
45
-
46
- ## Requirements
47
-
48
- - Python **3.9+**
49
- - Slack app with appropriate scopes
50
- - Tokens provided via environment variables or from Azure KeyVault using PC_Azure package (`python -m pip install PC_Azure`)
51
-
52
- Typical dependencies:
53
- - `slack_sdk`
54
- - `requests`
55
- - `python-dotenv` (optional)
56
- - `PC_Azure` (optional)
57
-
58
- ---
59
-
60
- ## Installation
61
-
62
- ```bash
63
- pip install -r requirements.txt
64
- ```
65
-
66
- ## Classes and usage
67
-
68
- ### `Users`
69
-
70
- Purpose: actions related to Slack users.
71
-
72
- Constructor:
73
- ```python
74
- Users(global_vars, client, logger, user_id="")
75
- ```
76
-
77
- Key methods:
78
- - `is_contingent_worker()` → bool using name/display name label `[External]`.
79
- - `is_guest()` → bool if `is_restricted` or `is_ultra_restricted`.
80
- - `make_multi_channel_guest(token, scim_version='v1')` → `requests.Response` via SCIM (v1/v2).
81
- - `remove_from_channels(token, client, logger, channel_ids)` → remove user from channels (admin API).
82
- - `remove_from_workspaces(client, logger, workspace_ids, keep=[])` → remove user from workspaces.
83
- - `ap_studio_process()` → composite flow: convert to MCG, remove from org-wide channels, remove from other workspaces.
84
- - `get_userId_from_email(email)` → Slack user ID or empty string.
85
- - `is_user_authorized(service_name, auth_level='read')` → bool based on IdP group membership.
86
- - `invite_user(channel_ids, email, team_id, email_password_policy_enabled=False)` → invite a user, returns response string.
87
-
88
- Example:
89
- ```python
90
- u = Users(global_vars, client, logger, user_id="U123")
91
- if u.is_contingent_worker():
92
- u.make_multi_channel_guest(token=global_vars.user_token)
93
- ```
94
-
95
- ### `Conversations`
96
-
97
- Purpose: actions related to conversations (e.g., channels).
98
-
99
- Constructor:
100
- ```python
101
- Conversations(global_vars, client, logger, channel_id)
102
- ```
103
-
104
- Key methods:
105
- - `is_private()` → bool.
106
- - `get_messages(channel_id="", include_all_metadata=False, limit=None, inclusive=True, latest=None, oldest=None)` → list of messages using `conversations.history` with pagination.
107
-
108
- Example:
109
- ```python
110
- ch = Conversations(global_vars, client, logger, channel_id="C123")
111
- msgs = ch.get_messages(limit=100)
112
- ```
113
-
114
- ### `Messages`
115
-
116
- Purpose: manage Slack messages and blocks.
117
-
118
- Constructor:
119
- ```python
120
- Messages(global_vars, client, logger, channel_id, ts, message=None)
121
- ```
122
-
123
- Key methods:
124
- - `update_message(as_user=True, channel_id="", message_ts="", new_message_blocks=[], new_message_text="", new_message_attachments="")` → update message via `chat.update`.
125
- - `replace_message_block(blocks=[], block_type="", block_id="", text="", new_block={}, new_block_id="")` → find a block by type or id and replace it, then update message.
126
-
127
- Example:
128
- ```python
129
- msg = Messages(global_vars, client, logger, "C123", "1717000000.000100")
130
- msg.update_message(new_message_text="Updated content")
131
- ```
132
-
133
- ### `Files`
134
-
135
- Purpose: interact with files in Slack.
136
-
137
- Constructor:
138
- ```python
139
- Files(global_vars, client, logger, file_id="", get_content=False)
140
- ```
141
-
142
- Key methods:
143
- - `get_text_content()` → fetch content for text files via `url_private` (uses bot token).
144
- - `upload_to_slack(title, channel="", thread_ts="")` → upload the current file content via `files_upload_v2`.
145
- - `delete_file(file_id="")` → delete a file by id.
146
- - `list_files(**args)` → simple wrapper around `files.list`.
147
- - `get_file_source_message(channel: Channels, file_id="", user_id="")` → find the message where a file was shared (looks back ~5 messages).
148
-
149
- Example:
150
- ```python
151
- f = Files(global_vars, client, logger, file_id="F123", get_content=True)
152
- f.upload_to_slack(title="Processed file", channel="C123")
153
- ```
154
-
155
- ### `Workspaces`
156
-
157
- Purpose: workspace info helper.
158
-
159
- Constructor:
160
- ```python
161
- Workspaces(client, logger, workspace_id)
162
- ```
163
-
164
- Obtains attributes via `team.info`.
165
-
166
- ### `IDP_groups`
167
-
168
- Purpose: manage IdP (Okta) groups via SCIM.
169
-
170
- Constructor:
171
- ```python
172
- IDP_groups(global_vars)
173
- ```
174
-
175
- Key methods:
176
- - `get_groups()` → list of `{ 'group id', 'group name' }` (paginated).
177
- - `get_members(group_id)` → list of members with `value` (user id) and `display` (name).
178
- - `is_member(user_id, group_id)` → bool.
179
-
180
- Example:
181
- ```python
182
- idp = IDP_groups(global_vars)
183
- if idp.is_member("U123", "GP456"):
184
- print("authorized")
185
- ```
186
-
187
- ## Tokens and rate limits
188
-
189
- - Methods that call admin or SCIM APIs require the User OAuth token.
190
- - Standard Web API calls may use the Bot token via `App.client`.
191
- - Some methods respect internal wait times (e.g., `Tier_2`, `Tier_3`, `Tier_4`) to avoid rate limits. Configure these in `libraries_and_globals.py`.
192
-
193
- ## Error handling
194
-
195
- - Methods catch `SlackApiError` and log messages via the provided `logger`.
196
- - Some methods post audit logs to channels configured in `global_vars`.
197
-
198
- ## Notes
199
-
200
- - SCIM version: production uses `v1`, sandbox may use `v2`.
201
- - `Files.get_text_content()` is designed for `text/*` mimetypes.
@@ -1,185 +0,0 @@
1
- # slack-objects
2
-
3
- A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
4
-
5
- The following Slack object types will be supported:
6
-
7
- - **Users**
8
- - **Conversations**
9
- - **Messages**
10
- - **Files**
11
- - **Workspaces**
12
- - **IDP_groups**
13
-
14
-
15
- ---
16
-
17
- ## Overview
18
-
19
- `slack-objects` provides lightweight, reusable classes that wrap Slack Web API, Admin API, and SCIM operations in a consistent, object-oriented way. It is designed for:
20
-
21
- - Slack administration automation
22
- - Identity and access management flows
23
- - Internal tooling and bots
24
- - Auditing and cleanup scripts
25
-
26
- The package does **not** aim to be a full Slack SDK replacement. Instead, it focuses on common higher-level tasks that typically require multiple API calls and boilerplate logic.
27
-
28
- ---
29
-
30
- ## Requirements
31
-
32
- - Python **3.9+**
33
- - Slack app with appropriate scopes
34
- - Tokens provided via environment variables or from Azure KeyVault using PC_Azure package (`python -m pip install PC_Azure`)
35
-
36
- Typical dependencies:
37
- - `slack_sdk`
38
- - `requests`
39
- - `python-dotenv` (optional)
40
- - `PC_Azure` (optional)
41
-
42
- ---
43
-
44
- ## Installation
45
-
46
- ```bash
47
- pip install -r requirements.txt
48
- ```
49
-
50
- ## Classes and usage
51
-
52
- ### `Users`
53
-
54
- Purpose: actions related to Slack users.
55
-
56
- Constructor:
57
- ```python
58
- Users(global_vars, client, logger, user_id="")
59
- ```
60
-
61
- Key methods:
62
- - `is_contingent_worker()` → bool using name/display name label `[External]`.
63
- - `is_guest()` → bool if `is_restricted` or `is_ultra_restricted`.
64
- - `make_multi_channel_guest(token, scim_version='v1')` → `requests.Response` via SCIM (v1/v2).
65
- - `remove_from_channels(token, client, logger, channel_ids)` → remove user from channels (admin API).
66
- - `remove_from_workspaces(client, logger, workspace_ids, keep=[])` → remove user from workspaces.
67
- - `ap_studio_process()` → composite flow: convert to MCG, remove from org-wide channels, remove from other workspaces.
68
- - `get_userId_from_email(email)` → Slack user ID or empty string.
69
- - `is_user_authorized(service_name, auth_level='read')` → bool based on IdP group membership.
70
- - `invite_user(channel_ids, email, team_id, email_password_policy_enabled=False)` → invite a user, returns response string.
71
-
72
- Example:
73
- ```python
74
- u = Users(global_vars, client, logger, user_id="U123")
75
- if u.is_contingent_worker():
76
- u.make_multi_channel_guest(token=global_vars.user_token)
77
- ```
78
-
79
- ### `Conversations`
80
-
81
- Purpose: actions related to conversations (e.g., channels).
82
-
83
- Constructor:
84
- ```python
85
- Conversations(global_vars, client, logger, channel_id)
86
- ```
87
-
88
- Key methods:
89
- - `is_private()` → bool.
90
- - `get_messages(channel_id="", include_all_metadata=False, limit=None, inclusive=True, latest=None, oldest=None)` → list of messages using `conversations.history` with pagination.
91
-
92
- Example:
93
- ```python
94
- ch = Conversations(global_vars, client, logger, channel_id="C123")
95
- msgs = ch.get_messages(limit=100)
96
- ```
97
-
98
- ### `Messages`
99
-
100
- Purpose: manage Slack messages and blocks.
101
-
102
- Constructor:
103
- ```python
104
- Messages(global_vars, client, logger, channel_id, ts, message=None)
105
- ```
106
-
107
- Key methods:
108
- - `update_message(as_user=True, channel_id="", message_ts="", new_message_blocks=[], new_message_text="", new_message_attachments="")` → update message via `chat.update`.
109
- - `replace_message_block(blocks=[], block_type="", block_id="", text="", new_block={}, new_block_id="")` → find a block by type or id and replace it, then update message.
110
-
111
- Example:
112
- ```python
113
- msg = Messages(global_vars, client, logger, "C123", "1717000000.000100")
114
- msg.update_message(new_message_text="Updated content")
115
- ```
116
-
117
- ### `Files`
118
-
119
- Purpose: interact with files in Slack.
120
-
121
- Constructor:
122
- ```python
123
- Files(global_vars, client, logger, file_id="", get_content=False)
124
- ```
125
-
126
- Key methods:
127
- - `get_text_content()` → fetch content for text files via `url_private` (uses bot token).
128
- - `upload_to_slack(title, channel="", thread_ts="")` → upload the current file content via `files_upload_v2`.
129
- - `delete_file(file_id="")` → delete a file by id.
130
- - `list_files(**args)` → simple wrapper around `files.list`.
131
- - `get_file_source_message(channel: Channels, file_id="", user_id="")` → find the message where a file was shared (looks back ~5 messages).
132
-
133
- Example:
134
- ```python
135
- f = Files(global_vars, client, logger, file_id="F123", get_content=True)
136
- f.upload_to_slack(title="Processed file", channel="C123")
137
- ```
138
-
139
- ### `Workspaces`
140
-
141
- Purpose: workspace info helper.
142
-
143
- Constructor:
144
- ```python
145
- Workspaces(client, logger, workspace_id)
146
- ```
147
-
148
- Obtains attributes via `team.info`.
149
-
150
- ### `IDP_groups`
151
-
152
- Purpose: manage IdP (Okta) groups via SCIM.
153
-
154
- Constructor:
155
- ```python
156
- IDP_groups(global_vars)
157
- ```
158
-
159
- Key methods:
160
- - `get_groups()` → list of `{ 'group id', 'group name' }` (paginated).
161
- - `get_members(group_id)` → list of members with `value` (user id) and `display` (name).
162
- - `is_member(user_id, group_id)` → bool.
163
-
164
- Example:
165
- ```python
166
- idp = IDP_groups(global_vars)
167
- if idp.is_member("U123", "GP456"):
168
- print("authorized")
169
- ```
170
-
171
- ## Tokens and rate limits
172
-
173
- - Methods that call admin or SCIM APIs require the User OAuth token.
174
- - Standard Web API calls may use the Bot token via `App.client`.
175
- - Some methods respect internal wait times (e.g., `Tier_2`, `Tier_3`, `Tier_4`) to avoid rate limits. Configure these in `libraries_and_globals.py`.
176
-
177
- ## Error handling
178
-
179
- - Methods catch `SlackApiError` and log messages via the provided `logger`.
180
- - Some methods post audit logs to channels configured in `global_vars`.
181
-
182
- ## Notes
183
-
184
- - SCIM version: production uses `v1`, sandbox may use `v2`.
185
- - `Files.get_text_content()` is designed for `text/*` mimetypes.
@@ -1,201 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: slack-objects
3
- Version: 0.0.post31
4
- Summary: This package defines classes for working with slack objects like users, conversations, messages, etc.
5
- Author-email: "Marcos E. Mercado" <marcos_elias@hotmail.com>
6
- Keywords: slack,objects,classes,slack objects,utilities,slack utilities,slack object types,slack types,types
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: slack-sdk
14
- Requires-Dist: PC_Utils
15
- Dynamic: license-file
16
-
17
- # slack-objects
18
-
19
- A focused Python package for working with **Slack objects** commonly used in administration and automation workflows.
20
-
21
- The following Slack object types will be supported:
22
-
23
- - **Users**
24
- - **Conversations**
25
- - **Messages**
26
- - **Files**
27
- - **Workspaces**
28
- - **IDP_groups**
29
-
30
-
31
- ---
32
-
33
- ## Overview
34
-
35
- `slack-objects` provides lightweight, reusable classes that wrap Slack Web API, Admin API, and SCIM operations in a consistent, object-oriented way. It is designed for:
36
-
37
- - Slack administration automation
38
- - Identity and access management flows
39
- - Internal tooling and bots
40
- - Auditing and cleanup scripts
41
-
42
- The package does **not** aim to be a full Slack SDK replacement. Instead, it focuses on common higher-level tasks that typically require multiple API calls and boilerplate logic.
43
-
44
- ---
45
-
46
- ## Requirements
47
-
48
- - Python **3.9+**
49
- - Slack app with appropriate scopes
50
- - Tokens provided via environment variables or from Azure KeyVault using PC_Azure package (`python -m pip install PC_Azure`)
51
-
52
- Typical dependencies:
53
- - `slack_sdk`
54
- - `requests`
55
- - `python-dotenv` (optional)
56
- - `PC_Azure` (optional)
57
-
58
- ---
59
-
60
- ## Installation
61
-
62
- ```bash
63
- pip install -r requirements.txt
64
- ```
65
-
66
- ## Classes and usage
67
-
68
- ### `Users`
69
-
70
- Purpose: actions related to Slack users.
71
-
72
- Constructor:
73
- ```python
74
- Users(global_vars, client, logger, user_id="")
75
- ```
76
-
77
- Key methods:
78
- - `is_contingent_worker()` → bool using name/display name label `[External]`.
79
- - `is_guest()` → bool if `is_restricted` or `is_ultra_restricted`.
80
- - `make_multi_channel_guest(token, scim_version='v1')` → `requests.Response` via SCIM (v1/v2).
81
- - `remove_from_channels(token, client, logger, channel_ids)` → remove user from channels (admin API).
82
- - `remove_from_workspaces(client, logger, workspace_ids, keep=[])` → remove user from workspaces.
83
- - `ap_studio_process()` → composite flow: convert to MCG, remove from org-wide channels, remove from other workspaces.
84
- - `get_userId_from_email(email)` → Slack user ID or empty string.
85
- - `is_user_authorized(service_name, auth_level='read')` → bool based on IdP group membership.
86
- - `invite_user(channel_ids, email, team_id, email_password_policy_enabled=False)` → invite a user, returns response string.
87
-
88
- Example:
89
- ```python
90
- u = Users(global_vars, client, logger, user_id="U123")
91
- if u.is_contingent_worker():
92
- u.make_multi_channel_guest(token=global_vars.user_token)
93
- ```
94
-
95
- ### `Conversations`
96
-
97
- Purpose: actions related to conversations (e.g., channels).
98
-
99
- Constructor:
100
- ```python
101
- Conversations(global_vars, client, logger, channel_id)
102
- ```
103
-
104
- Key methods:
105
- - `is_private()` → bool.
106
- - `get_messages(channel_id="", include_all_metadata=False, limit=None, inclusive=True, latest=None, oldest=None)` → list of messages using `conversations.history` with pagination.
107
-
108
- Example:
109
- ```python
110
- ch = Conversations(global_vars, client, logger, channel_id="C123")
111
- msgs = ch.get_messages(limit=100)
112
- ```
113
-
114
- ### `Messages`
115
-
116
- Purpose: manage Slack messages and blocks.
117
-
118
- Constructor:
119
- ```python
120
- Messages(global_vars, client, logger, channel_id, ts, message=None)
121
- ```
122
-
123
- Key methods:
124
- - `update_message(as_user=True, channel_id="", message_ts="", new_message_blocks=[], new_message_text="", new_message_attachments="")` → update message via `chat.update`.
125
- - `replace_message_block(blocks=[], block_type="", block_id="", text="", new_block={}, new_block_id="")` → find a block by type or id and replace it, then update message.
126
-
127
- Example:
128
- ```python
129
- msg = Messages(global_vars, client, logger, "C123", "1717000000.000100")
130
- msg.update_message(new_message_text="Updated content")
131
- ```
132
-
133
- ### `Files`
134
-
135
- Purpose: interact with files in Slack.
136
-
137
- Constructor:
138
- ```python
139
- Files(global_vars, client, logger, file_id="", get_content=False)
140
- ```
141
-
142
- Key methods:
143
- - `get_text_content()` → fetch content for text files via `url_private` (uses bot token).
144
- - `upload_to_slack(title, channel="", thread_ts="")` → upload the current file content via `files_upload_v2`.
145
- - `delete_file(file_id="")` → delete a file by id.
146
- - `list_files(**args)` → simple wrapper around `files.list`.
147
- - `get_file_source_message(channel: Channels, file_id="", user_id="")` → find the message where a file was shared (looks back ~5 messages).
148
-
149
- Example:
150
- ```python
151
- f = Files(global_vars, client, logger, file_id="F123", get_content=True)
152
- f.upload_to_slack(title="Processed file", channel="C123")
153
- ```
154
-
155
- ### `Workspaces`
156
-
157
- Purpose: workspace info helper.
158
-
159
- Constructor:
160
- ```python
161
- Workspaces(client, logger, workspace_id)
162
- ```
163
-
164
- Obtains attributes via `team.info`.
165
-
166
- ### `IDP_groups`
167
-
168
- Purpose: manage IdP (Okta) groups via SCIM.
169
-
170
- Constructor:
171
- ```python
172
- IDP_groups(global_vars)
173
- ```
174
-
175
- Key methods:
176
- - `get_groups()` → list of `{ 'group id', 'group name' }` (paginated).
177
- - `get_members(group_id)` → list of members with `value` (user id) and `display` (name).
178
- - `is_member(user_id, group_id)` → bool.
179
-
180
- Example:
181
- ```python
182
- idp = IDP_groups(global_vars)
183
- if idp.is_member("U123", "GP456"):
184
- print("authorized")
185
- ```
186
-
187
- ## Tokens and rate limits
188
-
189
- - Methods that call admin or SCIM APIs require the User OAuth token.
190
- - Standard Web API calls may use the Bot token via `App.client`.
191
- - Some methods respect internal wait times (e.g., `Tier_2`, `Tier_3`, `Tier_4`) to avoid rate limits. Configure these in `libraries_and_globals.py`.
192
-
193
- ## Error handling
194
-
195
- - Methods catch `SlackApiError` and log messages via the provided `logger`.
196
- - Some methods post audit logs to channels configured in `global_vars`.
197
-
198
- ## Notes
199
-
200
- - SCIM version: production uses `v1`, sandbox may use `v2`.
201
- - `Files.get_text_content()` is designed for `text/*` mimetypes.