airbyte-agent-slack 0.1.38__py3-none-any.whl → 0.1.40__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.
- airbyte_agent_slack/__init__.py +2 -0
- airbyte_agent_slack/_vendored/connector_sdk/cloud_utils/client.py +125 -0
- airbyte_agent_slack/_vendored/connector_sdk/executor/hosted_executor.py +54 -25
- airbyte_agent_slack/connector.py +210 -9
- airbyte_agent_slack/models.py +14 -0
- {airbyte_agent_slack-0.1.38.dist-info → airbyte_agent_slack-0.1.40.dist-info}/METADATA +3 -3
- {airbyte_agent_slack-0.1.38.dist-info → airbyte_agent_slack-0.1.40.dist-info}/RECORD +8 -8
- {airbyte_agent_slack-0.1.38.dist-info → airbyte_agent_slack-0.1.40.dist-info}/WHEEL +0 -0
airbyte_agent_slack/__init__.py
CHANGED
|
@@ -7,6 +7,7 @@ Auto-generated from OpenAPI specification.
|
|
|
7
7
|
from .connector import SlackConnector
|
|
8
8
|
from .models import (
|
|
9
9
|
SlackAuthConfig,
|
|
10
|
+
SlackReplicationConfig,
|
|
10
11
|
User,
|
|
11
12
|
UserProfile,
|
|
12
13
|
ResponseMetadata,
|
|
@@ -86,6 +87,7 @@ from .types import (
|
|
|
86
87
|
__all__ = [
|
|
87
88
|
"SlackConnector",
|
|
88
89
|
"SlackAuthConfig",
|
|
90
|
+
"SlackReplicationConfig",
|
|
89
91
|
"User",
|
|
90
92
|
"UserProfile",
|
|
91
93
|
"ResponseMetadata",
|
|
@@ -161,6 +161,131 @@ class AirbyteCloudClient:
|
|
|
161
161
|
connector_id = connectors[0]["id"]
|
|
162
162
|
return connector_id
|
|
163
163
|
|
|
164
|
+
async def initiate_oauth(
|
|
165
|
+
self,
|
|
166
|
+
definition_id: str,
|
|
167
|
+
external_user_id: str,
|
|
168
|
+
redirect_url: str,
|
|
169
|
+
) -> str:
|
|
170
|
+
"""Initiate a server-side OAuth flow.
|
|
171
|
+
|
|
172
|
+
Starts the OAuth flow for a connector. Returns a consent URL where the
|
|
173
|
+
end user should be redirected to grant access. After completing consent,
|
|
174
|
+
they'll be redirected to your redirect_url with a `server_side_oauth_secret_id`
|
|
175
|
+
query parameter that can be used with `create_source()`.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
definition_id: Connector definition UUID
|
|
179
|
+
external_user_id: Workspace identifier
|
|
180
|
+
redirect_url: URL where users will be redirected after OAuth consent
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
The OAuth consent URL
|
|
184
|
+
|
|
185
|
+
Raises:
|
|
186
|
+
httpx.HTTPStatusError: If the request fails
|
|
187
|
+
|
|
188
|
+
Example:
|
|
189
|
+
consent_url = await client.initiate_oauth(
|
|
190
|
+
definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
|
|
191
|
+
external_user_id="my-workspace",
|
|
192
|
+
redirect_url="https://myapp.com/oauth/callback",
|
|
193
|
+
)
|
|
194
|
+
# Redirect user to: consent_url
|
|
195
|
+
# After consent: https://myapp.com/oauth/callback?server_side_oauth_secret_id=...
|
|
196
|
+
"""
|
|
197
|
+
token = await self.get_bearer_token()
|
|
198
|
+
url = f"{self.API_BASE_URL}/api/v1/integrations/connectors/oauth/initiate"
|
|
199
|
+
headers = {"Authorization": f"Bearer {token}"}
|
|
200
|
+
request_body = {
|
|
201
|
+
"external_user_id": external_user_id,
|
|
202
|
+
"definition_id": definition_id,
|
|
203
|
+
"redirect_url": redirect_url,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
response = await self._http_client.post(url, json=request_body, headers=headers)
|
|
207
|
+
response.raise_for_status()
|
|
208
|
+
return response.json()["consent_url"]
|
|
209
|
+
|
|
210
|
+
async def create_source(
|
|
211
|
+
self,
|
|
212
|
+
name: str,
|
|
213
|
+
connector_definition_id: str,
|
|
214
|
+
external_user_id: str,
|
|
215
|
+
credentials: dict[str, Any] | None = None,
|
|
216
|
+
replication_config: dict[str, Any] | None = None,
|
|
217
|
+
server_side_oauth_secret_id: str | None = None,
|
|
218
|
+
source_template_id: str | None = None,
|
|
219
|
+
) -> str:
|
|
220
|
+
"""Create a new source on Airbyte Cloud.
|
|
221
|
+
|
|
222
|
+
Supports two authentication modes:
|
|
223
|
+
1. Direct credentials: Provide `credentials` dict
|
|
224
|
+
2. Server-side OAuth: Provide `server_side_oauth_secret_id` from OAuth flow
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
name: Source name
|
|
228
|
+
connector_definition_id: UUID of the connector definition
|
|
229
|
+
external_user_id: User identifier
|
|
230
|
+
credentials: Connector auth config dict. Required unless using OAuth.
|
|
231
|
+
replication_config: Optional replication settings (e.g., start_date for
|
|
232
|
+
connectors with x-airbyte-replication-config). Required for REPLICATION
|
|
233
|
+
mode sources like Intercom.
|
|
234
|
+
server_side_oauth_secret_id: OAuth secret ID from initiate_oauth redirect.
|
|
235
|
+
When provided, credentials are not required.
|
|
236
|
+
source_template_id: Source template ID. Required when organization has
|
|
237
|
+
multiple source templates for this connector type.
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
The created source ID (UUID string)
|
|
241
|
+
|
|
242
|
+
Raises:
|
|
243
|
+
httpx.HTTPStatusError: If creation fails
|
|
244
|
+
|
|
245
|
+
Example:
|
|
246
|
+
# With direct credentials:
|
|
247
|
+
source_id = await client.create_source(
|
|
248
|
+
name="My Intercom Source",
|
|
249
|
+
connector_definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
|
|
250
|
+
external_user_id="my-workspace",
|
|
251
|
+
credentials={"access_token": "..."},
|
|
252
|
+
replication_config={"start_date": "2024-01-01T00:00:00Z"}
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
# With server-side OAuth:
|
|
256
|
+
source_id = await client.create_source(
|
|
257
|
+
name="My Intercom Source",
|
|
258
|
+
connector_definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
|
|
259
|
+
external_user_id="my-workspace",
|
|
260
|
+
server_side_oauth_secret_id="airbyte_oauth_..._secret_...",
|
|
261
|
+
replication_config={"start_date": "2024-01-01T00:00:00Z"}
|
|
262
|
+
)
|
|
263
|
+
"""
|
|
264
|
+
token = await self.get_bearer_token()
|
|
265
|
+
url = f"{self.API_BASE_URL}/v1/integrations/connectors"
|
|
266
|
+
headers = {"Authorization": f"Bearer {token}"}
|
|
267
|
+
|
|
268
|
+
request_body: dict[str, Any] = {
|
|
269
|
+
"name": name,
|
|
270
|
+
"definition_id": connector_definition_id,
|
|
271
|
+
"external_user_id": external_user_id,
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if credentials is not None:
|
|
275
|
+
request_body["credentials"] = credentials
|
|
276
|
+
if replication_config is not None:
|
|
277
|
+
request_body["replication_config"] = replication_config
|
|
278
|
+
if server_side_oauth_secret_id is not None:
|
|
279
|
+
request_body["server_side_oauth_secret_id"] = server_side_oauth_secret_id
|
|
280
|
+
if source_template_id is not None:
|
|
281
|
+
request_body["source_template_id"] = source_template_id
|
|
282
|
+
|
|
283
|
+
response = await self._http_client.post(url, json=request_body, headers=headers)
|
|
284
|
+
response.raise_for_status()
|
|
285
|
+
|
|
286
|
+
data = response.json()
|
|
287
|
+
return data["id"]
|
|
288
|
+
|
|
164
289
|
async def execute_connector(
|
|
165
290
|
self,
|
|
166
291
|
connector_id: str,
|
|
@@ -19,19 +19,26 @@ class HostedExecutor:
|
|
|
19
19
|
instead of directly calling external services. The cloud API handles all
|
|
20
20
|
connector logic, secrets management, and execution.
|
|
21
21
|
|
|
22
|
-
The executor
|
|
22
|
+
The executor uses the AirbyteCloudClient to:
|
|
23
23
|
1. Authenticate with the Airbyte Platform (bearer token with caching)
|
|
24
|
-
2. Look up the user's connector
|
|
24
|
+
2. Look up the user's connector (if connector_id not provided)
|
|
25
25
|
3. Execute the connector operation via the cloud API
|
|
26
26
|
|
|
27
27
|
Implements ExecutorProtocol.
|
|
28
28
|
|
|
29
29
|
Example:
|
|
30
|
-
# Create executor with
|
|
30
|
+
# Create executor with explicit connector_id (no lookup needed)
|
|
31
|
+
executor = HostedExecutor(
|
|
32
|
+
airbyte_client_id="client_abc123",
|
|
33
|
+
airbyte_client_secret="secret_xyz789",
|
|
34
|
+
connector_id="existing-source-uuid",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Or create executor with user ID for lookup
|
|
31
38
|
executor = HostedExecutor(
|
|
32
|
-
external_user_id="user-123",
|
|
33
39
|
airbyte_client_id="client_abc123",
|
|
34
40
|
airbyte_client_secret="secret_xyz789",
|
|
41
|
+
external_user_id="user-123",
|
|
35
42
|
connector_definition_id="abc123-def456-ghi789",
|
|
36
43
|
)
|
|
37
44
|
|
|
@@ -51,28 +58,48 @@ class HostedExecutor:
|
|
|
51
58
|
|
|
52
59
|
def __init__(
|
|
53
60
|
self,
|
|
54
|
-
external_user_id: str,
|
|
55
61
|
airbyte_client_id: str,
|
|
56
62
|
airbyte_client_secret: str,
|
|
57
|
-
|
|
63
|
+
connector_id: str | None = None,
|
|
64
|
+
external_user_id: str | None = None,
|
|
65
|
+
connector_definition_id: str | None = None,
|
|
58
66
|
):
|
|
59
67
|
"""Initialize hosted executor.
|
|
60
68
|
|
|
69
|
+
Either provide connector_id directly OR (external_user_id + connector_definition_id)
|
|
70
|
+
for lookup.
|
|
71
|
+
|
|
61
72
|
Args:
|
|
62
|
-
external_user_id: User identifier in the Airbyte system
|
|
63
73
|
airbyte_client_id: Airbyte client ID for authentication
|
|
64
74
|
airbyte_client_secret: Airbyte client secret for authentication
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
connector_id: Direct connector/source ID (skips lookup if provided)
|
|
76
|
+
external_user_id: User identifier in the Airbyte system (for lookup)
|
|
77
|
+
connector_definition_id: Connector definition ID (for lookup)
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
ValueError: If neither connector_id nor (external_user_id + connector_definition_id) provided
|
|
67
81
|
|
|
68
82
|
Example:
|
|
83
|
+
# With explicit connector_id (no lookup)
|
|
84
|
+
executor = HostedExecutor(
|
|
85
|
+
airbyte_client_id="client_abc123",
|
|
86
|
+
airbyte_client_secret="secret_xyz789",
|
|
87
|
+
connector_id="existing-source-uuid",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# With lookup by user + definition
|
|
69
91
|
executor = HostedExecutor(
|
|
70
|
-
external_user_id="user-123",
|
|
71
92
|
airbyte_client_id="client_abc123",
|
|
72
93
|
airbyte_client_secret="secret_xyz789",
|
|
94
|
+
external_user_id="user-123",
|
|
73
95
|
connector_definition_id="abc123-def456-ghi789",
|
|
74
96
|
)
|
|
75
97
|
"""
|
|
98
|
+
# Validate: either connector_id OR (external_user_id + connector_definition_id) required
|
|
99
|
+
if not connector_id and not (external_user_id and connector_definition_id):
|
|
100
|
+
raise ValueError("Either connector_id OR (external_user_id + connector_definition_id) must be provided")
|
|
101
|
+
|
|
102
|
+
self._connector_id = connector_id
|
|
76
103
|
self._external_user_id = external_user_id
|
|
77
104
|
self._connector_definition_id = connector_definition_id
|
|
78
105
|
|
|
@@ -86,10 +113,9 @@ class HostedExecutor:
|
|
|
86
113
|
"""Execute connector via cloud API (ExecutorProtocol implementation).
|
|
87
114
|
|
|
88
115
|
Flow:
|
|
89
|
-
1.
|
|
90
|
-
2.
|
|
91
|
-
3.
|
|
92
|
-
4. Parse the response into ExecutionResult
|
|
116
|
+
1. Use provided connector_id or look up from external_user_id + definition_id
|
|
117
|
+
2. Execute the connector operation via the cloud API
|
|
118
|
+
3. Parse the response into ExecutionResult
|
|
93
119
|
|
|
94
120
|
Args:
|
|
95
121
|
config: Execution configuration (entity, action, params)
|
|
@@ -98,7 +124,7 @@ class HostedExecutor:
|
|
|
98
124
|
ExecutionResult with success/failure status
|
|
99
125
|
|
|
100
126
|
Raises:
|
|
101
|
-
ValueError: If no connector or multiple connectors found for user
|
|
127
|
+
ValueError: If no connector or multiple connectors found for user (when doing lookup)
|
|
102
128
|
httpx.HTTPStatusError: If API returns 4xx/5xx status code
|
|
103
129
|
httpx.RequestError: If network request fails
|
|
104
130
|
|
|
@@ -114,23 +140,26 @@ class HostedExecutor:
|
|
|
114
140
|
|
|
115
141
|
with tracer.start_as_current_span("airbyte.hosted_executor.execute") as span:
|
|
116
142
|
# Add span attributes for observability
|
|
117
|
-
|
|
143
|
+
if self._connector_definition_id:
|
|
144
|
+
span.set_attribute("connector.definition_id", self._connector_definition_id)
|
|
118
145
|
span.set_attribute("connector.entity", config.entity)
|
|
119
146
|
span.set_attribute("connector.action", config.action)
|
|
120
|
-
|
|
147
|
+
if self._external_user_id:
|
|
148
|
+
span.set_attribute("user.external_id", self._external_user_id)
|
|
121
149
|
if config.params:
|
|
122
150
|
# Only add non-sensitive param keys
|
|
123
151
|
span.set_attribute("connector.param_keys", list(config.params.keys()))
|
|
124
152
|
|
|
125
153
|
try:
|
|
126
|
-
#
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
# Use provided connector_id or look it up
|
|
155
|
+
if self._connector_id:
|
|
156
|
+
connector_id = self._connector_id
|
|
157
|
+
else:
|
|
158
|
+
# Look up connector by external_user_id + definition_id
|
|
159
|
+
connector_id = await self._cloud_client.get_connector_id(
|
|
160
|
+
external_user_id=self._external_user_id, # type: ignore[arg-type]
|
|
161
|
+
connector_definition_id=self._connector_definition_id, # type: ignore[arg-type]
|
|
162
|
+
)
|
|
134
163
|
|
|
135
164
|
span.set_attribute("connector.connector_id", connector_id)
|
|
136
165
|
|
airbyte_agent_slack/connector.py
CHANGED
|
@@ -38,6 +38,8 @@ from .types import (
|
|
|
38
38
|
)
|
|
39
39
|
if TYPE_CHECKING:
|
|
40
40
|
from .models import SlackAuthConfig
|
|
41
|
+
from .models import SlackReplicationConfig
|
|
42
|
+
|
|
41
43
|
# Import specific auth config classes for multi-auth isinstance checks
|
|
42
44
|
from .models import SlackTokenAuthenticationAuthConfig, SlackOauth20AuthenticationAuthConfig
|
|
43
45
|
# Import response models and envelope models at runtime
|
|
@@ -152,26 +154,35 @@ class SlackConnector:
|
|
|
152
154
|
external_user_id: str | None = None,
|
|
153
155
|
airbyte_client_id: str | None = None,
|
|
154
156
|
airbyte_client_secret: str | None = None,
|
|
157
|
+
connector_id: str | None = None,
|
|
155
158
|
on_token_refresh: Any | None = None ):
|
|
156
159
|
"""
|
|
157
160
|
Initialize a new slack connector instance.
|
|
158
161
|
|
|
159
162
|
Supports both local and hosted execution modes:
|
|
160
163
|
- Local mode: Provide `auth_config` for direct API calls
|
|
161
|
-
- Hosted mode: Provide
|
|
164
|
+
- Hosted mode: Provide Airbyte credentials with either `connector_id` or `external_user_id`
|
|
162
165
|
|
|
163
166
|
Args:
|
|
164
167
|
auth_config: Typed authentication configuration (required for local mode)
|
|
165
|
-
external_user_id: External user ID (
|
|
168
|
+
external_user_id: External user ID (for hosted mode lookup)
|
|
166
169
|
airbyte_client_id: Airbyte OAuth client ID (required for hosted mode)
|
|
167
170
|
airbyte_client_secret: Airbyte OAuth client secret (required for hosted mode)
|
|
171
|
+
connector_id: Specific connector/source ID (for hosted mode, skips lookup)
|
|
168
172
|
on_token_refresh: Optional callback for OAuth2 token refresh persistence.
|
|
169
173
|
Called with new_tokens dict when tokens are refreshed. Can be sync or async.
|
|
170
174
|
Example: lambda tokens: save_to_database(tokens)
|
|
171
175
|
Examples:
|
|
172
176
|
# Local mode (direct API calls)
|
|
173
177
|
connector = SlackConnector(auth_config=SlackAuthConfig(api_token="..."))
|
|
174
|
-
# Hosted mode (
|
|
178
|
+
# Hosted mode with explicit connector_id (no lookup needed)
|
|
179
|
+
connector = SlackConnector(
|
|
180
|
+
airbyte_client_id="client_abc123",
|
|
181
|
+
airbyte_client_secret="secret_xyz789",
|
|
182
|
+
connector_id="existing-source-uuid"
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
# Hosted mode with lookup by external_user_id
|
|
175
186
|
connector = SlackConnector(
|
|
176
187
|
external_user_id="user-123",
|
|
177
188
|
airbyte_client_id="client_abc123",
|
|
@@ -189,21 +200,24 @@ class SlackConnector:
|
|
|
189
200
|
on_token_refresh=save_tokens
|
|
190
201
|
)
|
|
191
202
|
"""
|
|
192
|
-
# Hosted mode:
|
|
193
|
-
|
|
203
|
+
# Hosted mode: Airbyte credentials + either connector_id OR external_user_id
|
|
204
|
+
is_hosted = airbyte_client_id and airbyte_client_secret and (connector_id or external_user_id)
|
|
205
|
+
|
|
206
|
+
if is_hosted:
|
|
194
207
|
from ._vendored.connector_sdk.executor import HostedExecutor
|
|
195
208
|
self._executor = HostedExecutor(
|
|
196
|
-
external_user_id=external_user_id,
|
|
197
209
|
airbyte_client_id=airbyte_client_id,
|
|
198
210
|
airbyte_client_secret=airbyte_client_secret,
|
|
199
|
-
|
|
211
|
+
connector_id=connector_id,
|
|
212
|
+
external_user_id=external_user_id,
|
|
213
|
+
connector_definition_id=str(SlackConnectorModel.id) if not connector_id else None,
|
|
200
214
|
)
|
|
201
215
|
else:
|
|
202
216
|
# Local mode: auth_config required
|
|
203
217
|
if not auth_config:
|
|
204
218
|
raise ValueError(
|
|
205
|
-
"Either provide (
|
|
206
|
-
"or auth_config for local mode"
|
|
219
|
+
"Either provide Airbyte credentials (airbyte_client_id, airbyte_client_secret) with "
|
|
220
|
+
"connector_id or external_user_id for hosted mode, or auth_config for local mode"
|
|
207
221
|
)
|
|
208
222
|
|
|
209
223
|
from ._vendored.connector_sdk.executor import LocalExecutor
|
|
@@ -567,6 +581,193 @@ class SlackConnector:
|
|
|
567
581
|
)
|
|
568
582
|
return entity_def.entity_schema if entity_def else None
|
|
569
583
|
|
|
584
|
+
@property
|
|
585
|
+
def connector_id(self) -> str | None:
|
|
586
|
+
"""Get the connector/source ID (only available in hosted mode).
|
|
587
|
+
|
|
588
|
+
Returns:
|
|
589
|
+
The connector ID if in hosted mode, None if in local mode.
|
|
590
|
+
|
|
591
|
+
Example:
|
|
592
|
+
connector = await SlackConnector.create_hosted(...)
|
|
593
|
+
print(f"Created connector: {connector.connector_id}")
|
|
594
|
+
"""
|
|
595
|
+
if hasattr(self, '_executor') and hasattr(self._executor, '_connector_id'):
|
|
596
|
+
return self._executor._connector_id
|
|
597
|
+
return None
|
|
598
|
+
|
|
599
|
+
# ===== HOSTED MODE FACTORY =====
|
|
600
|
+
|
|
601
|
+
@classmethod
|
|
602
|
+
async def initiate_oauth(
|
|
603
|
+
cls,
|
|
604
|
+
*,
|
|
605
|
+
external_user_id: str,
|
|
606
|
+
redirect_url: str,
|
|
607
|
+
airbyte_client_id: str,
|
|
608
|
+
airbyte_client_secret: str,
|
|
609
|
+
) -> str:
|
|
610
|
+
"""
|
|
611
|
+
Initiate server-side OAuth flow for this connector.
|
|
612
|
+
|
|
613
|
+
Returns a consent URL where the end user should be redirected to grant access.
|
|
614
|
+
After completing consent, they'll be redirected to your redirect_url with a
|
|
615
|
+
`server_side_oauth_secret_id` query parameter that can be used with `create_hosted()`.
|
|
616
|
+
|
|
617
|
+
Args:
|
|
618
|
+
external_user_id: Workspace identifier in Airbyte Cloud
|
|
619
|
+
redirect_url: URL where users will be redirected after OAuth consent
|
|
620
|
+
airbyte_client_id: Airbyte OAuth client ID
|
|
621
|
+
airbyte_client_secret: Airbyte OAuth client secret
|
|
622
|
+
|
|
623
|
+
Returns:
|
|
624
|
+
The OAuth consent URL
|
|
625
|
+
|
|
626
|
+
Example:
|
|
627
|
+
consent_url = await SlackConnector.initiate_oauth(
|
|
628
|
+
external_user_id="my-workspace",
|
|
629
|
+
redirect_url="https://myapp.com/oauth/callback",
|
|
630
|
+
airbyte_client_id="client_abc",
|
|
631
|
+
airbyte_client_secret="secret_xyz",
|
|
632
|
+
)
|
|
633
|
+
# Redirect user to: consent_url
|
|
634
|
+
# After consent, user arrives at: https://myapp.com/oauth/callback?server_side_oauth_secret_id=...
|
|
635
|
+
"""
|
|
636
|
+
from ._vendored.connector_sdk.cloud_utils import AirbyteCloudClient
|
|
637
|
+
|
|
638
|
+
client = AirbyteCloudClient(
|
|
639
|
+
client_id=airbyte_client_id,
|
|
640
|
+
client_secret=airbyte_client_secret,
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
try:
|
|
644
|
+
consent_url = await client.initiate_oauth(
|
|
645
|
+
definition_id=str(SlackConnectorModel.id),
|
|
646
|
+
external_user_id=external_user_id,
|
|
647
|
+
redirect_url=redirect_url,
|
|
648
|
+
)
|
|
649
|
+
finally:
|
|
650
|
+
await client.close()
|
|
651
|
+
|
|
652
|
+
return consent_url
|
|
653
|
+
|
|
654
|
+
@classmethod
|
|
655
|
+
async def create_hosted(
|
|
656
|
+
cls,
|
|
657
|
+
*,
|
|
658
|
+
external_user_id: str,
|
|
659
|
+
airbyte_client_id: str,
|
|
660
|
+
airbyte_client_secret: str,
|
|
661
|
+
auth_config: "SlackAuthConfig" | None = None,
|
|
662
|
+
server_side_oauth_secret_id: str | None = None,
|
|
663
|
+
name: str | None = None,
|
|
664
|
+
replication_config: "SlackReplicationConfig" | None = None,
|
|
665
|
+
source_template_id: str | None = None,
|
|
666
|
+
) -> "SlackConnector":
|
|
667
|
+
"""
|
|
668
|
+
Create a new hosted connector on Airbyte Cloud.
|
|
669
|
+
|
|
670
|
+
This factory method:
|
|
671
|
+
1. Creates a source on Airbyte Cloud with the provided credentials
|
|
672
|
+
2. Returns a connector configured with the new connector_id
|
|
673
|
+
|
|
674
|
+
Supports two authentication modes:
|
|
675
|
+
1. Direct credentials: Provide `auth_config` with typed credentials
|
|
676
|
+
2. Server-side OAuth: Provide `server_side_oauth_secret_id` from OAuth flow
|
|
677
|
+
|
|
678
|
+
Args:
|
|
679
|
+
external_user_id: Workspace identifier in Airbyte Cloud
|
|
680
|
+
airbyte_client_id: Airbyte OAuth client ID
|
|
681
|
+
airbyte_client_secret: Airbyte OAuth client secret
|
|
682
|
+
auth_config: Typed auth config. Required unless using server_side_oauth_secret_id.
|
|
683
|
+
server_side_oauth_secret_id: OAuth secret ID from initiate_oauth redirect.
|
|
684
|
+
When provided, auth_config is not required.
|
|
685
|
+
name: Optional source name (defaults to connector name + external_user_id)
|
|
686
|
+
replication_config: Typed replication settings.
|
|
687
|
+
Required for connectors with x-airbyte-replication-config (REPLICATION mode sources).
|
|
688
|
+
source_template_id: Source template ID. Required when organization has
|
|
689
|
+
multiple source templates for this connector type.
|
|
690
|
+
|
|
691
|
+
Returns:
|
|
692
|
+
A SlackConnector instance configured in hosted mode
|
|
693
|
+
|
|
694
|
+
Raises:
|
|
695
|
+
ValueError: If neither or both auth_config and server_side_oauth_secret_id provided
|
|
696
|
+
|
|
697
|
+
Example:
|
|
698
|
+
# Create a new hosted connector with API key auth
|
|
699
|
+
connector = await SlackConnector.create_hosted(
|
|
700
|
+
external_user_id="my-workspace",
|
|
701
|
+
airbyte_client_id="client_abc",
|
|
702
|
+
airbyte_client_secret="secret_xyz",
|
|
703
|
+
auth_config=SlackAuthConfig(api_token="..."),
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
# With replication config (required for this connector):
|
|
707
|
+
connector = await SlackConnector.create_hosted(
|
|
708
|
+
external_user_id="my-workspace",
|
|
709
|
+
airbyte_client_id="client_abc",
|
|
710
|
+
airbyte_client_secret="secret_xyz",
|
|
711
|
+
auth_config=SlackAuthConfig(api_token="..."),
|
|
712
|
+
replication_config=SlackReplicationConfig(start_date="...", lookback_window="...", join_channels="..."),
|
|
713
|
+
)
|
|
714
|
+
|
|
715
|
+
# With server-side OAuth:
|
|
716
|
+
connector = await SlackConnector.create_hosted(
|
|
717
|
+
external_user_id="my-workspace",
|
|
718
|
+
airbyte_client_id="client_abc",
|
|
719
|
+
airbyte_client_secret="secret_xyz",
|
|
720
|
+
server_side_oauth_secret_id="airbyte_oauth_..._secret_...",
|
|
721
|
+
replication_config=SlackReplicationConfig(start_date="...", lookback_window="...", join_channels="..."),
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
# Use the connector
|
|
725
|
+
result = await connector.execute("entity", "list", {})
|
|
726
|
+
"""
|
|
727
|
+
# Validate: exactly one of auth_config or server_side_oauth_secret_id required
|
|
728
|
+
if auth_config is None and server_side_oauth_secret_id is None:
|
|
729
|
+
raise ValueError(
|
|
730
|
+
"Either auth_config or server_side_oauth_secret_id must be provided"
|
|
731
|
+
)
|
|
732
|
+
if auth_config is not None and server_side_oauth_secret_id is not None:
|
|
733
|
+
raise ValueError(
|
|
734
|
+
"Cannot provide both auth_config and server_side_oauth_secret_id"
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
from ._vendored.connector_sdk.cloud_utils import AirbyteCloudClient
|
|
738
|
+
|
|
739
|
+
client = AirbyteCloudClient(
|
|
740
|
+
client_id=airbyte_client_id,
|
|
741
|
+
client_secret=airbyte_client_secret,
|
|
742
|
+
)
|
|
743
|
+
|
|
744
|
+
try:
|
|
745
|
+
# Build credentials from auth_config (if provided)
|
|
746
|
+
credentials = auth_config.model_dump(exclude_none=True) if auth_config else None
|
|
747
|
+
replication_config_dict = replication_config.model_dump(exclude_none=True) if replication_config else None
|
|
748
|
+
|
|
749
|
+
# Create source on Airbyte Cloud
|
|
750
|
+
source_name = name or f"{cls.connector_name} - {external_user_id}"
|
|
751
|
+
source_id = await client.create_source(
|
|
752
|
+
name=source_name,
|
|
753
|
+
connector_definition_id=str(SlackConnectorModel.id),
|
|
754
|
+
external_user_id=external_user_id,
|
|
755
|
+
credentials=credentials,
|
|
756
|
+
replication_config=replication_config_dict,
|
|
757
|
+
server_side_oauth_secret_id=server_side_oauth_secret_id,
|
|
758
|
+
source_template_id=source_template_id,
|
|
759
|
+
)
|
|
760
|
+
finally:
|
|
761
|
+
await client.close()
|
|
762
|
+
|
|
763
|
+
# Return connector configured with the new connector_id
|
|
764
|
+
return cls(
|
|
765
|
+
airbyte_client_id=airbyte_client_id,
|
|
766
|
+
airbyte_client_secret=airbyte_client_secret,
|
|
767
|
+
connector_id=source_id,
|
|
768
|
+
)
|
|
769
|
+
|
|
770
|
+
|
|
570
771
|
|
|
571
772
|
|
|
572
773
|
class UsersQuery:
|
airbyte_agent_slack/models.py
CHANGED
|
@@ -34,6 +34,20 @@ class SlackOauth20AuthenticationAuthConfig(BaseModel):
|
|
|
34
34
|
|
|
35
35
|
SlackAuthConfig = SlackTokenAuthenticationAuthConfig | SlackOauth20AuthenticationAuthConfig
|
|
36
36
|
|
|
37
|
+
# Replication configuration
|
|
38
|
+
|
|
39
|
+
class SlackReplicationConfig(BaseModel):
|
|
40
|
+
"""Replication Configuration - Settings for data replication from Slack."""
|
|
41
|
+
|
|
42
|
+
model_config = ConfigDict(extra="forbid")
|
|
43
|
+
|
|
44
|
+
start_date: str
|
|
45
|
+
"""UTC date and time in the format YYYY-MM-DDTHH:mm:ssZ from which to start replicating data."""
|
|
46
|
+
lookback_window: int
|
|
47
|
+
"""Number of days to look back when syncing data (0-365)."""
|
|
48
|
+
join_channels: bool
|
|
49
|
+
"""Whether to automatically join public channels to sync messages."""
|
|
50
|
+
|
|
37
51
|
# ===== RESPONSE TYPE DEFINITIONS (PYDANTIC) =====
|
|
38
52
|
|
|
39
53
|
class User(BaseModel):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: airbyte-agent-slack
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.40
|
|
4
4
|
Summary: Airbyte Slack Connector for AI platforms
|
|
5
5
|
Project-URL: Homepage, https://github.com/airbytehq/airbyte-agent-connectors
|
|
6
6
|
Project-URL: Documentation, https://docs.airbyte.com/ai-agents/
|
|
@@ -158,7 +158,7 @@ See the official [Slack API reference](https://api.slack.com/methods).
|
|
|
158
158
|
|
|
159
159
|
## Version information
|
|
160
160
|
|
|
161
|
-
- **Package version:** 0.1.
|
|
161
|
+
- **Package version:** 0.1.40
|
|
162
162
|
- **Connector version:** 0.1.12
|
|
163
|
-
- **Generated with Connector SDK commit SHA:**
|
|
163
|
+
- **Generated with Connector SDK commit SHA:** 9d9866b0aae8c3494d04d34e193b9bd860bfc1c6
|
|
164
164
|
- **Changelog:** [View changelog](https://github.com/airbytehq/airbyte-agent-connectors/blob/main/connectors/slack/CHANGELOG.md)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
airbyte_agent_slack/__init__.py,sha256=
|
|
2
|
-
airbyte_agent_slack/connector.py,sha256=
|
|
1
|
+
airbyte_agent_slack/__init__.py,sha256=gJS52JC97BmPpgjF1WcbI4HNDioHJcnlGRVDYVpBFe8,3807
|
|
2
|
+
airbyte_agent_slack/connector.py,sha256=BFcKp3buXgo6Sh-DOu5lBGYmnTqF3R4Rz6SE1G2l2io,49392
|
|
3
3
|
airbyte_agent_slack/connector_model.py,sha256=W8DFMX20VxPr2IxTzEIjYcYNSt-E0JNj1b5UizuaWV0,194577
|
|
4
|
-
airbyte_agent_slack/models.py,sha256=
|
|
4
|
+
airbyte_agent_slack/models.py,sha256=1CANLg66D2QD5TkK06mbYGLkQyv9WpZmeN0QBGaLX_0,30019
|
|
5
5
|
airbyte_agent_slack/types.py,sha256=QDLOYuH23w4H_5fxVjTcBBz6BMYm2PWbuM1K_EOcD4o,32154
|
|
6
6
|
airbyte_agent_slack/_vendored/__init__.py,sha256=ILl7AHXMui__swyrjxrh9yRa4dLiwBvV6axPWFWty80,38
|
|
7
7
|
airbyte_agent_slack/_vendored/connector_sdk/__init__.py,sha256=T5o7roU6NSpH-lCAGZ338sE5dlh4ZU6i6IkeG1zpems,1949
|
|
@@ -19,9 +19,9 @@ airbyte_agent_slack/_vendored/connector_sdk/utils.py,sha256=UYwYuSLhsDD-4C0dBs7Q
|
|
|
19
19
|
airbyte_agent_slack/_vendored/connector_sdk/validation.py,sha256=w5WGnmILkdBslpXhAXhKhE-c8ANBc_OZQxr_fUeAgtc,39666
|
|
20
20
|
airbyte_agent_slack/_vendored/connector_sdk/validation_replication.py,sha256=v7F5YWd5m4diIF7_4m4nOkC9crg97vqRUUkt9ka9HZ4,36043
|
|
21
21
|
airbyte_agent_slack/_vendored/connector_sdk/cloud_utils/__init__.py,sha256=4799Hv9f2zxDVj1aLyQ8JpTEuFTp_oOZMRz-NZCdBJg,134
|
|
22
|
-
airbyte_agent_slack/_vendored/connector_sdk/cloud_utils/client.py,sha256=
|
|
22
|
+
airbyte_agent_slack/_vendored/connector_sdk/cloud_utils/client.py,sha256=e0VLNCmesGGfo2uD0GiICgXsXTeTkh0GYiVgx_e4VEc,12296
|
|
23
23
|
airbyte_agent_slack/_vendored/connector_sdk/executor/__init__.py,sha256=EmG9YQNAjSuYCVB4D5VoLm4qpD1KfeiiOf7bpALj8p8,702
|
|
24
|
-
airbyte_agent_slack/_vendored/connector_sdk/executor/hosted_executor.py,sha256=
|
|
24
|
+
airbyte_agent_slack/_vendored/connector_sdk/executor/hosted_executor.py,sha256=tv0njAdy-gdHBg4izgcxhEWYbrNiBifEYEca9AWzaL0,8693
|
|
25
25
|
airbyte_agent_slack/_vendored/connector_sdk/executor/local_executor.py,sha256=RtdTXFzfoJz5Coz9nwQi81Df1402BRgO1Mgd3ZzTkfw,76581
|
|
26
26
|
airbyte_agent_slack/_vendored/connector_sdk/executor/models.py,sha256=mUUBnuShKXxVIfsTOhMiI2rn2a-50jJG7SFGKT_P6Jk,6281
|
|
27
27
|
airbyte_agent_slack/_vendored/connector_sdk/http/__init__.py,sha256=y8fbzZn-3yV9OxtYz8Dy6FFGI5v6TOqADd1G3xHH3Hw,911
|
|
@@ -53,6 +53,6 @@ airbyte_agent_slack/_vendored/connector_sdk/telemetry/__init__.py,sha256=RaLgkBU
|
|
|
53
53
|
airbyte_agent_slack/_vendored/connector_sdk/telemetry/config.py,sha256=tLmQwAFD0kP1WyBGWBS3ysaudN9H3e-3EopKZi6cGKg,885
|
|
54
54
|
airbyte_agent_slack/_vendored/connector_sdk/telemetry/events.py,sha256=8Y1NbXiwISX-V_wRofY7PqcwEXD0dLMnntKkY6XFU2s,1328
|
|
55
55
|
airbyte_agent_slack/_vendored/connector_sdk/telemetry/tracker.py,sha256=SginFQbHqVUVYG82NnNzG34O-tAQ_wZYjGDcuo0q4Kk,5584
|
|
56
|
-
airbyte_agent_slack-0.1.
|
|
57
|
-
airbyte_agent_slack-0.1.
|
|
58
|
-
airbyte_agent_slack-0.1.
|
|
56
|
+
airbyte_agent_slack-0.1.40.dist-info/METADATA,sha256=deKG1jZg_tccxVlEvidcw4Bgbntux6UDOhLTdM1jFdk,6597
|
|
57
|
+
airbyte_agent_slack-0.1.40.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
58
|
+
airbyte_agent_slack-0.1.40.dist-info/RECORD,,
|
|
File without changes
|