From 7bbae55e448786da6ec690ae2a91f9a2ec45f3fc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 26 Mar 2023 03:46:06 +0200 Subject: [PATCH] `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. --- platypush/entities/__init__.py | 10 ++--- .../{_managers => managers}/__init__.py | 0 platypush/entities/managers/cloud.py | 41 +++++++++++++++++++ .../{_managers => managers}/lights.py | 0 .../{_managers => managers}/sensors.py | 0 .../{_managers => managers}/switches.py | 0 6 files changed, 46 insertions(+), 5 deletions(-) rename platypush/entities/{_managers => managers}/__init__.py (100%) create mode 100644 platypush/entities/managers/cloud.py rename platypush/entities/{_managers => managers}/lights.py (100%) rename platypush/entities/{_managers => managers}/sensors.py (100%) rename platypush/entities/{_managers => managers}/switches.py (100%) diff --git a/platypush/entities/__init__.py b/platypush/entities/__init__.py index 5d29d40d..4f5d46f7 100644 --- a/platypush/entities/__init__.py +++ b/platypush/entities/__init__.py @@ -11,17 +11,17 @@ from ._base import ( init_entities_db, ) from ._engine import EntitiesEngine -from ._managers import ( +from .managers import ( EntityManager, get_plugin_entity_registry, register_entity_manager, ) -from ._managers.lights import LightEntityManager -from ._managers.sensors import SensorEntityManager -from ._managers.switches import ( - SwitchEntityManager, +from .managers.lights import LightEntityManager +from .managers.sensors import SensorEntityManager +from .managers.switches import ( DimmerEntityManager, EnumSwitchEntityManager, + SwitchEntityManager, ) _engine: Optional[EntitiesEngine] = None diff --git a/platypush/entities/_managers/__init__.py b/platypush/entities/managers/__init__.py similarity index 100% rename from platypush/entities/_managers/__init__.py rename to platypush/entities/managers/__init__.py diff --git a/platypush/entities/managers/cloud.py b/platypush/entities/managers/cloud.py new file mode 100644 index 00000000..4fa947b0 --- /dev/null +++ b/platypush/entities/managers/cloud.py @@ -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() diff --git a/platypush/entities/_managers/lights.py b/platypush/entities/managers/lights.py similarity index 100% rename from platypush/entities/_managers/lights.py rename to platypush/entities/managers/lights.py diff --git a/platypush/entities/_managers/sensors.py b/platypush/entities/managers/sensors.py similarity index 100% rename from platypush/entities/_managers/sensors.py rename to platypush/entities/managers/sensors.py diff --git a/platypush/entities/_managers/switches.py b/platypush/entities/managers/switches.py similarity index 100% rename from platypush/entities/_managers/switches.py rename to platypush/entities/managers/switches.py