Skip to content

Commit

Permalink
agent update in place
Browse files Browse the repository at this point in the history
  • Loading branch information
solarw committed Feb 12, 2024
1 parent b932783 commit 9a81565
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
43 changes: 42 additions & 1 deletion propel_client/propel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_or_id: 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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "propel-client"
version = "v0.0.12"
version = "v0.0.13"
description = "Propel service client"
authors = ["Yuri Turchenkov <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 9a81565

Please sign in to comment.