Skip to content

Commit

Permalink
Ability to update multiple lab properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tmikuska committed Feb 18, 2025
1 parent d53d76b commit f097f31
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions virl2_client/models/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,27 @@ def description(self, value: str) -> None:
"""Set the description of the lab."""
self._set_property("description", value)

@check_stale
@locked
def _set_property(self, prop: str, value: Any):
"""
Set the value of a lab property both locally and on the server.
:param prop: The name of the property.
:param value: The new value of the property.
"""
self._set_properties({prop: value})

@locked
@check_stale
def _set_properties(self, lab_data: dict[str, Any]) -> None:
"""
Set multiple properties of the lab.
:param node_data: A dictionary containing the properties to set.
"""
url = self._url_for("lab")
self._session.patch(url, json={prop: value})
setattr(self, f"_{prop}", value)
self._session.patch(url, json=lab_data)
for prop, value in lab_data.items():
setattr(self, f"_{prop}", value)

@property
def owner(self) -> str:
Expand Down

0 comments on commit f097f31

Please sign in to comment.