slack-objects 0.0.post31__py3-none-any.whl → 0.0.post34__py3-none-any.whl

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.
slack_objects/_version.py CHANGED
@@ -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
34
  __commit_id__ = commit_id = None
@@ -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
@@ -1,5 +1,5 @@
1
1
  slack_objects/__init__.py,sha256=wYczk9CK67k2nrq8rtlxVqGMu_93wBNGIf_Ha-GH5mE,525
2
- slack_objects/_version.py,sha256=SjQ_icTK6fnX32Dc0GVEVLmDoZTtEN7KhTlrIniW_QY,750
2
+ slack_objects/_version.py,sha256=xSraO2QtFHcObL6CDK5aHjGDDEBH4oVLzhjEYCeULEY,750
3
3
  slack_objects/api_caller.py,sha256=Gch_DFpAgQN7Svgoe9Y4F4R2FY4PfiBchXuGbZ0sOgw,1507
4
4
  slack_objects/base.py,sha256=mCKi5u1apj1vQTuNwlIcFf-A4Yh_Ag3lTp6kXJVJa3s,1097
5
5
  slack_objects/client.py,sha256=K3Ln6SGkgfc9i2IVIvFlcowX8Cgp2E26RnKf7XRr46k,1966
@@ -11,8 +11,8 @@ slack_objects/messages.py,sha256=PsUSqUfX5gtAwl7BKusT1AnTLqKRJgz4bkuXc1W4If4,119
11
11
  slack_objects/rate_limits.py,sha256=cSfG9k04DlpyOQRb8r5IFquKfgbrAEQHX4G9oGd8QcE,1496
12
12
  slack_objects/users.py,sha256=BvLYy-Ng82Mv5pnIPS_eF6hYXk-6upeEsMq-9QrTCG8,22315
13
13
  slack_objects/workspaces.py,sha256=1yUWIca61fq1OwB6xMJZJFCLh7HNmpku4vhjhvCJg-A,10744
14
- slack_objects-0.0.post31.dist-info/licenses/LICENSE,sha256=gIj0uwoGs4CwZR0bAP1ZP-F6B5f7VWJDz3Kfpc3c0dI,1090
15
- slack_objects-0.0.post31.dist-info/METADATA,sha256=gaqROB2GRuwm8FJ6O5GzLOOs7Wddg2HmXg3buGpC0-k,6379
16
- slack_objects-0.0.post31.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
17
- slack_objects-0.0.post31.dist-info/top_level.txt,sha256=enSaCqZ69Tu_AzK_F0_NEtvRK-r5OjpMHJsnFh5Z8Wo,14
18
- slack_objects-0.0.post31.dist-info/RECORD,,
14
+ slack_objects-0.0.post34.dist-info/licenses/LICENSE,sha256=gIj0uwoGs4CwZR0bAP1ZP-F6B5f7VWJDz3Kfpc3c0dI,1090
15
+ slack_objects-0.0.post34.dist-info/METADATA,sha256=LjbMNMvoDctvJyFziPIfAJ9i7gC1Nfmu2EVz9zzOy_0,3781
16
+ slack_objects-0.0.post34.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
17
+ slack_objects-0.0.post34.dist-info/top_level.txt,sha256=enSaCqZ69Tu_AzK_F0_NEtvRK-r5OjpMHJsnFh5Z8Wo,14
18
+ slack_objects-0.0.post34.dist-info/RECORD,,
@@ -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.