Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADCM-6119: Implement HostProvider object #8

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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