github.com/cilium/cilium@v1.16.2/api/v1/models/ip_a_m_response.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package models 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "context" 13 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/strfmt" 16 "github.com/go-openapi/swag" 17 "github.com/go-openapi/validate" 18 ) 19 20 // IPAMResponse IPAM configuration of an endpoint 21 // 22 // swagger:model IPAMResponse 23 type IPAMResponse struct { 24 25 // address 26 // Required: true 27 Address *AddressPair `json:"address"` 28 29 // host addressing 30 // Required: true 31 HostAddressing *NodeAddressing `json:"host-addressing"` 32 33 // ipv4 34 IPV4 *IPAMAddressResponse `json:"ipv4,omitempty"` 35 36 // ipv6 37 IPV6 *IPAMAddressResponse `json:"ipv6,omitempty"` 38 } 39 40 // Validate validates this IP a m response 41 func (m *IPAMResponse) Validate(formats strfmt.Registry) error { 42 var res []error 43 44 if err := m.validateAddress(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if err := m.validateHostAddressing(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if err := m.validateIPV4(formats); err != nil { 53 res = append(res, err) 54 } 55 56 if err := m.validateIPV6(formats); err != nil { 57 res = append(res, err) 58 } 59 60 if len(res) > 0 { 61 return errors.CompositeValidationError(res...) 62 } 63 return nil 64 } 65 66 func (m *IPAMResponse) validateAddress(formats strfmt.Registry) error { 67 68 if err := validate.Required("address", "body", m.Address); err != nil { 69 return err 70 } 71 72 if m.Address != nil { 73 if err := m.Address.Validate(formats); err != nil { 74 if ve, ok := err.(*errors.Validation); ok { 75 return ve.ValidateName("address") 76 } else if ce, ok := err.(*errors.CompositeError); ok { 77 return ce.ValidateName("address") 78 } 79 return err 80 } 81 } 82 83 return nil 84 } 85 86 func (m *IPAMResponse) validateHostAddressing(formats strfmt.Registry) error { 87 88 if err := validate.Required("host-addressing", "body", m.HostAddressing); err != nil { 89 return err 90 } 91 92 if m.HostAddressing != nil { 93 if err := m.HostAddressing.Validate(formats); err != nil { 94 if ve, ok := err.(*errors.Validation); ok { 95 return ve.ValidateName("host-addressing") 96 } else if ce, ok := err.(*errors.CompositeError); ok { 97 return ce.ValidateName("host-addressing") 98 } 99 return err 100 } 101 } 102 103 return nil 104 } 105 106 func (m *IPAMResponse) validateIPV4(formats strfmt.Registry) error { 107 if swag.IsZero(m.IPV4) { // not required 108 return nil 109 } 110 111 if m.IPV4 != nil { 112 if err := m.IPV4.Validate(formats); err != nil { 113 if ve, ok := err.(*errors.Validation); ok { 114 return ve.ValidateName("ipv4") 115 } else if ce, ok := err.(*errors.CompositeError); ok { 116 return ce.ValidateName("ipv4") 117 } 118 return err 119 } 120 } 121 122 return nil 123 } 124 125 func (m *IPAMResponse) validateIPV6(formats strfmt.Registry) error { 126 if swag.IsZero(m.IPV6) { // not required 127 return nil 128 } 129 130 if m.IPV6 != nil { 131 if err := m.IPV6.Validate(formats); err != nil { 132 if ve, ok := err.(*errors.Validation); ok { 133 return ve.ValidateName("ipv6") 134 } else if ce, ok := err.(*errors.CompositeError); ok { 135 return ce.ValidateName("ipv6") 136 } 137 return err 138 } 139 } 140 141 return nil 142 } 143 144 // ContextValidate validate this IP a m response based on the context it is used 145 func (m *IPAMResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 146 var res []error 147 148 if err := m.contextValidateAddress(ctx, formats); err != nil { 149 res = append(res, err) 150 } 151 152 if err := m.contextValidateHostAddressing(ctx, formats); err != nil { 153 res = append(res, err) 154 } 155 156 if err := m.contextValidateIPV4(ctx, formats); err != nil { 157 res = append(res, err) 158 } 159 160 if err := m.contextValidateIPV6(ctx, formats); err != nil { 161 res = append(res, err) 162 } 163 164 if len(res) > 0 { 165 return errors.CompositeValidationError(res...) 166 } 167 return nil 168 } 169 170 func (m *IPAMResponse) contextValidateAddress(ctx context.Context, formats strfmt.Registry) error { 171 172 if m.Address != nil { 173 174 if err := m.Address.ContextValidate(ctx, formats); err != nil { 175 if ve, ok := err.(*errors.Validation); ok { 176 return ve.ValidateName("address") 177 } else if ce, ok := err.(*errors.CompositeError); ok { 178 return ce.ValidateName("address") 179 } 180 return err 181 } 182 } 183 184 return nil 185 } 186 187 func (m *IPAMResponse) contextValidateHostAddressing(ctx context.Context, formats strfmt.Registry) error { 188 189 if m.HostAddressing != nil { 190 191 if err := m.HostAddressing.ContextValidate(ctx, formats); err != nil { 192 if ve, ok := err.(*errors.Validation); ok { 193 return ve.ValidateName("host-addressing") 194 } else if ce, ok := err.(*errors.CompositeError); ok { 195 return ce.ValidateName("host-addressing") 196 } 197 return err 198 } 199 } 200 201 return nil 202 } 203 204 func (m *IPAMResponse) contextValidateIPV4(ctx context.Context, formats strfmt.Registry) error { 205 206 if m.IPV4 != nil { 207 208 if swag.IsZero(m.IPV4) { // not required 209 return nil 210 } 211 212 if err := m.IPV4.ContextValidate(ctx, formats); err != nil { 213 if ve, ok := err.(*errors.Validation); ok { 214 return ve.ValidateName("ipv4") 215 } else if ce, ok := err.(*errors.CompositeError); ok { 216 return ce.ValidateName("ipv4") 217 } 218 return err 219 } 220 } 221 222 return nil 223 } 224 225 func (m *IPAMResponse) contextValidateIPV6(ctx context.Context, formats strfmt.Registry) error { 226 227 if m.IPV6 != nil { 228 229 if swag.IsZero(m.IPV6) { // not required 230 return nil 231 } 232 233 if err := m.IPV6.ContextValidate(ctx, formats); err != nil { 234 if ve, ok := err.(*errors.Validation); ok { 235 return ve.ValidateName("ipv6") 236 } else if ce, ok := err.(*errors.CompositeError); ok { 237 return ce.ValidateName("ipv6") 238 } 239 return err 240 } 241 } 242 243 return nil 244 } 245 246 // MarshalBinary interface implementation 247 func (m *IPAMResponse) MarshalBinary() ([]byte, error) { 248 if m == nil { 249 return nil, nil 250 } 251 return swag.WriteJSON(m) 252 } 253 254 // UnmarshalBinary interface implementation 255 func (m *IPAMResponse) UnmarshalBinary(b []byte) error { 256 var res IPAMResponse 257 if err := swag.ReadJSON(b, &res); err != nil { 258 return err 259 } 260 *m = res 261 return nil 262 }