airbyte-agent-orb 0.1.5__py3-none-any.whl → 0.1.7__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.
@@ -161,24 +161,80 @@ 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
+
164
210
  async def create_source(
165
211
  self,
166
212
  name: str,
167
213
  connector_definition_id: str,
168
214
  external_user_id: str,
169
- credentials: dict[str, Any],
215
+ credentials: dict[str, Any] | None = None,
170
216
  replication_config: dict[str, Any] | None = None,
217
+ server_side_oauth_secret_id: str | None = None,
218
+ source_template_id: str | None = None,
171
219
  ) -> str:
172
- """Create a new source on Airbyte Agent Platform.
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
173
225
 
174
226
  Args:
175
227
  name: Source name
176
228
  connector_definition_id: UUID of the connector definition
177
229
  external_user_id: User identifier
178
- credentials: Connector auth config dict
230
+ credentials: Connector auth config dict. Required unless using OAuth.
179
231
  replication_config: Optional replication settings (e.g., start_date for
180
232
  connectors with x-airbyte-replication-config). Required for REPLICATION
181
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.
182
238
 
183
239
  Returns:
184
240
  The created source ID (UUID string)
@@ -187,19 +243,21 @@ class AirbyteCloudClient:
187
243
  httpx.HTTPStatusError: If creation fails
188
244
 
189
245
  Example:
246
+ # With direct credentials:
190
247
  source_id = await client.create_source(
191
- name="My Gong Source",
192
- connector_definition_id="32382e40-3b49-4b99-9c5c-4076501914e7",
248
+ name="My Intercom Source",
249
+ connector_definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
193
250
  external_user_id="my-workspace",
194
- credentials={"access_key": "...", "access_key_secret": "..."}
251
+ credentials={"access_token": "..."},
252
+ replication_config={"start_date": "2024-01-01T00:00:00Z"}
195
253
  )
196
254
 
197
- # For REPLICATION mode sources (e.g., Intercom):
255
+ # With server-side OAuth:
198
256
  source_id = await client.create_source(
199
257
  name="My Intercom Source",
200
258
  connector_definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
201
259
  external_user_id="my-workspace",
202
- credentials={"access_token": "..."},
260
+ server_side_oauth_secret_id="airbyte_oauth_..._secret_...",
203
261
  replication_config={"start_date": "2024-01-01T00:00:00Z"}
204
262
  )
205
263
  """
@@ -211,11 +269,16 @@ class AirbyteCloudClient:
211
269
  "name": name,
212
270
  "definition_id": connector_definition_id,
213
271
  "external_user_id": external_user_id,
214
- "credentials": credentials,
215
272
  }
216
273
 
274
+ if credentials is not None:
275
+ request_body["credentials"] = credentials
217
276
  if replication_config is not None:
218
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
219
282
 
220
283
  response = await self._http_client.post(url, json=request_body, headers=headers)
221
284
  response.raise_for_status()
@@ -10,7 +10,7 @@ from enum import StrEnum
10
10
  from typing import Any, Dict
11
11
  from uuid import UUID
12
12
 
13
- from pydantic import BaseModel, ConfigDict, Field, field_validator
13
+ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
14
14
  from pydantic_core import Url
15
15
 
16
16
  from .extensions import CacheConfig, ReplicationConfig, RetryConfig
@@ -210,3 +210,34 @@ class Server(BaseModel):
210
210
  raise ValueError("Server URL cannot be empty")
211
211
  # Allow both absolute URLs and relative paths
212
212
  return v
213
+
214
+ @model_validator(mode="after")
215
+ def validate_replication_environment_mapping(self) -> "Server":
216
+ """Validate that x-airbyte-replication-environment-mapping sources exist in variables.
217
+
218
+ For simple mappings like {"subdomain": "subdomain"}, the key is the source variable.
219
+ For transform mappings like {"domain": {"source": "subdomain", "format": "..."}},
220
+ the "source" field is the source variable.
221
+ """
222
+ env_mapping = self.x_airbyte_replication_environment_mapping
223
+ if not env_mapping or not self.variables:
224
+ return self
225
+
226
+ variable_names = set(self.variables.keys())
227
+
228
+ for env_key, mapping_value in env_mapping.items():
229
+ if isinstance(mapping_value, str):
230
+ source_var = env_key
231
+ elif isinstance(mapping_value, EnvironmentMappingTransform):
232
+ source_var = mapping_value.source
233
+ else:
234
+ continue
235
+
236
+ if source_var not in variable_names:
237
+ available = ", ".join(sorted(variable_names)) if variable_names else "(none)"
238
+ raise ValueError(
239
+ f"x-airbyte-replication-environment-mapping: source variable '{source_var}' "
240
+ f"not found in server variables. Available: {available}"
241
+ )
242
+
243
+ return self
@@ -14,7 +14,7 @@ are implemented.
14
14
 
