Skip to content

Commit 481227b

Browse files
Removed overriden _serialize method
1 parent 06356a9 commit 481227b

File tree

1 file changed

+8
-44
lines changed

1 file changed

+8
-44
lines changed

linode_api4/objects/nodebalancer.py

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33

44
from linode_api4.common import Price, RegionPrice
55
from linode_api4.errors import UnexpectedResponseError
6-
from linode_api4.objects.base import (
7-
Base,
8-
ExplicitNullValue,
9-
MappedObject,
10-
Property,
11-
_flatten_request_body_recursive,
12-
)
6+
from linode_api4.objects.base import Base, MappedObject, Property
137
from linode_api4.objects.dbase import DerivedBase
148
from linode_api4.objects.networking import Firewall, IPAddress
159
from linode_api4.objects.region import Region
@@ -114,43 +108,6 @@ class NodeBalancerConfig(DerivedBase):
114108
"proxy_protocol": Property(mutable=True),
115109
}
116110

117-
def _serialize(self):
118-
"""
119-
A helper method to build a dict of all mutable Properties of
120-
this NodeBalancerConfig
121-
"""
122-
123-
result = {}
124-
125-
# Aggregate mutable values into a dict
126-
for k, v in NodeBalancerConfig.properties.items():
127-
if not v.mutable:
128-
continue
129-
130-
value = getattr(self, k)
131-
132-
if not v.nullable and (value is None or value == ""):
133-
continue
134-
135-
# Exclude cipher_suite if protocol is udp
136-
if k == "cipher_suite" and getattr(self, "protocol", None) == "udp":
137-
continue
138-
139-
# Allow explicit null values
140-
if (
141-
isinstance(value, ExplicitNullValue)
142-
or value == ExplicitNullValue
143-
):
144-
value = None
145-
146-
result[k] = value
147-
148-
# Resolve the underlying IDs of results
149-
for k, v in result.items():
150-
result[k] = _flatten_request_body_recursive(v)
151-
152-
return result
153-
154111
def save(self, force=True) -> bool:
155112
"""
156113
Send this NodeBalancerConfig's mutable values to the server in a PUT request.
@@ -166,6 +123,13 @@ def save(self, force=True) -> bool:
166123

167124
data = self._serialize()
168125

126+
print(data)
127+
128+
if data.get("protocol") == "udp" and "cipher_suite" in data:
129+
data.pop("cipher_suite")
130+
131+
print(data)
132+
169133
result = self._client.put(
170134
NodeBalancerConfig.api_endpoint, model=self, data=data
171135
)

0 commit comments

Comments
 (0)