diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py index c6b966b3d704..e515d9c54cba 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py @@ -18,7 +18,7 @@ class CompositeErrorHandler(ErrorHandler): type: "CompositeErrorHandler" error_handlers: - response_filters: - - predicate: "{{ 'codase' in decoded_response }}" + - predicate: "{{ 'codase' in response }}" action: RETRY backoff_strategies: - type: "ConstantBackoffStrategy" diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py index fb8614797847..e6ff84aba6c3 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py @@ -64,7 +64,7 @@ class DefaultErrorHandler(ErrorHandler): ` error_handler: response_filters: - - predicate: "{{ 'code' in decoded_response }}" + - predicate: "{{ 'code' in response }}" action: IGNORE ` diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py index aaa325e1e307..839a3e1807f4 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py @@ -46,7 +46,7 @@ def matches(self, response: requests.Response) -> Optional[ResponseAction]: return None def _response_matches_predicate(self, response: requests.Response) -> bool: - return self._predicate and self._predicate.eval(None, decoded_response=response.json()) + return self._predicate and self._predicate.eval(None, response=response.json()) def _response_contains_error_message(self, response: requests.Response) -> bool: if not self._error_message_contains: diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/limit_paginator.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/limit_paginator.py index 4603103a41e6..cf7ddd72382c 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/limit_paginator.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/limit_paginator.py @@ -22,7 +22,7 @@ class LimitPaginator(Paginator): Examples: 1. * fetches up to 10 records at a time by setting the "limit" request param to 10 - * updates the request path with "{{ decoded_response._metadata.next }}" + * updates the request path with "{{ response._metadata.next }}" paginator: type: "LimitPaginator" limit_value: 10 @@ -33,7 +33,7 @@ class LimitPaginator(Paginator): option_type: path pagination_strategy: type: "CursorPagination" - cursor_value: "{{ decoded_response._metadata.next }}" + cursor_value: "{{ response._metadata.next }}" ` 2. diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py index a3089940f906..1a1125056d1f 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py @@ -43,10 +43,8 @@ def next_page_token(self, response: requests.Response, last_records: List[Mappin decoded_response = self._decoder.decode(response) headers = response.headers if self._stop_condition: - should_stop = self._stop_condition.eval( - self._config, decoded_response=decoded_response, headers=headers, last_records=last_records - ) + should_stop = self._stop_condition.eval(self._config, response=decoded_response, headers=headers, last_records=last_records) if should_stop: return None - token = self._cursor_value.eval(config=self._config, last_records=last_records, decoded_response=self._decoder.decode(response)) + token = self._cursor_value.eval(config=self._config, last_records=last_records, response=decoded_response) return token if token else None diff --git a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py index e15d945e3542..1ae8ee880b65 100644 --- a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py +++ b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/error_handlers/test_default_error_handler.py @@ -86,7 +86,7 @@ ( "test_403_with_predicate", HTTPStatus.FORBIDDEN, - HttpResponseFilter(action=ResponseAction.RETRY, predicate="{{ 'code' in decoded_response }}"), + HttpResponseFilter(action=ResponseAction.RETRY, predicate="{{ 'code' in response }}"), None, {}, ResponseStatus.retry(10), @@ -95,7 +95,7 @@ ( "test_403_with_predicate", HTTPStatus.FORBIDDEN, - HttpResponseFilter(action=ResponseAction.RETRY, predicate="{{ 'some_absent_field' in decoded_response }}"), + HttpResponseFilter(action=ResponseAction.RETRY, predicate="{{ 'some_absent_field' in response }}"), None, {}, response_status.FAIL, diff --git a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py index 507e2b3391ca..73e1f0f5c36c 100644 --- a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py +++ b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py @@ -17,8 +17,8 @@ ("test_static_token", "token", None, "token"), ("test_token_from_config", "{{ config.config_key }}", None, "config_value"), ("test_token_from_last_record", "{{ last_records[-1].id }}", None, 1), - ("test_token_from_decoded_response", "{{ decoded_response._metadata.content }}", None, "content_value"), - ("test_token_not_found", "{{ decoded_response.invalid_key }}", None, None), + ("test_token_from_response", "{{ response._metadata.content }}", None, "content_value"), + ("test_token_not_found", "{{ response.invalid_key }}", None, None), ("test_static_token_with_stop_condition_false", "token", InterpolatedBoolean("{{False}}"), "token"), ("test_static_token_with_stop_condition_true", "token", InterpolatedBoolean("{{True}}"), None), ], diff --git a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_limit_paginator.py b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_limit_paginator.py index 3323db48337a..585da5eccd94 100644 --- a/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_limit_paginator.py +++ b/airbyte-cdk/python/unit_tests/sources/declarative/requesters/paginators/test_limit_paginator.py @@ -102,7 +102,7 @@ def test_limit_paginator( expected_next_page_token, ): limit_request_option = RequestOption(inject_into=RequestOptionType.request_parameter, field_name="limit") - cursor_value = "{{ decoded_response.next }}" + cursor_value = "{{ response.next }}" url_base = "https://airbyte.io" config = {} strategy = CursorPaginationStrategy(cursor_value, stop_condition=stop_condition, decoder=JsonDecoder(), config=config) @@ -130,7 +130,7 @@ def test_limit_paginator( def test_limit_cannot_be_set_in_path(): limit_request_option = RequestOption(inject_into=RequestOptionType.path) page_token_request_option = RequestOption(inject_into=RequestOptionType.request_parameter, field_name="offset") - cursor_value = "{{ decoded_response.next }}" + cursor_value = "{{ response.next }}" url_base = "https://airbyte.io" config = {} strategy = CursorPaginationStrategy(cursor_value, config) diff --git a/airbyte-cdk/python/unit_tests/sources/declarative/test_factory.py b/airbyte-cdk/python/unit_tests/sources/declarative/test_factory.py index a0dab7405294..7a7a23b8540a 100644 --- a/airbyte-cdk/python/unit_tests/sources/declarative/test_factory.py +++ b/airbyte-cdk/python/unit_tests/sources/declarative/test_factory.py @@ -159,7 +159,7 @@ def test_full_config(): inject_into: path pagination_strategy: type: "CursorPagination" - cursor_value: "{{ decoded_response._metadata.next }}" + cursor_value: "{{ response._metadata.next }}" url_base: "https://api.sendgrid.com/v3/" next_page_url_from_token_partial: class_name: "airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString" @@ -305,7 +305,7 @@ def test_create_composite_error_handler(): type: "CompositeErrorHandler" error_handlers: - response_filters: - - predicate: "{{ 'code' in decoded_response }}" + - predicate: "{{ 'code' in response }}" action: RETRY - response_filters: - http_codes: [ 403 ] @@ -316,7 +316,7 @@ def test_create_composite_error_handler(): assert len(component._error_handlers) == 2 assert isinstance(component._error_handlers[0], DefaultErrorHandler) assert isinstance(component._error_handlers[0]._response_filters[0], HttpResponseFilter) - assert component._error_handlers[0]._response_filters[0]._predicate._condition == "{{ 'code' in decoded_response }}" + assert component._error_handlers[0]._response_filters[0]._predicate._condition == "{{ 'code' in response }}" assert component._error_handlers[1]._response_filters[0]._http_codes == [403] assert isinstance(component, CompositeErrorHandler) @@ -342,7 +342,7 @@ def test_config_with_defaults(): inject_into: path pagination_strategy: type: "CursorPagination" - cursor_value: "{{ decoded_response._metadata.next }}" + cursor_value: "{{ response._metadata.next }}" requester: path: "/v3/marketing/lists" authenticator: @@ -388,7 +388,7 @@ def test_create_limit_paginator(): inject_into: path pagination_strategy: type: "CursorPagination" - cursor_value: "{{ decoded_response._metadata.next }}" + cursor_value: "{{ response._metadata.next }}" """ config = parser.parse(content)