15
15
  from typing import Literal
16
16
 
17
- from pydantic import BaseModel, ConfigDict, Field
17
+ from pydantic import BaseModel, ConfigDict, Field, model_validator
18
18
 
19
19
 
20
20
  class PaginationConfig(BaseModel):
@@ -252,6 +252,24 @@ class ReplicationConfig(BaseModel):
252
252
  description="Mapping from replication_config field names to source_config field names",
253
253
  )
254
254
 
255
+ @model_validator(mode="after")
256
+ def validate_replication_config_key_mapping(self) -> "ReplicationConfig":
257
+ """Validate that replication_config_key_mapping keys exist in properties.
258
+
259
+ The mapping is: {local_key: airbyte_path}
260
+ We validate that local_key exists in our properties.
261
+ """
262
+ if self.replication_config_key_mapping and self.properties:
263
+ property_names = set(self.properties.keys())
264
+ for local_key, airbyte_path in self.replication_config_key_mapping.items():
265
+ if local_key not in property_names:
266
+ available = ", ".join(sorted(property_names)) if property_names else "(none)"
267
+ raise ValueError(
268
+ f"replication_config_key_mapping: local key '{local_key}' "
269
+ f"(mapped to '{airbyte_path}') not found in properties. Available: {available}"
270
+ )
271
+ return self
272
+
255
273
 
256
274
  class CacheConfig(BaseModel):
257
275
  """
@@ -81,6 +81,21 @@ class AuthConfigOption(BaseModel):
81
81
  description="Mapping from source config paths (e.g., 'credentials.api_key') to auth config keys for direct connectors",
82
82
  )
83
83
 
84
+ @model_validator(mode="after")
85
+ def validate_replication_auth_key_mapping(self) -> "AuthConfigOption":
86
+ """Validate that replication_auth_key_mapping target keys exist in properties."""
87
+ if self.replication_auth_key_mapping and self.properties:
88
+ property_names = set(self.properties.keys())
89
+ for airbyte_path, our_key in self.replication_auth_key_mapping.items():
90
+ if our_key not in property_names:
91
+ option_context = f"oneOf option '{self.title}'" if self.title else "oneOf option"
92
+ available = ", ".join(sorted(property_names)) if property_names else "(none)"
93
+ raise ValueError(
94
+ f"replication_auth_key_mapping in {option_context}: target key '{our_key}' "
95
+ f"(mapped from '{airbyte_path}') not found in properties. Available: {available}"
96
+ )
97
+ return self
98
+
84
99
 
85
100
  class AirbyteAuthConfig(BaseModel):
86
101
  """
@@ -146,8 +161,30 @@ class AirbyteAuthConfig(BaseModel):
146
161
  if not self.auth_mapping:
147
162
  raise ValueError("Single auth option must have auth_mapping")
148
163
 
164
+ # Validate replication_auth_key_mapping targets exist in properties
165
+ if self.replication_auth_key_mapping and self.properties:
166
+ self._validate_replication_auth_key_mapping(self.replication_auth_key_mapping, self.properties, context="x-airbyte-auth-config")
167
+
149
168
  return self
150
169
 
170
+ @staticmethod
171
+ def _validate_replication_auth_key_mapping(mapping: Dict[str, str], properties: Dict[str, AuthConfigFieldSpec], context: str) -> None:
172
+ """Validate that replication_auth_key_mapping target keys exist in properties.
173
+
174
+ Args:
175
+ mapping: The replication_auth_key_mapping dict (airbyte_path -> our_key)
176
+ properties: The properties dict from x-airbyte-auth-config
177
+ context: Context string for error messages
178
+ """
179
+ property_names = set(properties.keys())
180
+ for airbyte_path, our_key in mapping.items():
181
+ if our_key not in property_names:
182
+ available = ", ".join(sorted(property_names)) if property_names else "(none)"
183
+ raise ValueError(
184
+ f"replication_auth_key_mapping in {context}: target key '{our_key}' "
185
+ f"(mapped from '{airbyte_path}') not found in properties. Available: {available}"
186
+ )
187
+
151
188
 
152
189
  class SecurityScheme(BaseModel):
153
190
  """
@@ -543,6 +543,7 @@ class OrbConnector:
543
543
  auth_config: "OrbAuthConfig",
544
544
  name: str | None = None,
545
545
  replication_config: dict[str, Any] | None = None,
546
+ source_template_id: str | None = None,
546
547
  ) -> "OrbConnector":
547
548
  """
548
549
  Create a new hosted connector on Airbyte Cloud.
@@ -559,6 +560,8 @@ class OrbConnector:
559
560
  name: Optional source name (defaults to connector name + external_user_id)
560
561
  replication_config: Optional replication settings dict.
561
562
  Required for connectors with x-airbyte-replication-config (REPLICATION mode sources).
