1
0
mirror of synced 2026-01-08 03:06:34 -05:00
Files
airbyte/airbyte-cdk/python/airbyte_cdk/sources/declarative/retrievers/retriever.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

39 lines
1.2 KiB
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
from abc import ABC, abstractmethod
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional
from airbyte_cdk.models import SyncMode
class Retriever(ABC):
@abstractmethod
def read_records(
self,
sync_mode: SyncMode,
cursor_field: List[str] = None,
stream_slice: Mapping[str, Any] = None,
stream_state: Mapping[str, Any] = None,
) -> Iterable[Mapping[str, Any]]:
pass
@abstractmethod
def stream_slices(self, *, sync_mode: SyncMode, stream_state: Mapping[str, Any] = None) -> Iterable[Optional[Mapping[str, Any]]]:
pass
@abstractmethod
def get_state(self) -> MutableMapping[str, Any]:
"""State getter, should return state in form that can serialized to a string and send to the output
as a STATE AirbyteMessage.
A good example of a state is a cursor_value:
{
self.cursor_field: "cursor_value"
}
State should try to be as small as possible but at the same time descriptive enough to restore
syncing process from the point where it stopped.
"""