github.com/cilium/cilium@v1.16.2/api/v1/health/models/health_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 ciliumModels "github.com/cilium/cilium/api/v1/models" 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // HealthResponse Health and status information of local node 21 // 22 // swagger:model HealthResponse 23 type HealthResponse struct { 24 25 // Status of Cilium daemon 26 Cilium ciliumModels.StatusResponse `json:"cilium,omitempty"` 27 28 // System load on node 29 SystemLoad *LoadResponse `json:"system-load,omitempty"` 30 31 // Uptime of cilium-health instance 32 Uptime string `json:"uptime,omitempty"` 33 } 34 35 // Validate validates this health response 36 func (m *HealthResponse) Validate(formats strfmt.Registry) error { 37 var res []error 38 39 if err := m.validateCilium(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if err := m.validateSystemLoad(formats); err != nil { 44 res = append(res, err) 45 } 46 47 if len(res) > 0 { 48 return errors.CompositeValidationError(res...) 49 } 50 return nil 51 } 52 53 func (m *HealthResponse) validateCilium(formats strfmt.Registry) error { 54 if swag.IsZero(m.Cilium) { // not required 55 return nil 56 } 57 58 if err := m.Cilium.Validate(formats); err != nil { 59 if ve, ok := err.(*errors.Validation); ok { 60 return ve.ValidateName("cilium") 61 } else if ce, ok := err.(*errors.CompositeError); ok { 62 return ce.ValidateName("cilium") 63 } 64 return err 65 } 66 67 return nil 68 } 69 70 func (m *HealthResponse) validateSystemLoad(formats strfmt.Registry) error { 71 if swag.IsZero(m.SystemLoad) { // not required 72 return nil 73 } 74 75 if m.SystemLoad != nil { 76 if err := m.SystemLoad.Validate(formats); err != nil { 77 if ve, ok := err.(*errors.Validation); ok { 78 return ve.ValidateName("system-load") 79 } else if ce, ok := err.(*errors.CompositeError); ok { 80 return ce.ValidateName("system-load") 81 } 82 return err 83 } 84 } 85 86 return nil 87 } 88 89 // ContextValidate validate this health response based on the context it is used 90 func (m *HealthResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 91 var res []error 92 93 if err := m.contextValidateCilium(ctx, formats); err != nil { 94 res = append(res, err) 95 } 96 97 if err := m.contextValidateSystemLoad(ctx, formats); err != nil { 98 res = append(res, err) 99 } 100 101 if len(res) > 0 { 102 return errors.CompositeValidationError(res...) 103 } 104 return nil 105 } 106 107 func (m *HealthResponse) contextValidateCilium(ctx context.Context, formats strfmt.Registry) error { 108 109 if swag.IsZero(m.Cilium) { // not required 110 return nil 111 } 112 113 if err := m.Cilium.ContextValidate(ctx, formats); err != nil { 114 if ve, ok := err.(*errors.Validation); ok { 115 return ve.ValidateName("cilium") 116 } else if ce, ok := err.(*errors.CompositeError); ok { 117 return ce.ValidateName("cilium") 118 } 119 return err 120 } 121 122 return nil 123 } 124 125 func (m *HealthResponse) contextValidateSystemLoad(ctx context.Context, formats strfmt.Registry) error { 126 127 if m.SystemLoad != nil { 128 129 if swag.IsZero(m.SystemLoad) { // not required 130 return nil 131 } 132 133 if err := m.SystemLoad.ContextValidate(ctx, formats); err != nil { 134 if ve, ok := err.(*errors.Validation); ok { 135 return ve.ValidateName("system-load") 136 } else if ce, ok := err.(*errors.CompositeError); ok { 137 return ce.ValidateName("system-load") 138 } 139 return err 140 } 141 } 142 143 return nil 144 } 145 146 // MarshalBinary interface implementation 147 func (m *HealthResponse) MarshalBinary() ([]byte, error) { 148 if m == nil { 149 return nil, nil 150 } 151 return swag.WriteJSON(m) 152 } 153 154 // UnmarshalBinary interface implementation 155 func (m *HealthResponse) UnmarshalBinary(b []byte) error { 156 var res HealthResponse 157 if err := swag.ReadJSON(b, &res); err != nil { 158 return err 159 } 160 *m = res 161 return nil 162 }