airbyte-cdk 6.33.0__py3-none-any.whl → 6.33.0.dev0__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_cdk/sources/declarative/auth/token.py +8 -3
- airbyte_cdk/sources/declarative/concurrent_declarative_source.py +2 -13
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +212 -15
- airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +6 -7
- airbyte_cdk/sources/declarative/manifest_declarative_source.py +4 -0
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +169 -10
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +171 -34
- airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py +2 -4
- airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +9 -3
- airbyte_cdk/sources/declarative/requesters/http_requester.py +4 -5
- airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +5 -6
- airbyte_cdk/sources/declarative/requesters/request_option.py +4 -83
- airbyte_cdk/sources/declarative/requesters/request_options/datetime_based_request_options_provider.py +6 -7
- airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +1 -4
- airbyte_cdk/sources/streams/call_rate.py +84 -71
- airbyte_cdk/utils/mapping_helpers.py +27 -86
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/RECORD +22 -22
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/LICENSE_SHORT +0 -0
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.33.0.dist-info → airbyte_cdk-6.33.0.dev0.dist-info}/entry_points.txt +0 -0
@@ -5,7 +5,7 @@
|
|
5
5
|
import base64
|
6
6
|
import logging
|
7
7
|
from dataclasses import InitVar, dataclass
|
8
|
-
from typing import Any, Mapping,
|
8
|
+
from typing import Any, Mapping, Union
|
9
9
|
|
10
10
|
import requests
|
11
11
|
from cachetools import TTLCache, cached
|
@@ -45,6 +45,11 @@ class ApiKeyAuthenticator(DeclarativeAuthenticator):
|
|
45
45
|
config: Config
|
46
46
|
parameters: InitVar[Mapping[str, Any]]
|
47
47
|
|
48
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
49
|
+
self._field_name = InterpolatedString.create(
|
50
|
+
self.request_option.field_name, parameters=parameters
|
51
|
+
)
|
52
|
+
|
48
53
|
@property
|
49
54
|
def auth_header(self) -> str:
|
50
55
|
options = self._get_request_options(RequestOptionType.header)
|
@@ -55,9 +60,9 @@ class ApiKeyAuthenticator(DeclarativeAuthenticator):
|
|
55
60
|
return self.token_provider.get_token()
|
56
61
|
|
57
62
|
def _get_request_options(self, option_type: RequestOptionType) -> Mapping[str, Any]:
|
58
|
-
options
|
63
|
+
options = {}
|
59
64
|
if self.request_option.inject_into == option_type:
|
60
|
-
self.
|
65
|
+
options[self._field_name.eval(self.config)] = self.token
|
61
66
|
return options
|
62
67
|
|
63
68
|
def get_request_params(self) -> Mapping[str, Any]:
|
@@ -475,21 +475,10 @@ class ConcurrentDeclarativeSource(ManifestDeclarativeSource, Generic[TState]):
|
|
475
475
|
# Also a temporary hack. In the legacy Stream implementation, as part of the read,
|
476
476
|
# set_initial_state() is called to instantiate incoming state on the cursor. Although we no
|
477
477
|
# longer rely on the legacy low-code cursor for concurrent checkpointing, low-code components
|
478
|
-
# like StopConditionPaginationStrategyDecorator
|
479
|
-
# properly initialized with state.
|
478
|
+
# like StopConditionPaginationStrategyDecorator and ClientSideIncrementalRecordFilterDecorator
|
479
|
+
# still rely on a DatetimeBasedCursor that is properly initialized with state.
|
480
480
|
if retriever.cursor:
|
481
481
|
retriever.cursor.set_initial_state(stream_state=stream_state)
|
482
|
-
|
483
|
-
# Similar to above, the ClientSideIncrementalRecordFilterDecorator cursor is a separate instance
|
484
|
-
# from the one initialized on the SimpleRetriever, so it also must also have state initialized
|
485
|
-
# for semi-incremental streams using is_client_side_incremental to filter properly
|
486
|
-
if isinstance(retriever.record_selector, RecordSelector) and isinstance(
|
487
|
-
retriever.record_selector.record_filter, ClientSideIncrementalRecordFilterDecorator
|
488
|
-
):
|
489
|
-
retriever.record_selector.record_filter._cursor.set_initial_state(
|
490
|
-
stream_state=stream_state
|
491
|
-
) # type: ignore # After non-concurrent cursors are deprecated we can remove these cursor workarounds
|
492
|
-
|
493
482
|
# We zero it out here, but since this is a cursor reference, the state is still properly
|
494
483
|
# instantiated for the other components that reference it
|
495
484
|
retriever.cursor = None
|
@@ -40,6 +40,12 @@ properties:
|
|
40
40
|
"$ref": "#/definitions/Spec"
|
41
41
|
concurrency_level:
|
42
42
|
"$ref": "#/definitions/ConcurrencyLevel"
|
43
|
+
api_budget:
|
44
|
+
title: API Budget
|
45
|
+
description: Defines how many requests can be made to the API in a given time frame. This field accepts either a generic APIBudget or an HTTP-specific configuration (HTTPAPIBudget) to be applied across all streams.
|
46
|
+
anyOf:
|
47
|
+
- "$ref": "#/definitions/APIBudget"
|
48
|
+
- "$ref": "#/definitions/HTTPAPIBudget"
|
43
49
|
metadata:
|
44
50
|
type: object
|
45
51
|
description: For internal Airbyte use only - DO NOT modify manually. Used by consumers of declarative manifests for storing related metadata.
|
@@ -794,7 +800,7 @@ definitions:
|
|
794
800
|
description: This option is used to adjust the upper and lower boundaries of each datetime window to beginning and end of the provided target period (day, week, month)
|
795
801
|
type: object
|
796
802
|
required:
|
797
|
-
|
803
|
+
- target
|
798
804
|
properties:
|
799
805
|
target:
|
800
806
|
title: Target
|
@@ -1365,6 +1371,207 @@ definitions:
|
|
1365
1371
|
$parameters:
|
1366
1372
|
type: object
|
1367
1373
|
additional_properties: true
|
1374
|
+
APIBudget:
|
1375
|
+
title: API Budget
|
1376
|
+
description: >
|
1377
|
+
A generic API budget configuration that defines the policies (rate limiting rules)
|
1378
|
+
and the maximum number of attempts to acquire a call credit. This budget does not automatically
|
1379
|
+
update itself based on HTTP response headers.
|
1380
|
+
type: object
|
1381
|
+
required:
|
1382
|
+
- type
|
1383
|
+
- policies
|
1384
|
+
properties:
|
1385
|
+
type:
|
1386
|
+
type: string
|
1387
|
+
enum: [APIBudget]
|
1388
|
+
policies:
|
1389
|
+
title: Policies
|
1390
|
+
description: List of call rate policies that define how many calls are allowed.
|
1391
|
+
type: array
|
1392
|
+
items:
|
1393
|
+
anyOf:
|
1394
|
+
- "$ref": "#/definitions/FixedWindowCallRatePolicy"
|
1395
|
+
- "$ref": "#/definitions/MovingWindowCallRatePolicy"
|
1396
|
+
- "$ref": "#/definitions/UnlimitedCallRatePolicy"
|
1397
|
+
maximum_attempts_to_acquire:
|
1398
|
+
title: Maximum Attempts to Acquire
|
1399
|
+
description: The maximum number of attempts to acquire a call before giving up.
|
1400
|
+
type: integer
|
1401
|
+
default: 100000
|
1402
|
+
additionalProperties: true
|
1403
|
+
HTTPAPIBudget:
|
1404
|
+
title: HTTP API Budget
|
1405
|
+
description: >
|
1406
|
+
An HTTP-specific API budget that extends APIBudget by updating rate limiting information based
|
1407
|
+
on HTTP response headers. It extracts available calls and the next reset timestamp from the HTTP responses.
|
1408
|
+
type: object
|
1409
|
+
required:
|
1410
|
+
- type
|
1411
|
+
- policies
|
1412
|
+
properties:
|
1413
|
+
type:
|
1414
|
+
type: string
|
1415
|
+
enum: [HTTPAPIBudget]
|
1416
|
+
policies:
|
1417
|
+
title: Policies
|
1418
|
+
description: List of call rate policies that define how many calls are allowed.
|
1419
|
+
type: array
|
1420
|
+
items:
|
1421
|
+
anyOf:
|
1422
|
+
- "$ref": "#/definitions/FixedWindowCallRatePolicy"
|
1423
|
+
- "$ref": "#/definitions/MovingWindowCallRatePolicy"
|
1424
|
+
- "$ref": "#/definitions/UnlimitedCallRatePolicy"
|
1425
|
+
ratelimit_reset_header:
|
1426
|
+
title: Rate Limit Reset Header
|
1427
|
+
description: The HTTP response header name that indicates when the rate limit resets.
|
1428
|
+
type: string
|
1429
|
+
default: "ratelimit-reset"
|
1430
|
+
ratelimit_remaining_header:
|
1431
|
+
title: Rate Limit Remaining Header
|
1432
|
+
description: The HTTP response header name that indicates the number of remaining allowed calls.
|
1433
|
+
type: string
|
1434
|
+
default: "ratelimit-remaining"
|
1435
|
+
status_codes_for_ratelimit_hit:
|
1436
|
+
title: Status Codes for Rate Limit Hit
|
1437
|
+
description: List of HTTP status codes that indicate a rate limit has been hit.
|
1438
|
+
type: array
|
1439
|
+
items:
|
1440
|
+
type: integer
|
1441
|
+
default: [429]
|
1442
|
+
maximum_attempts_to_acquire:
|
1443
|
+
title: Maximum Attempts to Acquire
|
1444
|
+
description: The maximum number of attempts to acquire a call before giving up.
|
1445
|
+
type: integer
|
1446
|
+
default: 100000
|
1447
|
+
additionalProperties: true
|
1448
|
+
FixedWindowCallRatePolicy:
|
1449
|
+
title: Fixed Window Call Rate Policy
|
1450
|
+
description: A policy that allows a fixed number of calls within a specific time window.
|
1451
|
+
type: object
|
1452
|
+
required:
|
1453
|
+
- type
|
1454
|
+
- next_reset_ts
|
1455
|
+
- period
|
1456
|
+
- call_limit
|
1457
|
+
- matchers
|
1458
|
+
properties:
|
1459
|
+
type:
|
1460
|
+
type: string
|
1461
|
+
enum: [FixedWindowCallRatePolicy]
|
1462
|
+
next_reset_ts:
|
1463
|
+
title: Next Reset Timestamp
|
1464
|
+
description: The timestamp when the rate limit will reset.
|
1465
|
+
type: string
|
1466
|
+
format: date-time
|
1467
|
+
period:
|
1468
|
+
title: Period
|
1469
|
+
description: The time interval for the rate limit window.
|
1470
|
+
type: string
|
1471
|
+
format: duration
|
1472
|
+
call_limit:
|
1473
|
+
title: Call Limit
|
1474
|
+
description: The maximum number of calls allowed within the period.
|
1475
|
+
type: integer
|
1476
|
+
matchers:
|
1477
|
+
title: Matchers
|
1478
|
+
description: List of matchers that define which requests this policy applies to.
|
1479
|
+
type: array
|
1480
|
+
items:
|
1481
|
+
"$ref": "#/definitions/HttpRequestMatcher"
|
1482
|
+
additionalProperties: true
|
1483
|
+
MovingWindowCallRatePolicy:
|
1484
|
+
title: Moving Window Call Rate Policy
|
1485
|
+
description: A policy that allows a fixed number of calls within a moving time window.
|
1486
|
+
type: object
|
1487
|
+
required:
|
1488
|
+
- type
|
1489
|
+
- rates
|
1490
|
+
- matchers
|
1491
|
+
properties:
|
1492
|
+
type:
|
1493
|
+
type: string
|
1494
|
+
enum: [MovingWindowCallRatePolicy]
|
1495
|
+
rates:
|
1496
|
+
title: Rates
|
1497
|
+
description: List of rates that define the call limits for different time intervals.
|
1498
|
+
type: array
|
1499
|
+
items:
|
1500
|
+
"$ref": "#/definitions/Rate"
|
1501
|
+
matchers:
|
1502
|
+
title: Matchers
|
1503
|
+
description: List of matchers that define which requests this policy applies to.
|
1504
|
+
type: array
|
1505
|
+
items:
|
1506
|
+
"$ref": "#/definitions/HttpRequestMatcher"
|
1507
|
+
additionalProperties: true
|
1508
|
+
UnlimitedCallRatePolicy:
|
1509
|
+
title: Unlimited Call Rate Policy
|
1510
|
+
description: A policy that allows unlimited calls for specific requests.
|
1511
|
+
type: object
|
1512
|
+
required:
|
1513
|
+
- type
|
1514
|
+
- matchers
|
1515
|
+
properties:
|
1516
|
+
type:
|
1517
|
+
type: string
|
1518
|
+
enum: [UnlimitedCallRatePolicy]
|
1519
|
+
matchers:
|
1520
|
+
title: Matchers
|
1521
|
+
description: List of matchers that define which requests this policy applies to.
|
1522
|
+
type: array
|
1523
|
+
items:
|
1524
|
+
"$ref": "#/definitions/HttpRequestMatcher"
|
1525
|
+
additionalProperties: true
|
1526
|
+
Rate:
|
1527
|
+
title: Rate
|
1528
|
+
description: Defines a rate limit with a specific number of calls allowed within a time interval.
|
1529
|
+
type: object
|
1530
|
+
required:
|
1531
|
+
- limit
|
1532
|
+
- interval
|
1533
|
+
properties:
|
1534
|
+
limit:
|
1535
|
+
title: Limit
|
1536
|
+
description: The maximum number of calls allowed within the interval.
|
1537
|
+
type: integer
|
1538
|
+
interval:
|
1539
|
+
title: Interval
|
1540
|
+
description: The time interval for the rate limit.
|
1541
|
+
type: string
|
1542
|
+
format: duration
|
1543
|
+
additionalProperties: true
|
1544
|
+
HttpRequestMatcher:
|
1545
|
+
title: HTTP Request Matcher
|
1546
|
+
description: >
|
1547
|
+
Matches HTTP requests based on method, base URL, URL path pattern, query parameters, and headers.
|
1548
|
+
Use `url_base` to specify the scheme and host (without trailing slash) and
|
1549
|
+
`url_path_pattern` to apply a regex to the request path.
|
1550
|
+
type: object
|
1551
|
+
properties:
|
1552
|
+
method:
|
1553
|
+
title: Method
|
1554
|
+
description: The HTTP method to match (e.g., GET, POST).
|
1555
|
+
type: string
|
1556
|
+
url_base:
|
1557
|
+
title: URL Base
|
1558
|
+
description: The base URL (scheme and host, e.g. "https://api.example.com") to match.
|
1559
|
+
type: string
|
1560
|
+
url_path_pattern:
|
1561
|
+
title: URL Path Pattern
|
1562
|
+
description: A regular expression pattern to match the URL path.
|
1563
|
+
type: string
|
1564
|
+
params:
|
1565
|
+
title: Parameters
|
1566
|
+
description: The query parameters to match.
|
1567
|
+
type: object
|
1568
|
+
additionalProperties: true
|
1569
|
+
headers:
|
1570
|
+
title: Headers
|
1571
|
+
description: The headers to match.
|
1572
|
+
type: object
|
1573
|
+
additionalProperties: true
|
1574
|
+
additionalProperties: true
|
1368
1575
|
DefaultErrorHandler:
|
1369
1576
|
title: Default Error Handler
|
1370
1577
|
description: Component defining how to handle errors. Default behavior includes only retrying server errors (HTTP 5XX) and too many requests (HTTP 429) with an exponential backoff.
|
@@ -2847,35 +3054,25 @@ definitions:
|
|
2847
3054
|
enum: [RequestPath]
|
2848
3055
|
RequestOption:
|
2849
3056
|
title: Request Option
|
2850
|
-
description: Specifies the key field
|
3057
|
+
description: Specifies the key field and where in the request a component's value should be injected.
|
2851
3058
|
type: object
|
2852
3059
|
required:
|
2853
3060
|
- type
|
3061
|
+
- field_name
|
2854
3062
|
- inject_into
|
2855
3063
|
properties:
|
2856
3064
|
type:
|
2857
3065
|
type: string
|
2858
3066
|
enum: [RequestOption]
|
2859
3067
|
field_name:
|
2860
|
-
title:
|
2861
|
-
description: Configures which key should be used in the location that the descriptor is being injected into
|
3068
|
+
title: Request Option
|
3069
|
+
description: Configures which key should be used in the location that the descriptor is being injected into
|
2862
3070
|
type: string
|
2863
3071
|
examples:
|
2864
3072
|
- segment_id
|
2865
3073
|
interpolation_context:
|
2866
3074
|
- config
|
2867
3075
|
- parameters
|
2868
|
-
field_path:
|
2869
|
-
title: Field Path
|
2870
|
-
description: Configures a path to be used for nested structures in JSON body requests (e.g. GraphQL queries)
|
2871
|
-
type: array
|
2872
|
-
items:
|
2873
|
-
type: string
|
2874
|
-
examples:
|
2875
|
-
- ["data", "viewer", "id"]
|
2876
|
-
interpolation_context:
|
2877
|
-
- config
|
2878
|
-
- parameters
|
2879
3076
|
inject_into:
|
2880
3077
|
title: Inject Into
|
2881
3078
|
description: Configures where the descriptor should be set on the HTTP requests. Note that request parameters that are already encoded in the URL path will not be duplicated.
|
@@ -365,15 +365,14 @@ class DatetimeBasedCursor(DeclarativeCursor):
|
|
365
365
|
options: MutableMapping[str, Any] = {}
|
366
366
|
if not stream_slice:
|
367
367
|
return options
|
368
|
-
|
369
368
|
if self.start_time_option and self.start_time_option.inject_into == option_type:
|
370
|
-
|
371
|
-
|
372
|
-
|
369
|
+
options[self.start_time_option.field_name.eval(config=self.config)] = stream_slice.get( # type: ignore # field_name is always casted to an interpolated string
|
370
|
+
self._partition_field_start.eval(self.config)
|
371
|
+
)
|
373
372
|
if self.end_time_option and self.end_time_option.inject_into == option_type:
|
374
|
-
|
375
|
-
|
376
|
-
|
373
|
+
options[self.end_time_option.field_name.eval(config=self.config)] = stream_slice.get( # type: ignore [union-attr]
|
374
|
+
self._partition_field_end.eval(self.config)
|
375
|
+
)
|
377
376
|
return options
|
378
377
|
|
379
378
|
def should_be_synced(self, record: Record) -> bool:
|
@@ -137,6 +137,10 @@ class ManifestDeclarativeSource(DeclarativeSource):
|
|
137
137
|
self._source_config, config
|
138
138
|
)
|
139
139
|
|
140
|
+
api_budget_model = self._source_config.get("api_budget")
|
141
|
+
if api_budget_model:
|
142
|
+
self._constructor.set_api_budget(api_budget_model, config)
|
143
|
+
|
140
144
|
source_streams = [
|
141
145
|
self._constructor.create_component(
|
142
146
|
DeclarativeStreamModel,
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
5
|
|
6
|
+
from datetime import datetime, timedelta
|
6
7
|
from enum import Enum
|
7
8
|
from typing import Any, Dict, List, Literal, Optional, Union
|
8
9
|
|
@@ -642,6 +643,45 @@ class OAuthAuthenticator(BaseModel):
|
|
642
643
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
643
644
|
|
644
645
|
|
646
|
+
class Rate(BaseModel):
|
647
|
+
class Config:
|
648
|
+
extra = Extra.allow
|
649
|
+
|
650
|
+
limit: int = Field(
|
651
|
+
...,
|
652
|
+
description="The maximum number of calls allowed within the interval.",
|
653
|
+
title="Limit",
|
654
|
+
)
|
655
|
+
interval: timedelta = Field(
|
656
|
+
..., description="The time interval for the rate limit.", title="Interval"
|
657
|
+
)
|
658
|
+
|
659
|
+
|
660
|
+
class HttpRequestMatcher(BaseModel):
|
661
|
+
class Config:
|
662
|
+
extra = Extra.allow
|
663
|
+
|
664
|
+
method: Optional[str] = Field(
|
665
|
+
None, description="The HTTP method to match (e.g., GET, POST).", title="Method"
|
666
|
+
)
|
667
|
+
url_base: Optional[str] = Field(
|
668
|
+
None,
|
669
|
+
description='The base URL (scheme and host, e.g. "https://api.example.com") to match.',
|
670
|
+
title="URL Base",
|
671
|
+
)
|
672
|
+
url_path_pattern: Optional[str] = Field(
|
673
|
+
None,
|
674
|
+
description="A regular expression pattern to match the URL path.",
|
675
|
+
title="URL Path Pattern",
|
676
|
+
)
|
677
|
+
params: Optional[Dict[str, Any]] = Field(
|
678
|
+
None, description="The query parameters to match.", title="Parameters"
|
679
|
+
)
|
680
|
+
headers: Optional[Dict[str, Any]] = Field(
|
681
|
+
None, description="The headers to match.", title="Headers"
|
682
|
+
)
|
683
|
+
|
684
|
+
|
645
685
|
class DpathExtractor(BaseModel):
|
646
686
|
type: Literal["DpathExtractor"]
|
647
687
|
field_path: List[str] = Field(
|
@@ -1200,17 +1240,11 @@ class InjectInto(Enum):
|
|
1200
1240
|
|
1201
1241
|
class RequestOption(BaseModel):
|
1202
1242
|
type: Literal["RequestOption"]
|
1203
|
-
field_name:
|
1204
|
-
|
1205
|
-
description="Configures which key should be used in the location that the descriptor is being injected into
|
1243
|
+
field_name: str = Field(
|
1244
|
+
...,
|
1245
|
+
description="Configures which key should be used in the location that the descriptor is being injected into",
|
1206
1246
|
examples=["segment_id"],
|
1207
|
-
title="
|
1208
|
-
)
|
1209
|
-
field_path: Optional[List[str]] = Field(
|
1210
|
-
None,
|
1211
|
-
description="Configures a path to be used for nested structures in JSON body requests (e.g. GraphQL queries)",
|
1212
|
-
examples=[["data", "viewer", "id"]],
|
1213
|
-
title="Field Path",
|
1247
|
+
title="Request Option",
|
1214
1248
|
)
|
1215
1249
|
inject_into: InjectInto = Field(
|
1216
1250
|
...,
|
@@ -1584,6 +1618,60 @@ class DatetimeBasedCursor(BaseModel):
|
|
1584
1618
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
1585
1619
|
|
1586
1620
|
|
1621
|
+
class FixedWindowCallRatePolicy(BaseModel):
|
1622
|
+
class Config:
|
1623
|
+
extra = Extra.allow
|
1624
|
+
|
1625
|
+
type: Literal["FixedWindowCallRatePolicy"]
|
1626
|
+
next_reset_ts: datetime = Field(
|
1627
|
+
...,
|
1628
|
+
description="The timestamp when the rate limit will reset.",
|
1629
|
+
title="Next Reset Timestamp",
|
1630
|
+
)
|
1631
|
+
period: timedelta = Field(
|
1632
|
+
..., description="The time interval for the rate limit window.", title="Period"
|
1633
|
+
)
|
1634
|
+
call_limit: int = Field(
|
1635
|
+
...,
|
1636
|
+
description="The maximum number of calls allowed within the period.",
|
1637
|
+
title="Call Limit",
|
1638
|
+
)
|
1639
|
+
matchers: List[HttpRequestMatcher] = Field(
|
1640
|
+
...,
|
1641
|
+
description="List of matchers that define which requests this policy applies to.",
|
1642
|
+
title="Matchers",
|
1643
|
+
)
|
1644
|
+
|
1645
|
+
|
1646
|
+
class MovingWindowCallRatePolicy(BaseModel):
|
1647
|
+
class Config:
|
1648
|
+
extra = Extra.allow
|
1649
|
+
|
1650
|
+
type: Literal["MovingWindowCallRatePolicy"]
|
1651
|
+
rates: List[Rate] = Field(
|
1652
|
+
...,
|
1653
|
+
description="List of rates that define the call limits for different time intervals.",
|
1654
|
+
title="Rates",
|
1655
|
+
)
|
1656
|
+
matchers: List[HttpRequestMatcher] = Field(
|
1657
|
+
...,
|
1658
|
+
description="List of matchers that define which requests this policy applies to.",
|
1659
|
+
title="Matchers",
|
1660
|
+
)
|
1661
|
+
|
1662
|
+
|
1663
|
+
class UnlimitedCallRatePolicy(BaseModel):
|
1664
|
+
class Config:
|
1665
|
+
extra = Extra.allow
|
1666
|
+
|
1667
|
+
type: Literal["UnlimitedCallRatePolicy"]
|
1668
|
+
matchers: List[HttpRequestMatcher] = Field(
|
1669
|
+
...,
|
1670
|
+
description="List of matchers that define which requests this policy applies to.",
|
1671
|
+
title="Matchers",
|
1672
|
+
)
|
1673
|
+
|
1674
|
+
|
1587
1675
|
class DefaultErrorHandler(BaseModel):
|
1588
1676
|
type: Literal["DefaultErrorHandler"]
|
1589
1677
|
backoff_strategies: Optional[
|
@@ -1715,6 +1803,67 @@ class CompositeErrorHandler(BaseModel):
|
|
1715
1803
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
1716
1804
|
|
1717
1805
|
|
1806
|
+
class APIBudget(BaseModel):
|
1807
|
+
class Config:
|
1808
|
+
extra = Extra.allow
|
1809
|
+
|
1810
|
+
type: Literal["APIBudget"]
|
1811
|
+
policies: List[
|
1812
|
+
Union[
|
1813
|
+
FixedWindowCallRatePolicy,
|
1814
|
+
MovingWindowCallRatePolicy,
|
1815
|
+
UnlimitedCallRatePolicy,
|
1816
|
+
]
|
1817
|
+
] = Field(
|
1818
|
+
...,
|
1819
|
+
description="List of call rate policies that define how many calls are allowed.",
|
1820
|
+
title="Policies",
|
1821
|
+
)
|
1822
|
+
maximum_attempts_to_acquire: Optional[int] = Field(
|
1823
|
+
100000,
|
1824
|
+
description="The maximum number of attempts to acquire a call before giving up.",
|
1825
|
+
title="Maximum Attempts to Acquire",
|
1826
|
+
)
|
1827
|
+
|
1828
|
+
|
1829
|
+
class HTTPAPIBudget(BaseModel):
|
1830
|
+
class Config:
|
1831
|
+
extra = Extra.allow
|
1832
|
+
|
1833
|
+
type: Literal["HTTPAPIBudget"]
|
1834
|
+
policies: List[
|
1835
|
+
Union[
|
1836
|
+
FixedWindowCallRatePolicy,
|
1837
|
+
MovingWindowCallRatePolicy,
|
1838
|
+
UnlimitedCallRatePolicy,
|
1839
|
+
]
|
1840
|
+
] = Field(
|
1841
|
+
...,
|
1842
|
+
description="List of call rate policies that define how many calls are allowed.",
|
1843
|
+
title="Policies",
|
1844
|
+
)
|
1845
|
+
ratelimit_reset_header: Optional[str] = Field(
|
1846
|
+
"ratelimit-reset",
|
1847
|
+
description="The HTTP response header name that indicates when the rate limit resets.",
|
1848
|
+
title="Rate Limit Reset Header",
|
1849
|
+
)
|
1850
|
+
ratelimit_remaining_header: Optional[str] = Field(
|
1851
|
+
"ratelimit-remaining",
|
1852
|
+
description="The HTTP response header name that indicates the number of remaining allowed calls.",
|
1853
|
+
title="Rate Limit Remaining Header",
|
1854
|
+
)
|
1855
|
+
status_codes_for_ratelimit_hit: Optional[List[int]] = Field(
|
1856
|
+
[429],
|
1857
|
+
description="List of HTTP status codes that indicate a rate limit has been hit.",
|
1858
|
+
title="Status Codes for Rate Limit Hit",
|
1859
|
+
)
|
1860
|
+
maximum_attempts_to_acquire: Optional[int] = Field(
|
1861
|
+
100000,
|
1862
|
+
description="The maximum number of attempts to acquire a call before giving up.",
|
1863
|
+
title="Maximum Attempts to Acquire",
|
1864
|
+
)
|
1865
|
+
|
1866
|
+
|
1718
1867
|
class ZipfileDecoder(BaseModel):
|
1719
1868
|
class Config:
|
1720
1869
|
extra = Extra.allow
|
@@ -1748,6 +1897,11 @@ class DeclarativeSource1(BaseModel):
|
|
1748
1897
|
definitions: Optional[Dict[str, Any]] = None
|
1749
1898
|
spec: Optional[Spec] = None
|
1750
1899
|
concurrency_level: Optional[ConcurrencyLevel] = None
|
1900
|
+
api_budget: Optional[Union[APIBudget, HTTPAPIBudget]] = Field(
|
1901
|
+
None,
|
1902
|
+
description="Defines how many requests can be made to the API in a given time frame. This field accepts either a generic APIBudget or an HTTP-specific configuration (HTTPAPIBudget) to be applied across all streams.",
|
1903
|
+
title="API Budget",
|
1904
|
+
)
|
1751
1905
|
metadata: Optional[Dict[str, Any]] = Field(
|
1752
1906
|
None,
|
1753
1907
|
description="For internal Airbyte use only - DO NOT modify manually. Used by consumers of declarative manifests for storing related metadata.",
|
@@ -1774,6 +1928,11 @@ class DeclarativeSource2(BaseModel):
|
|
1774
1928
|
definitions: Optional[Dict[str, Any]] = None
|
1775
1929
|
spec: Optional[Spec] = None
|
1776
1930
|
concurrency_level: Optional[ConcurrencyLevel] = None
|
1931
|
+
api_budget: Optional[Union[APIBudget, HTTPAPIBudget]] = Field(
|
1932
|
+
None,
|
1933
|
+
description="Defines how many requests can be made to the API in a given time frame. This field accepts either a generic APIBudget or an HTTP-specific configuration (HTTPAPIBudget) to be applied across all streams.",
|
1934
|
+
title="API Budget",
|
1935
|
+
)
|
1777
1936
|
metadata: Optional[Dict[str, Any]] = Field(
|
1778
1937
|
None,
|
1779
1938
|
description="For internal Airbyte use only - DO NOT modify manually. Used by consumers of declarative manifests for storing related metadata.",
|