@@ -97,13 +97,19 @@ type UpdateSecurityGroupRuleRequest struct {
9797 SecurityGroupID string `json:"-"`
9898 SecurityGroupRuleID string `json:"-"`
9999
100- Protocol * SecurityGroupRuleProtocol `json:"protocol,omitempty"`
101- Direction * SecurityGroupRuleDirection `json:"direction,omitempty"`
102- Action * SecurityGroupRuleAction `json:"action,omitempty"`
103- IPRange * string `json:"ip_range,omitempty"`
104- DestPortFrom * uint32 `json:"dest_port_from,omitempty"`
105- DestPortTo * uint32 `json:"dest_port_to,omitempty"`
106- Position * uint32 `json:"position,omitempty"`
100+ Protocol * SecurityGroupRuleProtocol `json:"protocol"`
101+ Direction * SecurityGroupRuleDirection `json:"direction"`
102+ Action * SecurityGroupRuleAction `json:"action"`
103+ IPRange * string `json:"ip_range"`
104+ Position * uint32 `json:"position"`
105+
106+ // If set to 0, DestPortFrom will be removed.
107+ // See SecurityGroupRule.DestPortFrom for more information
108+ DestPortFrom * uint32 `json:"dest_port_from"`
109+
110+ // If set to 0, DestPortTo will be removed.
111+ // See SecurityGroupRule.DestPortTo for more information
112+ DestPortTo * uint32 `json:"dest_port_to"`
107113}
108114
109115type UpdateSecurityGroupRuleResponse struct {
@@ -155,10 +161,18 @@ func (s *API) UpdateSecurityGroupRule(req *UpdateSecurityGroupRuleRequest, opts
155161 setRequest .IPRange = * req .IPRange
156162 }
157163 if req .DestPortTo != nil {
158- setRequest .DestPortTo = req .DestPortTo
164+ if * req .DestPortTo > 0 {
165+ setRequest .DestPortTo = req .DestPortTo
166+ } else {
167+ setRequest .DestPortTo = nil
168+ }
159169 }
160170 if req .DestPortFrom != nil {
161- setRequest .DestPortFrom = req .DestPortFrom
171+ if * req .DestPortFrom > 0 {
172+ setRequest .DestPortFrom = req .DestPortFrom
173+ } else {
174+ setRequest .DestPortFrom = nil
175+ }
162176 }
163177 if req .DestPortFrom != nil && req .DestPortTo != nil && * req .DestPortFrom == * req .DestPortTo {
164178 setRequest .DestPortTo = nil
0 commit comments