* Revert Sendgrid and Sentry sources to use python CDK instead of low-code * keep yaml configs for future reference * don't revert additional properties and update changelog w/ PR number * consistent time formatting in Messages stream and fix the unit test * auto-bump connector version [ci skip] * auto-bump connector version [ci skip] Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
45 lines
1.4 KiB
Python
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),
|
|
]
|