github.com/cilium/cilium@v1.16.2/api/v1/health/models/endpoint_status.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 "strconv" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // EndpointStatus Connectivity status to host cilium-health endpoints via different paths 21 // 22 // swagger:model EndpointStatus 23 type EndpointStatus struct { 24 25 // primary address 26 PrimaryAddress *PathStatus `json:"primary-address,omitempty"` 27 28 // secondary addresses 29 SecondaryAddresses []*PathStatus `json:"secondary-addresses"` 30 } 31 32 // Validate validates this endpoint status 33 func (m *EndpointStatus) Validate(formats strfmt.Registry) error { 34 var res []error 35 36 if err := m.validatePrimaryAddress(formats); err != nil { 37 res = append(res, err) 38 } 39 40 if err := m.validateSecondaryAddresses(formats); err != nil { 41 res = append(res, err) 42 } 43 44 if len(res) > 0 { 45 return errors.CompositeValidationError(res...) 46 } 47 return nil 48 } 49 50 func (m *EndpointStatus) validatePrimaryAddress(formats strfmt.Registry) error { 51 if swag.IsZero(m.PrimaryAddress) { // not required 52 return nil 53 } 54 55 if m.PrimaryAddress != nil { 56 if err := m.PrimaryAddress.Validate(formats); err != nil { 57 if ve, ok := err.(*errors.Validation); ok { 58 return ve.ValidateName("primary-address") 59 } else if ce, ok := err.(*errors.CompositeError); ok { 60 return ce.ValidateName("primary-address") 61 } 62 return err 63 } 64 } 65 66 return nil 67 } 68 69 func (m *EndpointStatus) validateSecondaryAddresses(formats strfmt.Registry) error { 70 if swag.IsZero(m.SecondaryAddresses) { // not required 71 return nil 72 } 73 74 for i := 0; i < len(m.SecondaryAddresses); i++ { 75 if swag.IsZero(m.SecondaryAddresses[i]) { // not required 76 continue 77 } 78 79 if m.SecondaryAddresses[i] != nil { 80 if err := m.SecondaryAddresses[i].Validate(formats); err != nil { 81 if ve, ok := err.(*errors.Validation); ok { 82 return ve.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 83 } else if ce, ok := err.(*errors.CompositeError); ok { 84 return ce.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 85 } 86 return err 87 } 88 } 89 90 } 91 92 return nil 93 } 94 95 // ContextValidate validate this endpoint status based on the context it is used 96 func (m *EndpointStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 97 var res []error 98 99 if err := m.contextValidatePrimaryAddress(ctx, formats); err != nil { 100 res = append(res, err) 101 } 102 103 if err := m.contextValidateSecondaryAddresses(ctx, formats); err != nil { 104 res = append(res, err) 105 } 106 107 if len(res) > 0 { 108 return errors.CompositeValidationError(res...) 109 } 110 return nil 111 } 112 113 func (m *EndpointStatus) contextValidatePrimaryAddress(ctx context.Context, formats strfmt.Registry) error { 114 115 if m.PrimaryAddress != nil { 116 117 if swag.IsZero(m.PrimaryAddress) { // not required 118 return nil 119 } 120 121 if err := m.PrimaryAddress.ContextValidate(ctx, formats); err != nil { 122 if ve, ok := err.(*errors.Validation); ok { 123 return ve.ValidateName("primary-address") 124 } else if ce, ok := err.(*errors.CompositeError); ok { 125 return ce.ValidateName("primary-address") 126 } 127 return err 128 } 129 } 130 131 return nil 132 } 133 134 func (m *EndpointStatus) contextValidateSecondaryAddresses(ctx context.Context, formats strfmt.Registry) error { 135 136 for i := 0; i < len(m.SecondaryAddresses); i++ { 137 138 if m.SecondaryAddresses[i] != nil { 139 140 if swag.IsZero(m.SecondaryAddresses[i]) { // not required 141 return nil 142 } 143 144 if err := m.SecondaryAddresses[i].ContextValidate(ctx, formats); err != nil { 145 if ve, ok := err.(*errors.Validation); ok { 146 return ve.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 147 } else if ce, ok := err.(*errors.CompositeError); ok { 148 return ce.ValidateName("secondary-addresses" + "." + strconv.Itoa(i)) 149 } 150 return err 151 } 152 } 153 154 } 155 156 return nil 157 } 158 159 // MarshalBinary interface implementation 160 func (m *EndpointStatus) MarshalBinary() ([]byte, error) { 161 if m == nil { 162 return nil, nil 163 } 164 return swag.WriteJSON(m) 165 } 166 167 // UnmarshalBinary interface implementation 168 func (m *EndpointStatus) UnmarshalBinary(b []byte) error { 169 var res EndpointStatus 170 if err := swag.ReadJSON(b, &res); err != nil { 171 return err 172 } 173 *m = res 174 return nil 175 }