airbyte_cdk.sources.file_based.remote_file

 1#
 2# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
 3#
 4from abc import ABC, abstractmethod
 5from datetime import datetime
 6from typing import Optional
 7
 8from pydantic.v1 import BaseModel
 9
10
11class RemoteFile(BaseModel):
12    """
13    A file in a file-based stream.
14    """
15
16    uri: str
17    last_modified: datetime
18    mime_type: Optional[str] = None
19
20
21class UploadableRemoteFile(RemoteFile, ABC):
22    """
23    A file in a file-based stream that supports uploading(file transferring).
24    """
25
26    id: Optional[str] = None
27    created_at: Optional[str] = None
28    updated_at: Optional[str] = None
29
30    @property
31    @abstractmethod
32    def size(self) -> int:
33        """
34        Returns the file size in bytes.
35        """
36        ...
37
38    @abstractmethod
39    def download_to_local_directory(self, local_file_path: str) -> None:
40        """
41        Download the file from remote source to local storage.
42        """
43        ...
44
45    @property
46    def source_file_relative_path(self) -> str:
47        """
48        Returns the relative path of the source file.
49        """
50        return self.uri
51
52    @property
53    def file_uri_for_logging(self) -> str:
54        """
55        Returns the URI for the file being logged.
56        """
57        return self.uri
class RemoteFile(pydantic.v1.main.BaseModel):
12class RemoteFile(BaseModel):
13    """
14    A file in a file-based stream.
15    """
16
17    uri: str
18    last_modified: datetime
19    mime_type: Optional[str] = None

A file in a file-based stream.

uri: str
last_modified: datetime.datetime
mime_type: Optional[str]
class UploadableRemoteFile(RemoteFile, abc.ABC):
22class UploadableRemoteFile(RemoteFile, ABC):
23    """
24    A file in a file-based stream that supports uploading(file transferring).
25    """
26
27    id: Optional[str] = None
28    created_at: Optional[str] = None
29    updated_at: Optional[str] = None
30
31    @property
32    @abstractmethod
33    def size(self) -> int:
34        """
35        Returns the file size in bytes.
36        """
37        ...
38
39    @abstractmethod
40    def download_to_local_directory(self, local_file_path: str) -> None:
41        """
42        Download the file from remote source to local storage.
43        """
44        ...
45
46    @property
47    def source_file_relative_path(self) -> str:
48        """
49        Returns the relative path of the source file.
50        """
51        return self.uri
52
53    @property
54    def file_uri_for_logging(self) -> str:
55        """
56        Returns the URI for the file being logged.
57        """
58        return self.uri

A file in a file-based stream that supports uploading(file transferring).

id: Optional[str]
created_at: Optional[str]
updated_at: Optional[str]
size: int
31    @property
32    @abstractmethod
33    def size(self) -> int:
34        """
35        Returns the file size in bytes.
36        """
37        ...

Returns the file size in bytes.

@abstractmethod
def download_to_local_directory(self, local_file_path: str) -> None:
39    @abstractmethod
40    def download_to_local_directory(self, local_file_path: str) -> None:
41        """
42        Download the file from remote source to local storage.
43        """
44        ...

Download the file from remote source to local storage.

source_file_relative_path: str
46    @property
47    def source_file_relative_path(self) -> str:
48        """
49        Returns the relative path of the source file.
50        """
51        return self.uri

Returns the relative path of the source file.

file_uri_for_logging: str
53    @property
54    def file_uri_for_logging(self) -> str:
55        """
56        Returns the URI for the file being logged.
57        """
58        return self.uri

Returns the URI for the file being logged.