-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdeclarative_source.py
45 lines (38 loc) · 1.72 KB
/
declarative_source.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
import logging
from abc import abstractmethod
from typing import Any, List, Mapping, Tuple
from airbyte_cdk.models import (
AirbyteLogMessage,
)
from airbyte_cdk.sources.abstract_source import AbstractSource
from airbyte_cdk.sources.declarative.checks.connection_checker import ConnectionChecker
class DeclarativeSource(AbstractSource):
"""
Base class for declarative Source. Concrete sources need to define the connection_checker to use
"""
@property
@abstractmethod
def connection_checker(self) -> ConnectionChecker:
"""Returns the ConnectionChecker to use for the `check` operation"""
def check_connection(
self, logger: logging.Logger, config: Mapping[str, Any]
) -> Tuple[bool, Any]:
"""
:param logger: The source logger
:param config: The user-provided configuration as specified by the source's spec.
This usually contains information required to check connection e.g. tokens, secrets and keys etc.
:return: A tuple of (boolean, error). If boolean is true, then the connection check is successful
and we can connect to the underlying data source using the provided configuration.
Otherwise, the input config cannot be used to connect to the underlying data source,
and the "error" object should describe what went wrong.
The error object will be cast to string to display the problem to the user.
"""
return self.connection_checker.check_connection(self, logger, config)
def deprecation_warnings(self) -> List[AirbyteLogMessage]:
"""
Returns a list of deprecation warnings for the source.
"""
return []