Skip to content

Commit

Permalink
ADCM-6177: Implement node for getting upgrades (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: astarovo <[email protected]>
  • Loading branch information
2 people authored and a-alferov committed Dec 9, 2024
1 parent 8bdac72 commit 82e0b1f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions adcm_aio_client/core/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from adcm_aio_client.core.actions._objects import ActionsAccessor
from adcm_aio_client.core.actions._objects import ActionsAccessor, UpgradeNode

__all__ = ["ActionsAccessor"]
__all__ = ["ActionsAccessor", "UpgradeNode"]
23 changes: 22 additions & 1 deletion adcm_aio_client/core/actions/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from adcm_aio_client.core.objects._base import InteractiveChildObject, InteractiveObject

if TYPE_CHECKING:
from adcm_aio_client.core.objects.cm import Cluster
from adcm_aio_client.core.objects.cm import Bundle, Cluster


class Action(InteractiveChildObject):
Expand Down Expand Up @@ -66,6 +66,27 @@ class ActionsAccessor(NonPaginatedChildAccessor):
class_type = Action


class Upgrade(Action):
PATH_PREFIX = "upgrades"

@property
def bundle(self: Self) -> Bundle:
from adcm_aio_client.core.objects.cm import Bundle

return Bundle(requester=self._requester, data=self._data["bundle"])

@async_cached_property # TODO: Config class
async def config(self: Self) -> ...:
return (await self._rich_data)["configuration"]

def validate(self: Self) -> bool:
return True


class UpgradeNode(NonPaginatedChildAccessor):
class_type = Upgrade


async def detect_cluster(owner: InteractiveObject) -> Cluster:
from adcm_aio_client.core.objects.cm import Cluster, Component, Host, Service

Expand Down
5 changes: 3 additions & 2 deletions adcm_aio_client/core/objects/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from asyncstdlib.functools import cached_property as async_cached_property # noqa: N813

from adcm_aio_client.core.actions import ActionsAccessor
from adcm_aio_client.core.actions import ActionsAccessor, UpgradeNode
from adcm_aio_client.core.config import ConfigHistoryNode, ObjectConfig
from adcm_aio_client.core.config._objects import ConfigOwner
from adcm_aio_client.core.objects._base import AwareOfOwnPath, MaintenanceMode, WithProtectedRequester
Expand Down Expand Up @@ -40,7 +40,8 @@ def config_history(self: Self) -> ConfigHistoryNode:

class WithUpgrades(WithProtectedRequester, AwareOfOwnPath):
@cached_property
def upgrades(self: Self) -> ...: ...
def upgrades(self: Self) -> UpgradeNode:
return UpgradeNode(parent=self, path=(*self.get_own_path(), "upgrades"), requester=self._requester)


class WithConfigGroups(WithProtectedRequester, AwareOfOwnPath):
Expand Down

0 comments on commit 82e0b1f

Please sign in to comment.