Skip to content

Commit

Permalink
ADCM-6118: Implement Host object
Browse files Browse the repository at this point in the history
  • Loading branch information
Starovoitov committed Nov 19, 2024
1 parent 6b5c530 commit 23d4bbc
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions adcm_aio_client/core/objects/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ class ADCMEntityStatus(str, Enum):
class Bundle(Deletable, InteractiveObject): ...


class Host(Deletable, InteractiveObject): ...


class Cluster(
Deletable, WithActions, WithUpgrades, WithConfig, WithActionHostGroups, WithConfigGroups, InteractiveObject
):
Expand Down Expand Up @@ -101,10 +98,6 @@ def get_own_path(self: Self) -> Endpoint:
return ("clusters",)


class HostsInClusterNode(PaginatedAccessor[Host, None]):
class_type = Host


class Service(InteractiveChildObject[Cluster]):
@property
def id(self: Self) -> int:
Expand Down Expand Up @@ -135,13 +128,10 @@ class ComponentsNode(NonPaginatedChildAccessor[Service, Component, None]):
class_type = Component


class ConfigsNode(PaginatedChildAccessor): ...


class HostProvidersNode(PaginatedChildAccessor): ...


class Host(InteractiveChildObject):
class Host(Deletable, InteractiveChildObject):
@property
def id(self: Self) -> int:
return int(self._data["id"])
Expand All @@ -159,16 +149,10 @@ async def get_status(self: Self) -> ADCMEntityStatus:
return ADCMEntityStatus(response.as_dict()["status"])

@cached_property
def cluster(self: Self) -> ClustersNode | None:
def cluster(self: Self) -> Cluster | None:
if not self._data["cluster"]:
return None
return ClustersNode(
path=("clusters", self._data["cluster"]["id"], *self.get_own_path()), requester=self._requester
)

@cached_property
def config(self: Self) -> "ConfigsNode":
return ConfigsNode(parent=self, path=(*self.get_own_path(), "config"), requester=self._requester)
return Cluster(requester=self._requester, data=self._data["cluster"])

@cached_property
def hostprovider(self: Self) -> "HostProvidersNode":
Expand All @@ -182,3 +166,7 @@ class HostsNode(PaginatedAccessor[Host, None]):
class_type = Host

# TODO: define def __init__(self, hostprovider: Hostprovider, name: str, cluster: Cluster = None): ...


class HostsInClusterNode(PaginatedAccessor[Host, None]):
class_type = Host

0 comments on commit 23d4bbc

Please sign in to comment.