Skip to content

Commit

Permalink
Source Stripe: ref
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
  • Loading branch information
artem1205 committed Sep 10, 2024
1 parent 588344b commit 19e694d
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
import os
import traceback
from datetime import datetime, timedelta, timezone
from typing import Any, List, Mapping, MutableMapping, Optional, Tuple

Expand All @@ -21,7 +20,6 @@
from airbyte_cdk.sources.streams.concurrent.adapters import StreamFacade
from airbyte_cdk.sources.streams.concurrent.cursor import ConcurrentCursor, CursorField, FinalStateCursor
from airbyte_cdk.sources.streams.concurrent.state_converters.datetime_stream_state_converter import EpochValueConcurrentStreamStateConverter
from airbyte_cdk.sources.streams.http.availability_strategy import HttpAvailabilityStrategy
from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
from airbyte_protocol.models import SyncMode
Expand Down Expand Up @@ -110,14 +108,12 @@ def validate_and_fill_with_defaults(config: MutableMapping[str, Any]) -> Mutable
def check_connection(self, logger: logging.Logger, config: MutableMapping[str, Any]) -> Tuple[bool, Any]:
args = self._get_stream_base_args(config)
account_stream = StripeStream(name="accounts", path="accounts", use_cache=USE_CACHE, **args)
availability_strategy = HttpAvailabilityStrategy()
try:
stream_is_available, reason = availability_strategy.check_availability(account_stream, logger)
if not stream_is_available:
return False, reason
except Exception as error:
logger.error(f"Encountered an error trying to connect to stream {account_stream.name}. Error: \n {traceback.format_exc()}")
return False, f"Unable to connect to stream {account_stream.name} - {error}"
next(account_stream.read_records(sync_mode=SyncMode.full_refresh))
except AirbyteTracedException as error:
if error.failure_type == FailureType.config_error:
return False, error.message
raise error
return True, None

def _get_stream_base_args(self, config: MutableMapping[str, Any]) -> MutableMapping[str, Any]:
Expand Down

0 comments on commit 19e694d

Please sign in to comment.