From dc41bd9e449bc3034df44accb88b4280796c3149 Mon Sep 17 00:00:00 2001 From: Artem Starovoitov Date: Fri, 22 Nov 2024 12:28:33 +0300 Subject: [PATCH] ADCM-6122: Implement ADCM object (#11) Co-authored-by: astarovo --- adcm_aio_client/core/client.py | 6 +++++- adcm_aio_client/core/objects/cm.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/adcm_aio_client/core/client.py b/adcm_aio_client/core/client.py index 832f951..c2dc325 100644 --- a/adcm_aio_client/core/client.py +++ b/adcm_aio_client/core/client.py @@ -13,7 +13,7 @@ from functools import cached_property from typing import Self -from adcm_aio_client.core.objects.cm import ClustersNode, HostProvidersNode, HostsNode +from adcm_aio_client.core.objects.cm import ADCM, ClustersNode, HostProvidersNode, HostsNode from adcm_aio_client.core.requesters import Requester from adcm_aio_client.core.types import AuthToken, Cert, Credentials, Verify @@ -34,6 +34,10 @@ def hosts(self: Self) -> HostsNode: def hostproviders(self: Self) -> HostProvidersNode: return HostProvidersNode(path=(), requester=self._requester) + @cached_property + def adcm(self: Self) -> ADCM: + return ADCM(requester=self._requester, data={}) + async def build_client( url: str | list[str], diff --git a/adcm_aio_client/core/objects/cm.py b/adcm_aio_client/core/objects/cm.py index 90e26d5..f36bec1 100644 --- a/adcm_aio_client/core/objects/cm.py +++ b/adcm_aio_client/core/objects/cm.py @@ -21,6 +21,21 @@ from adcm_aio_client.core.types import ADCMEntityStatus, Endpoint +class ADCM(InteractiveObject, WithActions, WithConfig): + @property + def id(self: Self) -> int: + return 1 + + @cached_property + async def version(self: Self) -> str: + # TODO: override root_path for being without /api/v2 + response = await self._requester.get("versions") + return response.as_dict()["adcm"]["version"] + + def get_own_path(self: Self) -> Endpoint: + return ("adcm",) + + class Bundle(Deletable, InteractiveObject): ...