2022-09-11 10:08:50 +02:00
|
|
|
from abc import abstractmethod
|
2025-04-13 21:16:17 +02:00
|
|
|
from typing import AsyncGenerator, TypeAlias
|
2022-09-11 10:08:50 +02:00
|
|
|
|
2025-03-19 16:13:50 +01:00
|
|
|
from app.api.error_report.report import Report
|
2025-04-13 21:16:17 +02:00
|
|
|
from app.apps.models import (
|
|
|
|
|
AppId,
|
|
|
|
|
AppManageTaskMessage,
|
|
|
|
|
AppStatus,
|
|
|
|
|
AppStatusQueryResult,
|
|
|
|
|
AppUninstallInput,
|
|
|
|
|
)
|
2025-03-19 16:13:50 +01:00
|
|
|
from app.external.result_type.src.result import Result
|
|
|
|
|
|
2025-04-13 21:16:17 +02:00
|
|
|
AppManageResult: TypeAlias = AsyncGenerator[Result[AppManageTaskMessage, Report], None]
|
|
|
|
|
|
2022-09-11 10:08:50 +02:00
|
|
|
|
2022-09-10 22:14:37 +02:00
|
|
|
class AppsBase:
|
2022-09-11 10:08:50 +02:00
|
|
|
@abstractmethod
|
2025-03-19 16:13:50 +01:00
|
|
|
async def get_app_status_single(self, app_id: str) -> Result[AppStatus, Report]:
|
2022-09-10 22:14:37 +02:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2022-09-11 10:08:50 +02:00
|
|
|
@abstractmethod
|
2025-03-19 16:13:50 +01:00
|
|
|
async def get_app_status(self) -> Result[AppStatusQueryResult, Report]:
|
2022-09-10 22:14:37 +02:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2024-02-18 12:10:35 +01:00
|
|
|
@abstractmethod
|
2025-03-19 16:13:50 +01:00
|
|
|
async def get_app_status_advanced(self, app_id: str) -> Result[AppStatus, Report]:
|
2024-02-18 12:10:35 +01:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2022-09-11 10:08:50 +02:00
|
|
|
@abstractmethod
|
2025-04-13 21:16:17 +02:00
|
|
|
def install_app(self, app_id: AppId) -> AppManageResult:
|
2022-09-10 22:14:37 +02:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2022-09-11 10:08:50 +02:00
|
|
|
@abstractmethod
|
2025-04-13 21:16:17 +02:00
|
|
|
def uninstall_app(self, input: AppUninstallInput) -> AppManageResult:
|
2022-09-10 22:14:37 +02:00
|
|
|
raise NotImplementedError()
|