"""Cloud provider abstraction for worker management.""" from dataclasses import dataclass from typing import Protocol @dataclass class Instance: id: str name: str ip: str status: str provider: str type: str class ProviderModule(Protocol): def create_instance( self: str, instance_type: str, ssh_key: str, location: str | None = None, ) -> Instance: ... def destroy_instance(self: str) -> None: ... def list_instances(self: str | None = None) -> list[Instance]: ... def get_instance(self: str) -> Instance | None: ... def wait_for_ssh(self: str, timeout: int = 300) -> bool: ... def get_provider(provider_name: str) -> ProviderModule: if provider_name == "hetzner": from materia.providers import hetzner return hetzner elif provider_name == "ovh": from materia.providers import ovh return ovh elif provider_name == "scaleway": from materia.providers import scaleway return scaleway elif provider_name == "oracle": from materia.providers import oracle return oracle else: raise ValueError(f"Unknown provider: {provider_name}")