ds_protocol_sftp_py_lib.linked_service.sftp¶
File: sftp.py Region: src/ds_protocol_sftp_py_lib/linked_service/sftp
SFTP Linked Service implementation.
This module defines the SftpLinkedService class, which implements a linked service for SFTP connections, including connection management, error handling, and integration with the SFTP client.
Example
>>> import uuid
>>> from ds_protocol_sftp_py_lib.linked_service import SftpLinkedService, SftpLinkedServiceSettings
>>> linked_service = SftpLinkedService(
... id=uuid.uuid4(),
... name="example::linked_service",
... version="1.0.0",
... settings=SftpLinkedServiceSettings(
... host="sftp.example.com",
... username="user",
... password="password123",
... private_key=None,
... passphrase=None,
... timeout=30.0,
... host_key_fingerprint="AbCdEfGhIjKlMnOpQrStUvWxYz0123456789abcdEf==",
... host_key_validation=True,
... port=22,
... ),
... )
>>> linked_service.connect()
Attributes¶
Classes¶
Settings for SFTP Linked Service connections. |
|
SFTP Linked Service implementation. |
Module Contents¶
- class ds_protocol_sftp_py_lib.linked_service.sftp.SftpLinkedServiceSettings[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.linked_service.LinkedServiceSettingsSettings for SFTP Linked Service connections.
- host¶
SFTP server hostname.
- Type:
str
- username¶
Username for authentication.
- Type:
str
- password¶
Password for authentication.
- Type:
str | None
- private_key¶
Private key for authentication.
- Type:
str | None
- passphrase¶
Passphrase for private key.
- Type:
str | None
- timeout¶
Connection timeout in seconds.
- Type:
float | None
- host_key_fingerprint¶
Expected host key fingerprint.
- Type:
str | None
- host_key_validation¶
Whether to validate host key.
- Type:
bool
- port¶
SFTP server port.
- Type:
int
- host: str¶
Hostname or IP address of the SFTP server.
- username: str¶
Username for authentication.
- password: str | None = None¶
Password for authentication.
- private_key: str | None = None¶
Private key for authentication.
- passphrase: str | None = None¶
Passphrase for private key.
- timeout: float | None = None¶
Connection timeout in seconds.
- host_key_fingerprint: str | None = None¶
Expected host key fingerprint (base64-encoded MD5, as produced by Paramiko’s get_fingerprint(); e.g., ‘AbCdEfGhIjKlMnOpQrStUvWxYz0123456789abcdEf==’).
- host_key_validation: bool = True¶
Whether to validate host key.
- port: int = 22¶
SFTP server port.
- ds_protocol_sftp_py_lib.linked_service.sftp.SftpLinkedServiceSettingsType¶
- class ds_protocol_sftp_py_lib.linked_service.sftp.SftpLinkedService[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.linked_service.LinkedService[SftpLinkedServiceSettingsType],Generic[SftpLinkedServiceSettingsType]SFTP Linked Service implementation.
- settings¶
Linked service settings.
- _connection¶
Underlying SFTP client connection.
- Type:
SFTPClient | None
- settings: SftpLinkedServiceSettingsType¶
- _sftp: ds_protocol_sftp_py_lib.utils.sftp.provider.Sftp | None = None¶
- property type: ds_protocol_sftp_py_lib.enums.ResourceType¶
Get the type of linked service.
- Returns:
The type of the linked service.
- Return type:
- property connection: ds_protocol_sftp_py_lib.utils.sftp.provider.Sftp¶
Get the SFTP client connection.
- Returns:
The active SFTP client connection.
- Return type:
- Raises:
ConnectionError – If the connection is not initialized.
- _init_sftp() ds_protocol_sftp_py_lib.utils.sftp.provider.Sftp[source]¶
Initialize the Sftp client.
- Returns:
An initialized Sftp provider instance.
- Return type:
- connect() None[source]¶
Initialize the Sftp client instance if not already initialized.
- Raises:
ConnectionError – If connection fails.
AuthenticationError – If authentication fails.