@@ -8,6 +8,17 @@ import (
88 "github.com/gophercloud/gophercloud/v2/pagination"
99)
1010
11+ // Type TLSVersion represents a tls version
12+ type TLSVersion string
13+
14+ const (
15+ TLSVersionSSLv3 TLSVersion = "SSLv3"
16+ TLSVersionTLSv1 TLSVersion = "TLSv1"
17+ TLSVersionTLSv1_1 TLSVersion = "TLSv1.1"
18+ TLSVersionTLSv1_2 TLSVersion = "TLSv1.2"
19+ TLSVersionTLSv1_3 TLSVersion = "TLSv1.3"
20+ )
21+
1122// ListOptsBuilder allows extensions to add additional parameters to the
1223// List request.
1324type ListOptsBuilder interface {
@@ -151,7 +162,7 @@ type CreateOpts struct {
151162
152163 // A list of TLS protocol versions. Available versions: SSLv3, TLSv1,
153164 // TLSv1.1, TLSv1.2, TLSv1.3. Available from microversion 2.17.
154- TLSVersions []string `json:"tls_versions,omitempty"`
165+ TLSVersions []TLSVersion `json:"tls_versions,omitempty"`
155166
156167 // The administrative state of the Pool. A valid value is true (UP)
157168 // or false (DOWN).
@@ -256,15 +267,37 @@ type UpdateOpts struct {
256267
257268 // A list of TLS protocol versions. Available versions: SSLv3, TLSv1,
258269 // TLSv1.1, TLSv1.2, TLSv1.3. Available from microversion 2.17.
259- TLSVersions * []string `json:"tls_versions,omitempty"`
270+ TLSVersions * []TLSVersion `json:"tls_versions,omitempty"`
260271
261272 // Tags is a set of resource tags. New in version 2.5
262273 Tags * []string `json:"tags,omitempty"`
263274}
264275
265276// ToPoolUpdateMap builds a request body from UpdateOpts.
266277func (opts UpdateOpts ) ToPoolUpdateMap () (map [string ]any , error ) {
267- return gophercloud .BuildRequestBody (opts , "pool" )
278+ b , err := gophercloud .BuildRequestBody (opts , "pool" )
279+ if err != nil {
280+ return nil , err
281+ }
282+
283+ m := b ["pool" ].(map [string ]any )
284+
285+ // allow to unset session_persistence on empty SessionPersistence struct
286+ if opts .Persistence != nil && * opts .Persistence == (SessionPersistence {}) {
287+ m ["session_persistence" ] = nil
288+ }
289+
290+ // allow to unset alpn_protocols on empty slice
291+ if opts .ALPNProtocols != nil && len (* opts .ALPNProtocols ) == 0 {
292+ m ["alpn_protocols" ] = nil
293+ }
294+
295+ // allow to unset tls_versions on empty slice
296+ if opts .TLSVersions != nil && len (* opts .TLSVersions ) == 0 {
297+ m ["tls_versions" ] = nil
298+ }
299+
300+ return b , nil
268301}
269302
270303// Update allows pools to be updated.
0 commit comments