Skip to content

Commit fcb631b

Browse files
Implement _serialize(...) override in NodeBalancerConfig
1 parent 8ff070c commit fcb631b

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

linode_api4/objects/nodebalancer.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,34 +108,19 @@ class NodeBalancerConfig(DerivedBase):
108108
"proxy_protocol": Property(mutable=True),
109109
}
110110

111-
def save(self, force=True) -> bool:
111+
def _serialize(self, is_put: bool = False):
112112
"""
113-
Send this NodeBalancerConfig's mutable values to the server in a PUT request.
114-
:param force: If true, this method will always send a PUT request regardless of
115-
whether the field has been explicitly updated. For optimization
116-
purposes, this field should be set to false for typical update
117-
operations. (Defaults to True)
118-
:type force: bool
113+
This override removes the `cipher_suite` field from the PUT request
114+
body on calls to save(...) for UDP configs, which is rejected by
115+
the API.
119116
"""
120117

121-
if not force and not self._changed:
122-
return False
118+
result = super()._serialize(is_put)
123119

124-
data = self._serialize()
120+
if is_put and result["protocol"] == "udp" and "cipher_suite" in result:
121+
del result["cipher_suite"]
125122

126-
if data.get("protocol") == "udp" and "cipher_suite" in data:
127-
data.pop("cipher_suite")
128-
129-
result = self._client.put(
130-
NodeBalancerConfig.api_endpoint, model=self, data=data
131-
)
132-
133-
if "error" in result:
134-
return False
135-
136-
self._populate(result)
137-
138-
return True
123+
return result
139124

140125
@property
141126
def nodes(self):

0 commit comments

Comments
 (0)