Skip to content

Commit 665dc1f

Browse files
lazebnyioctavia-squidington-iii
andauthored
feat(low-code cdk): add interpolation for limit field in Rate (#353)
Co-authored-by: octavia-squidington-iii <[email protected]>
1 parent ef0ca58 commit 665dc1f

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,11 @@ definitions:
14901490
limit:
14911491
title: Limit
14921492
description: The maximum number of calls allowed within the interval.
1493-
type: integer
1493+
anyOf:
1494+
- type: integer
1495+
- type: string
1496+
interpolation_context:
1497+
- config
14941498
interval:
14951499
title: Interval
14961500
description: The time interval for the rate limit.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ class Rate(BaseModel):
646646
class Config:
647647
extra = Extra.allow
648648

649-
limit: int = Field(
649+
limit: Union[int, str] = Field(
650650
...,
651651
description="The maximum number of calls allowed within the interval.",
652652
title="Limit",

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3024,8 +3024,9 @@ def create_unlimited_call_rate_policy(
30243024
)
30253025

30263026
def create_rate(self, model: RateModel, config: Config, **kwargs: Any) -> Rate:
3027+
interpolated_limit = InterpolatedString.create(str(model.limit), parameters={})
30273028
return Rate(
3028-
limit=model.limit,
3029+
limit=int(interpolated_limit.eval(config=config)),
30293030
interval=parse_duration(model.interval),
30303031
)
30313032

unit_tests/sources/declarative/requesters/test_http_requester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def test_backoff_strategy_from_manifest_is_respected(http_requester_factory: Any
946946
)
947947

948948

949-
def test_http_requester_with_mock_apibudget(http_requester_factory, monkeypatch):
949+
def test_http_requester_with_mock_api_budget(http_requester_factory, monkeypatch):
950950
mock_budget = MagicMock(spec=HttpAPIBudget)
951951

952952
requester = http_requester_factory(

0 commit comments

Comments
 (0)