1
0
mirror of synced 2026-01-27 16:02:00 -05:00
Files
airbyte/airbyte-integrations/connectors/source-sentry/source_sentry/source.py
Marcos Marx dca2256a7c Bump 2022 license version (#13233)
* Bump year in license short to 2022

* remove protocol from cdk
2022-05-26 15:00:42 -03:00

45 lines
1.4 KiB
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
from typing import Any, List, Mapping, Tuple
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator
from .streams import Events, Issues, ProjectDetail, Projects
# Source
class SourceSentry(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, Any]:
try:
projects_stream = Projects(
authenticator=TokenAuthenticator(token=config["auth_token"]),
hostname=config.get("hostname"),
)
next(projects_stream.read_records(sync_mode=SyncMode.full_refresh))
return True, None
except Exception as e:
return False, e
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
stream_args = {
"authenticator": TokenAuthenticator(token=config["auth_token"]),
"hostname": config.get("hostname"),
}
project_stream_args = {
**stream_args,
"organization": config["organization"],
"project": config["project"],
}
return [
Events(**project_stream_args),
Issues(**project_stream_args),
ProjectDetail(**project_stream_args),
Projects(**stream_args),
]