563
+ source_template_id: Source template ID. Required when organization has
564
+ multiple source templates for this connector type.
562
565
 
563
566
  Returns:
564
567
  A OrbConnector instance configured in hosted mode
@@ -575,6 +578,7 @@ class OrbConnector:
575
578
  # Use the connector
576
579
  result = await connector.execute("entity", "list", {})
577
580
  """
581
+
578
582
  from ._vendored.connector_sdk.cloud_utils import AirbyteCloudClient
579
583
 
580
584
  client = AirbyteCloudClient(
@@ -583,8 +587,8 @@ class OrbConnector:
583
587
  )
584
588
 
585
589
  try:
586
- # Build credentials from auth_config
587
- credentials = auth_config.model_dump(exclude_none=True)
590
+ # Build credentials from auth_config (if provided)
591
+ credentials = auth_config.model_dump(exclude_none=True) if auth_config else None
588
592
  replication_config_dict = replication_config.model_dump(exclude_none=True) if replication_config else None
589
593
 
590
594
  # Create source on Airbyte Cloud
@@ -595,6 +599,7 @@ class OrbConnector:
595
599
  external_user_id=external_user_id,
596
600
  credentials=credentials,
597
601
  replication_config=replication_config_dict,
602
+ source_template_id=source_template_id,
598
603
  )
599
604
  finally:
600
605
  await client.close()
@@ -608,6 +613,7 @@ class OrbConnector:
608
613
 
609
614
 
610
615
 
616
+
611
617
  class CustomersQuery:
612
618
  """
