Provider protocols
Provider Protocols¶
ProviderBackend¶
All providers must implement the ProviderBackend protocol.
from pathlib import Path
from typing import Protocol
from pdf_remote_converter.providers.models import ConversionResult
class ProviderBackend(Protocol):
name: str
supported_formats: set[str]
monthly_quota: int
quota_remaining: int
def convert(self, input_path: Path, output_path: Path) -> ConversionResult:
"""
Convert a document to PDF.
Args:
input_path: Path to the input file.
output_path: Path to the output PDF file.
Returns:
ConversionResult: Result of the conversion.
Raises:
QuotaExceededError: If quota is exceeded.
RateLimitError: If rate limited.
ProviderUnavailableError: If provider is unavailable.
AuthenticationError: If authentication fails.
"""
...
def is_healthy(self) -> bool:
"""
Check if the provider is healthy.
Returns:
bool: True if healthy, False otherwise.
"""
...
ConversionResult¶
from dataclasses import dataclass
@dataclass
class ConversionResult:
provider: str
success: bool
file_size: int
details: str | None = None
Provider Implementations¶
| Provider | File | Class |
|---|---|---|
| CloudConvert | providers/cloudconvert.py |
CloudConvertProvider |
| Adobe | providers/adobe.py |
AdobeProvider |
| ApyHub | providers/apyhub.py |
ApyHubProvider |
| Google Drive | providers/google_drive.py |
GoogleDriveProvider |
| Zamzar | providers/zamzar.py |
ZamzarProvider |
Related¶
- High-Level API - Main
Converterclass. - Adding a New Provider - How to implement the protocol.
- Architecture - Provider architecture overview.