-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[source-recharge] - Migrate to CDK v3.7.0 (#42076)
- Loading branch information
1 parent
fba41d3
commit 36ba028
Showing
7 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...egrations/connectors/source-recharge/source_recharge/components/recharge_error_handler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import logging | ||
from typing import Optional, Union | ||
|
||
from airbyte_cdk.sources.streams.http.error_handlers import HttpStatusErrorHandler | ||
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ErrorResolution, FailureType, ResponseAction | ||
from requests import Response | ||
|
||
|
||
class RechargeErrorHandler(HttpStatusErrorHandler): | ||
def __init__(self, logger: logging.Logger) -> None: | ||
self.logger = logger | ||
super().__init__(logger=logger) | ||
|
||
def interpret_response(self, response_or_exception: Optional[Union[Response, Exception]] = None) -> ErrorResolution: | ||
|
||
if isinstance(response_or_exception, Response): | ||
content_length = int(response_or_exception.headers.get("Content-Length", 0)) | ||
incomplete_data_response = response_or_exception.status_code == 200 and content_length > len(response_or_exception.content) | ||
if incomplete_data_response: | ||
return ErrorResolution( | ||
response_action=ResponseAction.RETRY, | ||
failure_type=FailureType.transient_error, | ||
error_message="The response is incomplete, retrying the request.", | ||
) | ||
|
||
return super().interpret_response(response_or_exception) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters