1
0
mirror of synced 2026-01-02 12:02:47 -05:00
Files
airbyte/airbyte-integrations/connectors/source-sentry/source_sentry/source.py
Arsen Losenko a354378811 Source Sentry: Change stream that is used during check (#25759)
* Source Sentry: Change stream that is used during check

* Update changelog

* Update metadata.yaml

* Remove import

* auto-bump connector version

---------

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
2023-05-02 15:12:20 +03:00

48 lines
1.5 KiB
Python

#
# Copyright (c) 2023 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, Releases
# Source
class SourceSentry(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, Any]:
try:
stream = ProjectDetail(
authenticator=TokenAuthenticator(token=config["auth_token"]),
hostname=config.get("hostname"),
organization=config.get("organization"),
project=config.get("project"),
)
next(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),
Releases(**project_stream_args),
]