platypush.entities._managers -> platypush.entities.managers.

It's better for entity managers to be stored in their own public
package, instead of cluttering too much the namespace of their parent
package.
This commit is contained in:
Fabio Manganiello 2023-03-26 03:46:06 +02:00
parent f5d9895521
commit 7bbae55e44
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
6 changed files with 46 additions and 5 deletions

View file

@ -11,17 +11,17 @@ from ._base import (
init_entities_db, init_entities_db,
) )
from ._engine import EntitiesEngine from ._engine import EntitiesEngine
from ._managers import ( from .managers import (
EntityManager, EntityManager,
get_plugin_entity_registry, get_plugin_entity_registry,
register_entity_manager, register_entity_manager,
) )
from ._managers.lights import LightEntityManager from .managers.lights import LightEntityManager
from ._managers.sensors import SensorEntityManager from .managers.sensors import SensorEntityManager
from ._managers.switches import ( from .managers.switches import (
SwitchEntityManager,
DimmerEntityManager, DimmerEntityManager,
EnumSwitchEntityManager, EnumSwitchEntityManager,
SwitchEntityManager,
) )
_engine: Optional[EntitiesEngine] = None _engine: Optional[EntitiesEngine] = None

View file

@ -0,0 +1,41 @@
from abc import ABC, abstractmethod
from typing import Union
from uuid import UUID
from . import EntityManager
InstanceId = Union[str, int, UUID]
class CloudInstanceEntityManager(EntityManager, ABC):
"""
Base class for integrations that support cloud instances (like Linode or
AWS).
"""
@abstractmethod
def reboot(self, instance: InstanceId, **_):
"""
Reboot an instance.
:param instance: ID or name of the instance to be rebooted.
"""
raise NotImplementedError()
@abstractmethod
def boot(self, instance: InstanceId, **_):
"""
Boot an instance.
:param instance: ID or name of the instance to be rebooted.
"""
raise NotImplementedError()
@abstractmethod
def shutdown(self, instance: InstanceId, **_):
"""
Shutdown an instance.
:param instance: ID or name of the instance to be rebooted.
"""
raise NotImplementedError()