airbyte-agent-stripe 0.5.28__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_stripe/__init__.py +237 -0
- airbyte_agent_stripe/_vendored/__init__.py +1 -0
- airbyte_agent_stripe/_vendored/connector_sdk/__init__.py +82 -0
- airbyte_agent_stripe/_vendored/connector_sdk/auth_strategies.py +1123 -0
- airbyte_agent_stripe/_vendored/connector_sdk/auth_template.py +135 -0
- airbyte_agent_stripe/_vendored/connector_sdk/cloud_utils/__init__.py +5 -0
- airbyte_agent_stripe/_vendored/connector_sdk/cloud_utils/client.py +213 -0
- airbyte_agent_stripe/_vendored/connector_sdk/connector_model_loader.py +957 -0
- airbyte_agent_stripe/_vendored/connector_sdk/constants.py +78 -0
- airbyte_agent_stripe/_vendored/connector_sdk/exceptions.py +23 -0
- airbyte_agent_stripe/_vendored/connector_sdk/executor/__init__.py +31 -0
- airbyte_agent_stripe/_vendored/connector_sdk/executor/hosted_executor.py +197 -0
- airbyte_agent_stripe/_vendored/connector_sdk/executor/local_executor.py +1524 -0
- airbyte_agent_stripe/_vendored/connector_sdk/executor/models.py +190 -0
- airbyte_agent_stripe/_vendored/connector_sdk/extensions.py +655 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/__init__.py +37 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/adapters/__init__.py +9 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/adapters/httpx_adapter.py +251 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/config.py +98 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/exceptions.py +119 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/protocols.py +114 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http/response.py +102 -0
- airbyte_agent_stripe/_vendored/connector_sdk/http_client.py +686 -0
- airbyte_agent_stripe/_vendored/connector_sdk/logging/__init__.py +11 -0
- airbyte_agent_stripe/_vendored/connector_sdk/logging/logger.py +264 -0
- airbyte_agent_stripe/_vendored/connector_sdk/logging/types.py +92 -0
- airbyte_agent_stripe/_vendored/connector_sdk/observability/__init__.py +11 -0
- airbyte_agent_stripe/_vendored/connector_sdk/observability/models.py +19 -0
- airbyte_agent_stripe/_vendored/connector_sdk/observability/redactor.py +81 -0
- airbyte_agent_stripe/_vendored/connector_sdk/observability/session.py +94 -0
- airbyte_agent_stripe/_vendored/connector_sdk/performance/__init__.py +6 -0
- airbyte_agent_stripe/_vendored/connector_sdk/performance/instrumentation.py +57 -0
- airbyte_agent_stripe/_vendored/connector_sdk/performance/metrics.py +93 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/__init__.py +75 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/base.py +161 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/components.py +238 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/connector.py +131 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/extensions.py +109 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/operations.py +146 -0
- airbyte_agent_stripe/_vendored/connector_sdk/schema/security.py +213 -0
- airbyte_agent_stripe/_vendored/connector_sdk/secrets.py +182 -0
- airbyte_agent_stripe/_vendored/connector_sdk/telemetry/__init__.py +10 -0
- airbyte_agent_stripe/_vendored/connector_sdk/telemetry/config.py +32 -0
- airbyte_agent_stripe/_vendored/connector_sdk/telemetry/events.py +58 -0
- airbyte_agent_stripe/_vendored/connector_sdk/telemetry/tracker.py +151 -0
- airbyte_agent_stripe/_vendored/connector_sdk/types.py +241 -0
- airbyte_agent_stripe/_vendored/connector_sdk/utils.py +60 -0
- airbyte_agent_stripe/_vendored/connector_sdk/validation.py +822 -0
- airbyte_agent_stripe/connector.py +1579 -0
- airbyte_agent_stripe/connector_model.py +14869 -0
- airbyte_agent_stripe/models.py +2353 -0
- airbyte_agent_stripe/types.py +295 -0
- airbyte_agent_stripe-0.5.28.dist-info/METADATA +114 -0
- airbyte_agent_stripe-0.5.28.dist-info/RECORD +55 -0
- airbyte_agent_stripe-0.5.28.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Constants used throughout the Airbyte SDK.
|
|
3
|
+
|
|
4
|
+
This module centralizes configuration defaults and commonly used values to improve
|
|
5
|
+
maintainability and consistency across the codebase.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
11
|
+
|
|
12
|
+
# ============================================================================
|
|
13
|
+
# HTTP Connection and Timeout Defaults
|
|
14
|
+
# ============================================================================
|
|
15
|
+
|
|
16
|
+
# Connection pooling limits
|
|
17
|
+
DEFAULT_MAX_CONNECTIONS = 100
|
|
18
|
+
"""Maximum number of concurrent HTTP connections to maintain in the pool."""
|
|
19
|
+
|
|
20
|
+
DEFAULT_MAX_KEEPALIVE_CONNECTIONS = 20
|
|
21
|
+
"""Maximum number of keepalive connections to maintain in the pool."""
|
|
22
|
+
|
|
23
|
+
# Timeout values (in seconds)
|
|
24
|
+
DEFAULT_CONNECT_TIMEOUT = 5.0
|
|
25
|
+
"""Default timeout for establishing a new connection (seconds)."""
|
|
26
|
+
|
|
27
|
+
DEFAULT_READ_TIMEOUT = 30.0
|
|
28
|
+
"""Default timeout for reading response data (seconds)."""
|
|
29
|
+
|
|
30
|
+
DEFAULT_WRITE_TIMEOUT = 30.0
|
|
31
|
+
"""Default timeout for writing request data (seconds)."""
|
|
32
|
+
|
|
33
|
+
DEFAULT_POOL_TIMEOUT = 5.0
|
|
34
|
+
"""Default timeout for acquiring a connection from the pool (seconds)."""
|
|
35
|
+
|
|
36
|
+
DEFAULT_REQUEST_TIMEOUT = 30.0
|
|
37
|
+
"""Default overall request timeout (seconds)."""
|
|
38
|
+
|
|
39
|
+
# ============================================================================
|
|
40
|
+
# OpenAPI Specification
|
|
41
|
+
# ============================================================================
|
|
42
|
+
|
|
43
|
+
OPENAPI_VERSION_PREFIX = "3.1."
|
|
44
|
+
"""Required OpenAPI version prefix. Only 3.1.x specifications are supported."""
|
|
45
|
+
|
|
46
|
+
OPENAPI_DEFAULT_VERSION = "1.0.0"
|
|
47
|
+
"""Default version string for connectors that don't specify a version."""
|
|
48
|
+
|
|
49
|
+
# ============================================================================
|
|
50
|
+
# Performance and Metrics
|
|
51
|
+
# ============================================================================
|
|
52
|
+
|
|
53
|
+
MILLISECONDS_PER_SECOND = 1000
|
|
54
|
+
"""Conversion factor from seconds to milliseconds."""
|
|
55
|
+
|
|
56
|
+
# ============================================================================
|
|
57
|
+
# Retry and Backoff Defaults
|
|
58
|
+
# ============================================================================
|
|
59
|
+
|
|
60
|
+
DEFAULT_INITIAL_DELAY_SECONDS = 1.0
|
|
61
|
+
"""Default initial delay for retry backoff (seconds)."""
|
|
62
|
+
|
|
63
|
+
DEFAULT_MAX_DELAY_SECONDS = 60.0
|
|
64
|
+
"""Default maximum delay for retry backoff (seconds)."""
|
|
65
|
+
|
|
66
|
+
# ============================================================================
|
|
67
|
+
# SDK Version
|
|
68
|
+
# ============================================================================
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
SDK_VERSION = version("connector-sdk")
|
|
72
|
+
except PackageNotFoundError:
|
|
73
|
+
# Fallback for development when package isn't installed
|
|
74
|
+
SDK_VERSION = "0.0.0-dev"
|
|
75
|
+
"""Current version of the Airbyte SDK."""
|
|
76
|
+
|
|
77
|
+
MINIMUM_PYTHON_VERSION = "3.9"
|
|
78
|
+
"""Minimum Python version required to run the SDK."""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Exceptions for the Airbyte SDK.
|
|
2
|
+
|
|
3
|
+
DEPRECATED: HTTP exceptions have been moved to connector_sdk.http.exceptions.
|
|
4
|
+
This module re-exports them for backward compatibility.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .http.exceptions import (
|
|
8
|
+
AuthenticationError,
|
|
9
|
+
HTTPClientError,
|
|
10
|
+
HTTPStatusError,
|
|
11
|
+
NetworkError,
|
|
12
|
+
RateLimitError,
|
|
13
|
+
TimeoutError,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"HTTPClientError",
|
|
18
|
+
"HTTPStatusError",
|
|
19
|
+
"AuthenticationError",
|
|
20
|
+
"RateLimitError",
|
|
21
|
+
"NetworkError",
|
|
22
|
+
"TimeoutError",
|
|
23
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Executor implementations for connector operations."""
|
|
2
|
+
|
|
3
|
+
from .hosted_executor import HostedExecutor
|
|
4
|
+
from .local_executor import LocalExecutor
|
|
5
|
+
from .models import (
|
|
6
|
+
ActionNotSupportedError,
|
|
7
|
+
EntityNotFoundError,
|
|
8
|
+
ExecutionConfig,
|
|
9
|
+
ExecutionResult,
|
|
10
|
+
ExecutorError,
|
|
11
|
+
ExecutorProtocol,
|
|
12
|
+
InvalidParameterError,
|
|
13
|
+
MissingParameterError,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
# Config and Result types
|
|
18
|
+
"ExecutionConfig",
|
|
19
|
+
"ExecutionResult",
|
|
20
|
+
# Protocol
|
|
21
|
+
"ExecutorProtocol",
|
|
22
|
+
# Executors
|
|
23
|
+
"LocalExecutor",
|
|
24
|
+
"HostedExecutor",
|
|
25
|
+
# Exceptions
|
|
26
|
+
"ExecutorError",
|
|
27
|
+
"EntityNotFoundError",
|
|
28
|
+
"ActionNotSupportedError",
|
|
29
|
+
"MissingParameterError",
|
|
30
|
+
"InvalidParameterError",
|
|
31
|
+
]
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""Hosted executor for proxying operations through the cloud API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from opentelemetry import trace
|
|
6
|
+
|
|
7
|
+
from ..cloud_utils import AirbyteCloudClient
|
|
8
|
+
|
|
9
|
+
from .models import (
|
|
10
|
+
ExecutionConfig,
|
|
11
|
+
ExecutionResult,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class HostedExecutor:
|
|
16
|
+
"""Executor that proxies execution through the Airbyte Cloud API.
|
|
17
|
+
|
|
18
|
+
This is the "hosted mode" executor that makes HTTP calls to the cloud API
|
|
19
|
+
instead of directly calling external services. The cloud API handles all
|
|
20
|
+
connector logic, secrets management, and execution.
|
|
21
|
+
|
|
22
|
+
The executor takes an external_user_id and uses the AirbyteCloudClient to:
|
|
23
|
+
1. Authenticate with the Airbyte Platform (bearer token with caching)
|
|
24
|
+
2. Look up the user's connector instance
|
|
25
|
+
3. Execute the connector operation via the cloud API
|
|
26
|
+
|
|
27
|
+
Implements ExecutorProtocol.
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
# Create executor with user ID, credentials, and connector definition ID
|
|
31
|
+
executor = HostedExecutor(
|
|
32
|
+
external_user_id="user-123",
|
|
33
|
+
airbyte_client_id="client_abc123",
|
|
34
|
+
airbyte_client_secret="secret_xyz789",
|
|
35
|
+
connector_definition_id="abc123-def456-ghi789",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Execute an operation
|
|
39
|
+
execution_config = ExecutionConfig(
|
|
40
|
+
entity="customers",
|
|
41
|
+
action="list",
|
|
42
|
+
params={"limit": 10}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
result = await executor.execute(execution_config)
|
|
46
|
+
if result.success:
|
|
47
|
+
print(f"Data: {result.data}")
|
|
48
|
+
else:
|
|
49
|
+
print(f"Error: {result.error}")
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
external_user_id: str,
|
|
55
|
+
airbyte_client_id: str,
|
|
56
|
+
airbyte_client_secret: str,
|
|
57
|
+
connector_definition_id: str,
|
|
58
|
+
):
|
|
59
|
+
"""Initialize hosted executor.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
external_user_id: User identifier in the Airbyte system
|
|
63
|
+
airbyte_client_id: Airbyte client ID for authentication
|
|
64
|
+
airbyte_client_secret: Airbyte client secret for authentication
|
|
65
|
+
connector_definition_id: Connector definition ID used to look up
|
|
66
|
+
the user's connector instance.
|
|
67
|
+
|
|
68
|
+
Example:
|
|
69
|
+
executor = HostedExecutor(
|
|
70
|
+
external_user_id="user-123",
|
|
71
|
+
airbyte_client_id="client_abc123",
|
|
72
|
+
airbyte_client_secret="secret_xyz789",
|
|
73
|
+
connector_definition_id="abc123-def456-ghi789",
|
|
74
|
+
)
|
|
75
|
+
"""
|
|
76
|
+
self._external_user_id = external_user_id
|
|
77
|
+
self._connector_definition_id = connector_definition_id
|
|
78
|
+
|
|
79
|
+
# Create AirbyteCloudClient for API interactions
|
|
80
|
+
self._cloud_client = AirbyteCloudClient(
|
|
81
|
+
client_id=airbyte_client_id,
|
|
82
|
+
client_secret=airbyte_client_secret,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
async def execute(self, config: ExecutionConfig) -> ExecutionResult:
|
|
86
|
+
"""Execute connector via cloud API (ExecutorProtocol implementation).
|
|
87
|
+
|
|
88
|
+
Flow:
|
|
89
|
+
1. Get connector id from connector model
|
|
90
|
+
2. Look up the user's connector instance ID
|
|
91
|
+
3. Execute the connector operation via the cloud API
|
|
92
|
+
4. Parse the response into ExecutionResult
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
config: Execution configuration (entity, action, params)
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
ExecutionResult with success/failure status
|
|
99
|
+
|
|
100
|
+
Raises:
|
|
101
|
+
ValueError: If no instance or multiple instances found for user
|
|
102
|
+
httpx.HTTPStatusError: If API returns 4xx/5xx status code
|
|
103
|
+
httpx.RequestError: If network request fails
|
|
104
|
+
|
|
105
|
+
Example:
|
|
106
|
+
config = ExecutionConfig(
|
|
107
|
+
entity="customers",
|
|
108
|
+
action="list",
|
|
109
|
+
params={"limit": 10}
|
|
110
|
+
)
|
|
111
|
+
result = await executor.execute(config)
|
|
112
|
+
"""
|
|
113
|
+
tracer = trace.get_tracer("airbyte.connector-sdk.executor.hosted")
|
|
114
|
+
|
|
115
|
+
with tracer.start_as_current_span("airbyte.hosted_executor.execute") as span:
|
|
116
|
+
# Add span attributes for observability
|
|
117
|
+
span.set_attribute("connector.definition_id", self._connector_definition_id)
|
|
118
|
+
span.set_attribute("connector.entity", config.entity)
|
|
119
|
+
span.set_attribute("connector.action", config.action)
|
|
120
|
+
span.set_attribute("user.external_id", self._external_user_id)
|
|
121
|
+
if config.params:
|
|
122
|
+
# Only add non-sensitive param keys
|
|
123
|
+
span.set_attribute("connector.param_keys", list(config.params.keys()))
|
|
124
|
+
|
|
125
|
+
try:
|
|
126
|
+
# Step 1: Get connector definition id
|
|
127
|
+
connector_definition_id = self._connector_definition_id
|
|
128
|
+
|
|
129
|
+
# Step 2: Get the connector instance ID for this user
|
|
130
|
+
instance_id = await self._cloud_client.get_connector_instance_id(
|
|
131
|
+
external_user_id=self._external_user_id,
|
|
132
|
+
connector_definition_id=connector_definition_id,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
span.set_attribute("connector.instance_id", instance_id)
|
|
136
|
+
|
|
137
|
+
# Step 3: Execute the connector via the cloud API
|
|
138
|
+
response = await self._cloud_client.execute_connector(
|
|
139
|
+
instance_id=instance_id,
|
|
140
|
+
entity=config.entity,
|
|
141
|
+
action=config.action,
|
|
142
|
+
params=config.params,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# Step 4: Parse the response into ExecutionResult
|
|
146
|
+
# The response_data is a dict from the API
|
|
147
|
+
result = self._parse_execution_result(response)
|
|
148
|
+
|
|
149
|
+
# Mark span as successful
|
|
150
|
+
span.set_attribute("connector.success", result.success)
|
|
151
|
+
|
|
152
|
+
return result
|
|
153
|
+
|
|
154
|
+
except ValueError as e:
|
|
155
|
+
# Instance lookup validation error (0 or >1 instances)
|
|
156
|
+
span.set_attribute("connector.success", False)
|
|
157
|
+
span.set_attribute("connector.error_type", "ValueError")
|
|
158
|
+
span.record_exception(e)
|
|
159
|
+
raise
|
|
160
|
+
|
|
161
|
+
except Exception as e:
|
|
162
|
+
# HTTP errors and other exceptions
|
|
163
|
+
span.set_attribute("connector.success", False)
|
|
164
|
+
span.set_attribute("connector.error_type", type(e).__name__)
|
|
165
|
+
span.record_exception(e)
|
|
166
|
+
raise
|
|
167
|
+
|
|
168
|
+
def _parse_execution_result(self, response: dict) -> ExecutionResult:
|
|
169
|
+
"""Parse API response into ExecutionResult.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
response_data: Raw JSON response from the cloud API
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
ExecutionResult with parsed data
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
return ExecutionResult(
|
|
179
|
+
success=True,
|
|
180
|
+
data=response["result"],
|
|
181
|
+
meta=response.get("connector_metadata"),
|
|
182
|
+
error=None,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
async def close(self):
|
|
186
|
+
"""Close the cloud client and cleanup resources.
|
|
187
|
+
|
|
188
|
+
Call this when you're done using the executor to clean up HTTP connections.
|
|
189
|
+
|
|
190
|
+
Example:
|
|
191
|
+
executor = HostedExecutor(...)
|
|
192
|
+
try:
|
|
193
|
+
result = await executor.execute(config)
|
|
194
|
+
finally:
|
|
195
|
+
await executor.close()
|
|
196
|
+
"""
|
|
197
|
+
await self._cloud_client.close()
|