diff --git a/src/py/mat3ra/api_client/client.py b/src/py/mat3ra/api_client/client.py index 00914aa..1299e27 100644 --- a/src/py/mat3ra/api_client/client.py +++ b/src/py/mat3ra/api_client/client.py @@ -8,6 +8,7 @@ from .constants import ACCESS_TOKEN_ENV_VAR, _build_base_url from .endpoints.bank_materials import BankMaterialEndpoints from .endpoints.bank_workflows import BankWorkflowEndpoints +from .endpoints.clusters import ClustersEndpoint from .endpoints.jobs import JobEndpoints from .endpoints.materials import MaterialEndpoints from .endpoints.metaproperties import MetaPropertiesEndpoints @@ -59,6 +60,7 @@ def _init_endpoints(self, timeout_seconds: int) -> None: self.metaproperties = MetaPropertiesEndpoints(*base_args, **base_kwargs) self.bank_materials = BankMaterialEndpoints(*base_args, **base_kwargs) self.bank_workflows = BankWorkflowEndpoints(*base_args, **base_kwargs) + self.clusters = ClustersEndpoint(*base_args, **base_kwargs) @staticmethod def _resolve_config( diff --git a/src/py/mat3ra/api_client/endpoints/clusters.py b/src/py/mat3ra/api_client/endpoints/clusters.py new file mode 100644 index 0000000..d8e58ed --- /dev/null +++ b/src/py/mat3ra/api_client/endpoints/clusters.py @@ -0,0 +1,35 @@ +from . import BaseEndpoint +from .enums import DEFAULT_API_VERSION, SECURE + + +class ClustersEndpoint(BaseEndpoint): + """ + Clusters endpoints for infrastructure access. + + Args: + host (str): API hostname. + port (int): API port number. + account_id (str): account ID. + auth_token (str): authentication token. + version (str): API version. + secure (bool): whether to use secure http protocol (https vs http). + kwargs (dict): a dictionary of HTTP session options. + timeout (int): session timeout in seconds. + + Attributes: + name (str): endpoint name. + headers (dict): default HTTP headers. + """ + + def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs): + super(ClustersEndpoint, self).__init__(host, port, version, secure, **kwargs) + self.headers = self.get_headers(account_id, auth_token) + + def list(self): + """ + Returns a list of available clusters with their queues. + + Returns: + list[Dict]: Cluster information, including queues. + """ + return self.request("GET", "other/clusters", headers=self.headers)