music-assistant-server

1.7 KBPY
__init__.py
1.7 KB51 lines • python
1"""Server specific/only models."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING, Protocol
6
7from .metadata_provider import MetadataProvider
8from .music_provider import MusicProvider
9from .player_provider import PlayerProvider
10from .plugin import PluginProvider
11
12if TYPE_CHECKING:
13    from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig
14    from music_assistant_models.enums import ProviderFeature
15    from music_assistant_models.provider import ProviderManifest
16
17    from music_assistant.mass import MusicAssistant
18
19
20ProviderInstanceType = MetadataProvider | MusicProvider | PlayerProvider | PluginProvider
21
22
23class ProviderModuleType(Protocol):
24    """Model for a provider module to support type hints."""
25
26    """Return the (base) features supported by this Provider."""
27    SUPPORTED_FEATURES: set[ProviderFeature]
28
29    @staticmethod
30    async def setup(
31        mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
32    ) -> ProviderInstanceType:
33        """Initialize provider(instance) with given configuration."""
34        raise NotImplementedError
35
36    @staticmethod
37    async def get_config_entries(
38        mass: MusicAssistant,
39        instance_id: str | None = None,
40        action: str | None = None,
41        values: dict[str, ConfigValueType] | None = None,
42    ) -> tuple[ConfigEntry, ...]:
43        """
44        Return Config entries to setup this provider.
45
46        instance_id: id of an existing provider instance (None if new instance setup).
47        action: [optional] action key called from config entries UI.
48        values: the (intermediate) raw values for config entries sent with the action.
49        """
50        raise NotImplementedError
51