Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TPT 1880: Fixed issue with updating non-populated NodeBalancerNode #277

Merged
merged 4 commits into from
May 9, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 23 additions & 3 deletions linode_api4/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,29 @@ def save(self, force=True) -> bool:
if not force and not self._changed:
return False

resp = self._client.put(
type(self).api_endpoint, model=self, data=self._serialize()
)
if not self._populated:
result = {
a: getattr(self, a)
ezilber-akamai-zz marked this conversation as resolved.
Show resolved Hide resolved
for a in type(self).properties
if type(self).properties[a].mutable
and object.__getattribute__(self, a) is not None
and hasattr(self, a)
ezilber-akamai-zz marked this conversation as resolved.
Show resolved Hide resolved
}

for key, value in result.items():
if (
isinstance(value, ExplicitNullValue)
or value == ExplicitNullValue
):
result[key] = None

resp = self._client.put(
type(self).api_endpoint, model=self, data=result
)
else:
resp = self._client.put(
type(self).api_endpoint, model=self, data=self._serialize()
)
ezilber-akamai-zz marked this conversation as resolved.
Show resolved Hide resolved

if "error" in resp:
return False
Expand Down