From 0c3f768368c336ebf8e0f25d8582ffbdcd3fac23 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Mon, 12 Feb 2024 13:40:42 +0300 Subject: [PATCH] agent update in place --- propel_client/propel.py | 43 ++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/propel_client/propel.py b/propel_client/propel.py index 63f8299..7589328 100644 --- a/propel_client/propel.py +++ b/propel_client/propel.py @@ -415,9 +415,50 @@ def agents_create( # pylint: disable=too-many-arguments agent_data["ingress_enabled"] = ingress_enabled agent_data["tendermint_ingress_enabled"] = tendermint_ingress_enabled - return self._agents_create_from_data(agent_data) + def agents_update( # pylint: disable=too-many-arguments # noqa + self, + name_or_id: str, + service_ipfs_hash: Optional[str] = None, + ingress_enabled: Optional[bool] = None, + variables: Optional[List[str]] = None, + tendermint_ingress_enabled: Optional[bool] = None, + ) -> Dict: + """ + Update agent by agent name or id. + + :param name: agent name or id + :param service_ipfs_hash: optional service ipfs hash id + :param ingress_enabled: option bool + :param variables: optional list of strings of varible names or ids + :param tendermint_ingress_enabled: optional bool + :return: dict + """ + agent_data: Dict[str, Union[List, int, str]] = {} + + if service_ipfs_hash is not None: + agent_data["service_ipfs_hash"] = service_ipfs_hash + + if variables: + agent_data["variables"] = variables + + if ingress_enabled is not None: + agent_data["ingress_enabled"] = ingress_enabled + + if tendermint_ingress_enabled is not None: + agent_data["tendermint_ingress_enabled"] = tendermint_ingress_enabled + + if not agent_data: + raise ValueError("No values to update!") + + url = self._get_url(self.API_AGENTS_LIST) + f"/{name_or_id}/update_agent/" + response = self._http_post( + url, json=agent_data, **self._get_credentials_params() + ) + self._check_response(response, codes=[200]) + return response.json() + def variables_list(self) -> Dict: """ List user variables. diff --git a/pyproject.toml b/pyproject.toml index 6c6a1e3..b169169 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "propel-client" -version = "v0.0.12" +version = "v0.0.13" description = "Propel service client" authors = ["Yuri Turchenkov "] readme = "README.md"