3
3
4
4
from linode_api4 .common import Price , RegionPrice
5
5
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
13
7
from linode_api4 .objects .dbase import DerivedBase
14
8
from linode_api4 .objects .networking import Firewall , IPAddress
15
9
from linode_api4 .objects .region import Region
@@ -114,43 +108,6 @@ class NodeBalancerConfig(DerivedBase):
114
108
"proxy_protocol" : Property (mutable = True ),
115
109
}
116
110
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
-
154
111
def save (self , force = True ) -> bool :
155
112
"""
156
113
Send this NodeBalancerConfig's mutable values to the server in a PUT request.
@@ -166,6 +123,13 @@ def save(self, force=True) -> bool:
166
123
167
124
data = self ._serialize ()
168
125
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
+
169
133
result = self ._client .put (
170
134
NodeBalancerConfig .api_endpoint , model = self , data = data
171
135
)
0 commit comments