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-6138: Implement Bundle object #20

Merged
merged 7 commits into from
Nov 29, 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
10 changes: 7 additions & 3 deletions adcm_aio_client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from functools import cached_property
from typing import Self

from adcm_aio_client.core.objects.cm import ADCM, ClustersNode, HostProvidersNode, HostsAccessor
from adcm_aio_client.core.requesters import DefaultRequester
from adcm_aio_client.core.types import AuthToken, Cert, Credentials, Requester, Verify
from adcm_aio_client.core.objects.cm import ADCM, BundlesNode, ClustersNode, HostProvidersNode, HostsAccessor
from adcm_aio_client.core.requesters import DefaultRequester, Requester
from adcm_aio_client.core.types import AuthToken, Cert, Credentials, Verify


class ADCMClient:
Expand All @@ -38,6 +38,10 @@ def hostproviders(self: Self) -> HostProvidersNode:
def adcm(self: Self) -> ADCM:
return ADCM(requester=self._requester, data={})

@cached_property
def bundles(self: Self) -> BundlesNode:
return BundlesNode(path=("bundles",), requester=self._requester)


async def build_client(
url: str,
Expand Down
50 changes: 44 additions & 6 deletions adcm_aio_client/core/objects/cm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from functools import cached_property
from typing import Iterable, Self
from typing import Iterable, Literal, Self
import asyncio

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

from adcm_aio_client.core.errors import NotFoundError, OperationError, ResponseError
from adcm_aio_client.core.objects._accessors import (
Expand Down Expand Up @@ -41,7 +41,48 @@ def get_own_path(self: Self) -> Endpoint:
return ("adcm",)


class Bundle(Deletable, InteractiveObject): ...
class License(InteractiveObject): ...


class Bundle(Deletable, RootInteractiveObject):
PATH_PREFIX = "bundles"

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

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

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

@property
def edition(self: Self) -> Literal["community", "enterprise"]:
return self._data["edition"]

@property
def signature_status(self: Self) -> Literal["invalid", "valid", "absent"]:
return self._data["signatureStatus"]

@property
def _type(self: Self) -> Literal["cluster", "provider"]:
return self._data["mainPrototype"]["type"]

def license(self: Self) -> License:
return self._construct(what=License, from_data=self._data["mainPrototype"]["license"])

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


class BundlesNode(PaginatedAccessor[Bundle, None]):
class_type = Bundle

def get_own_path(self: Self) -> Endpoint:
return ("bundles",)
Sealwing marked this conversation as resolved.
Show resolved Hide resolved


class Cluster(
Expand Down Expand Up @@ -112,9 +153,6 @@ def get_own_path(self: Self) -> Endpoint:
class ClustersNode(PaginatedAccessor[Cluster, None]):
class_type = Cluster

def get_own_path(self: Self) -> Endpoint:
return ("clusters",)


class Service(
WithStatus,
Expand Down