613
619
  Query class for Customers entity operations.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airbyte-agent-orb
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Airbyte Orb 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/
@@ -147,7 +147,7 @@ See the official [Orb API reference](https://docs.withorb.com/api-reference).
147
147
 
148
148
  ## Version information
149
149
 
150
- - **Package version:** 0.1.5
150
+ - **Package version:** 0.1.7
151
151
  - **Connector version:** 0.1.1
152
- - **Generated with Connector SDK commit SHA:** b184da3e22ef8521d2eeebf3c96a0fe8da2424f5
152
+ - **Generated with Connector SDK commit SHA:** 940246757c7476ed4edd7d16b873ebe54ea2b456
153
153
  - **Changelog:** [View changelog](https://github.com/airbytehq/airbyte-agent-connectors/blob/main/connectors/orb/CHANGELOG.md)
@@ -1,5 +1,5 @@
1
1
  airbyte_agent_orb/__init__.py,sha256=jHWqgCDpIiDZB1WLwcKo4aNXkp5ypSdV0WQWkCNJv_Y,3225
2
- airbyte_agent_orb/connector.py,sha256=KYeYW2DnDEYKMzp_nTdD17ydcB5Oh1Dwz0NNLIXswng,41204
2
+ airbyte_agent_orb/connector.py,sha256=dCsSG2QFX4hdIyMJzNiP0sCj4xWoAKAKKrGxH83AVmc,41497
3
3
  airbyte_agent_orb/connector_model.py,sha256=mhxwbi31hLA-oU2I8oQq7uMK4S0KV8XGjCELQRGth50,120056
4
4
  airbyte_agent_orb/models.py,sha256=dFg7AeDxlgoGO8eU9ypRTLqULqSAHDA3cuaXKEKbsyk,22410
5
5
  airbyte_agent_orb/types.py,sha256=O6Q2AOp8BYjYhpEFvOZXnzQDf-7GAKnpCorER2Puh2E,37077
@@ -19,7 +19,7 @@ airbyte_agent_orb/_vendored/connector_sdk/utils.py,sha256=UYwYuSLhsDD-4C0dBs7Qy0
19
19
  airbyte_agent_orb/_vendored/connector_sdk/validation.py,sha256=w5WGnmILkdBslpXhAXhKhE-c8ANBc_OZQxr_fUeAgtc,39666
20
20
  airbyte_agent_orb/_vendored/connector_sdk/validation_replication.py,sha256=v7F5YWd5m4diIF7_4m4nOkC9crg97vqRUUkt9ka9HZ4,36043
21
21
  airbyte_agent_orb/_vendored/connector_sdk/cloud_utils/__init__.py,sha256=4799Hv9f2zxDVj1aLyQ8JpTEuFTp_oOZMRz-NZCdBJg,134
22
- airbyte_agent_orb/_vendored/connector_sdk/cloud_utils/client.py,sha256=-_ibaHVa7KBBw8SnMuxpWz6XkrSgNTFdMgDfTChtywg,9505
22
+ airbyte_agent_orb/_vendored/connector_sdk/cloud_utils/client.py,sha256=e0VLNCmesGGfo2uD0GiICgXsXTeTkh0GYiVgx_e4VEc,12296
23
23
  airbyte_agent_orb/_vendored/connector_sdk/executor/__init__.py,sha256=EmG9YQNAjSuYCVB4D5VoLm4qpD1KfeiiOf7bpALj8p8,702
24
24
  airbyte_agent_orb/_vendored/connector_sdk/executor/hosted_executor.py,sha256=tv0njAdy-gdHBg4izgcxhEWYbrNiBifEYEca9AWzaL0,8693
25
25
  airbyte_agent_orb/_vendored/connector_sdk/executor/local_executor.py,sha256=RtdTXFzfoJz5Coz9nwQi81Df1402BRgO1Mgd3ZzTkfw,76581
@@ -43,16 +43,16 @@ airbyte_agent_orb/_vendored/connector_sdk/performance/__init__.py,sha256=Sp5fSd1
43
43
  airbyte_agent_orb/_vendored/connector_sdk/performance/instrumentation.py,sha256=_dXvNiqdndIBwDjeDKNViWzn_M5FkSUsMmJtFldrmsM,1504
44
44
  airbyte_agent_orb/_vendored/connector_sdk/performance/metrics.py,sha256=FRff7dKt4iwt_A7pxV5n9kAGBR756PC7q8-weWygPSM,2817
45
45
  airbyte_agent_orb/_vendored/connector_sdk/schema/__init__.py,sha256=Uymu-QuzGJuMxexBagIvUxpVAigIuIhz3KeBl_Vu4Ko,1638
46
- airbyte_agent_orb/_vendored/connector_sdk/schema/base.py,sha256=mOO5eZSK-FB7S-ZXpt5HFG5YBg8x-oM6RZRLPOEGxZM,7115
46
+ airbyte_agent_orb/_vendored/connector_sdk/schema/base.py,sha256=0R0aR4HjcJpu3vN0jZ4nPBEwVZ_7J9_XLQgWaQGT3Fs,8476
47
47
  airbyte_agent_orb/_vendored/connector_sdk/schema/components.py,sha256=nJIPieavwX3o3ODvdtLHPk84d_V229xmg6LDfwEHjzc,8119
48
48
  airbyte_agent_orb/_vendored/connector_sdk/schema/connector.py,sha256=mSZk1wr2YSdRj9tTRsPAuIlCzd_xZLw-Bzl1sMwE0rE,3731
49
- airbyte_agent_orb/_vendored/connector_sdk/schema/extensions.py,sha256=5hgpFHK7fzpzegCkJk882DeIP79bCx_qairKJhvPMZ8,9590
49
+ airbyte_agent_orb/_vendored/connector_sdk/schema/extensions.py,sha256=DqWCvyWKLnPxAbJirq6uITf-MBeJRVCcsEjySF4fuhQ,10558
50
50
  airbyte_agent_orb/_vendored/connector_sdk/schema/operations.py,sha256=St-A75m6sZUZlsoM6WcoPaShYu_X1K19pdyPvJbabOE,6214
51
- airbyte_agent_orb/_vendored/connector_sdk/schema/security.py,sha256=R-21DLnp-ANIRO1Dzqo53TYFJL6lCp0aO8GSuxa_bDI,9225
51
+ airbyte_agent_orb/_vendored/connector_sdk/schema/security.py,sha256=5UeaN63InuInS_XHNZSm5yDXrMLm5lhz298l-3GSc_4,11435
52
52
  airbyte_agent_orb/_vendored/connector_sdk/telemetry/__init__.py,sha256=RaLgkBU4dfxn1LC5Y0Q9rr2PJbrwjxvPgBLmq8_WafE,211
53
53
  airbyte_agent_orb/_vendored/connector_sdk/telemetry/config.py,sha256=tLmQwAFD0kP1WyBGWBS3ysaudN9H3e-3EopKZi6cGKg,885
54
54
  airbyte_agent_orb/_vendored/connector_sdk/telemetry/events.py,sha256=8Y1NbXiwISX-V_wRofY7PqcwEXD0dLMnntKkY6XFU2s,1328
55
55
  airbyte_agent_orb/_vendored/connector_sdk/telemetry/tracker.py,sha256=SginFQbHqVUVYG82NnNzG34O-tAQ_wZYjGDcuo0q4Kk,5584
56
- airbyte_agent_orb-0.1.5.dist-info/METADATA,sha256=z_-GPecIUiy42GQZ_Yyrim1v_-J9O91ZNMPoBLVSnnw,5670
57
- airbyte_agent_orb-0.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
58
- airbyte_agent_orb-0.1.5.dist-info/RECORD,,
56
+ airbyte_agent_orb-0.1.7.dist-info/METADATA,sha256=I_Biiotj9EZ2BMBPaxWxlCDt8h57_CjyGn3d95gEt_0,5670
57
+ airbyte_agent_orb-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
58
+ airbyte_agent_orb-0.1.7.dist-info/RECORD,,