Skip to content

Commit

Permalink
ADCM-6119: Implement HostProvider object (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: astarovo <[email protected]>
  • Loading branch information
Starovoitov and astarovo authored Nov 20, 2024
1 parent 35f22f4 commit a2efbba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion adcm_aio_client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from functools import cached_property
from typing import Self

from adcm_aio_client.core.objects.cm import ClustersNode, HostsNode
from adcm_aio_client.core.objects.cm import ClustersNode, HostProvidersNode, HostsNode
from adcm_aio_client.core.requesters import Requester
from adcm_aio_client.core.types import AuthToken, Cert, Credentials, Verify

Expand All @@ -30,6 +30,10 @@ def clusters(self: Self) -> ClustersNode:
def hosts(self: Self) -> HostsNode:
return HostsNode(path=(), requester=self._requester)

@cached_property
def hostproviders(self: Self) -> HostProvidersNode:
return HostProvidersNode(path=(), requester=self._requester)


async def build_client(
url: str | list[str],
Expand Down
21 changes: 18 additions & 3 deletions adcm_aio_client/core/objects/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,26 @@ class ComponentsNode(NonPaginatedChildAccessor[Service, Component, None]):

class HostProvider(Deletable, WithActions, WithUpgrades, WithConfig, RootInteractiveObject):
PATH_PREFIX = "hostproviders"
# data-based properties

@property
def name(self: Self) -> str:
return str(self._data["name"])

class HostProvidersNode(PaginatedChildAccessor): ...
@property
def description(self: Self) -> str:
return str(self._data["description"])

@property
def display_name(self: Self) -> str:
return str(self._data["prototype"]["displayName"])

def get_own_path(self: Self) -> Endpoint:
return self.PATH_PREFIX, self.id


class HostProvidersNode(PaginatedAccessor[HostProvider, None]):
class_type = HostProvider


class Host(Deletable, RootInteractiveObject):
Expand Down Expand Up @@ -160,8 +177,6 @@ def get_own_path(self: Self) -> Endpoint:
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 a2efbba

Please sign in to comment.