airbyte_cdk.sources.declarative.async_job.repository

 1# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
 2
 3from abc import abstractmethod
 4from typing import Any, Iterable, Mapping, Set
 5
 6from airbyte_cdk.sources.declarative.async_job.job import AsyncJob
 7from airbyte_cdk.sources.types import StreamSlice
 8
 9
10class AsyncJobRepository:
11    @abstractmethod
12    def start(self, stream_slice: StreamSlice) -> AsyncJob:
13        pass
14
15    @abstractmethod
16    def update_jobs_status(self, jobs: Set[AsyncJob]) -> None:
17        pass
18
19    @abstractmethod
20    def fetch_records(self, job: AsyncJob) -> Iterable[Mapping[str, Any]]:
21        pass
22
23    @abstractmethod
24    def abort(self, job: AsyncJob) -> None:
25        """
26        Called when we need to stop on the API side. This method can raise NotImplementedError as not all the APIs will support aborting
27        jobs.
28        """
29        raise NotImplementedError(
30            "Either the API or the AsyncJobRepository implementation do not support aborting jobs"
31        )
32
33    @abstractmethod
34    def delete(self, job: AsyncJob) -> None:
35        pass
class AsyncJobRepository:
11class AsyncJobRepository:
12    @abstractmethod
13    def start(self, stream_slice: StreamSlice) -> AsyncJob:
14        pass
15
16    @abstractmethod
17    def update_jobs_status(self, jobs: Set[AsyncJob]) -> None:
18        pass
19
20    @abstractmethod
21    def fetch_records(self, job: AsyncJob) -> Iterable[Mapping[str, Any]]:
22        pass
23
24    @abstractmethod
25    def abort(self, job: AsyncJob) -> None:
26        """
27        Called when we need to stop on the API side. This method can raise NotImplementedError as not all the APIs will support aborting
28        jobs.
29        """
30        raise NotImplementedError(
31            "Either the API or the AsyncJobRepository implementation do not support aborting jobs"
32        )
33
34    @abstractmethod
35    def delete(self, job: AsyncJob) -> None:
36        pass
@abstractmethod
def start( self, stream_slice: airbyte_cdk.StreamSlice) -> airbyte_cdk.sources.declarative.async_job.job.AsyncJob:
12    @abstractmethod
13    def start(self, stream_slice: StreamSlice) -> AsyncJob:
14        pass
@abstractmethod
def update_jobs_status( self, jobs: Set[airbyte_cdk.sources.declarative.async_job.job.AsyncJob]) -> None:
16    @abstractmethod
17    def update_jobs_status(self, jobs: Set[AsyncJob]) -> None:
18        pass
@abstractmethod
def fetch_records( self, job: airbyte_cdk.sources.declarative.async_job.job.AsyncJob) -> Iterable[Mapping[str, Any]]:
20    @abstractmethod
21    def fetch_records(self, job: AsyncJob) -> Iterable[Mapping[str, Any]]:
22        pass
@abstractmethod
def abort( self, job: airbyte_cdk.sources.declarative.async_job.job.AsyncJob) -> None:
24    @abstractmethod
25    def abort(self, job: AsyncJob) -> None:
26        """
27        Called when we need to stop on the API side. This method can raise NotImplementedError as not all the APIs will support aborting
28        jobs.
29        """
30        raise NotImplementedError(
31            "Either the API or the AsyncJobRepository implementation do not support aborting jobs"
32        )

Called when we need to stop on the API side. This method can raise NotImplementedError as not all the APIs will support aborting jobs.

@abstractmethod
def delete( self, job: airbyte_cdk.sources.declarative.async_job.job.AsyncJob) -> None:
34    @abstractmethod
35    def delete(self, job: AsyncJob) -> None:
36        pass