github.com/cilium/cilium@v1.16.2/api/v1/models/endpoint.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 ) 18 19 // Endpoint An endpoint is a namespaced network interface to which cilium applies policies 20 // 21 // swagger:model Endpoint 22 type Endpoint struct { 23 24 // The cilium-agent-local ID of the endpoint 25 ID int64 `json:"id,omitempty"` 26 27 // The desired configuration state of the endpoint 28 Spec *EndpointConfigurationSpec `json:"spec,omitempty"` 29 30 // The desired and realized configuration state of the endpoint 31 Status *EndpointStatus `json:"status,omitempty"` 32 } 33 34 // Validate validates this endpoint 35 func (m *Endpoint) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateSpec(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if err := m.validateStatus(formats); err != nil { 43 res = append(res, err) 44 } 45 46 if len(res) > 0 { 47 return errors.CompositeValidationError(res...) 48 } 49 return nil 50 } 51 52 func (m *Endpoint) validateSpec(formats strfmt.Registry) error { 53 if swag.IsZero(m.Spec) { // not required 54 return nil 55 } 56 57 if m.Spec != nil { 58 if err := m.Spec.Validate(formats); err != nil { 59 if ve, ok := err.(*errors.Validation); ok { 60 return ve.ValidateName("spec") 61 } else if ce, ok := err.(*errors.CompositeError); ok { 62 return ce.ValidateName("spec") 63 } 64 return err 65 } 66 } 67 68 return nil 69 } 70 71 func (m *Endpoint) validateStatus(formats strfmt.Registry) error { 72 if swag.IsZero(m.Status) { // not required 73 return nil 74 } 75 76 if m.Status != nil { 77 if err := m.Status.Validate(formats); err != nil { 78 if ve, ok := err.(*errors.Validation); ok { 79 return ve.ValidateName("status") 80 } else if ce, ok := err.(*errors.CompositeError); ok { 81 return ce.ValidateName("status") 82 } 83 return err 84 } 85 } 86 87 return nil 88 } 89 90 // ContextValidate validate this endpoint based on the context it is used 91 func (m *Endpoint) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 92 var res []error 93 94 if err := m.contextValidateSpec(ctx, formats); err != nil { 95 res = append(res, err) 96 } 97 98 if err := m.contextValidateStatus(ctx, formats); err != nil { 99 res = append(res, err) 100 } 101 102 if len(res) > 0 { 103 return errors.CompositeValidationError(res...) 104 } 105 return nil 106 } 107 108 func (m *Endpoint) contextValidateSpec(ctx context.Context, formats strfmt.Registry) error { 109 110 if m.Spec != nil { 111 112 if swag.IsZero(m.Spec) { // not required 113 return nil 114 } 115 116 if err := m.Spec.ContextValidate(ctx, formats); err != nil { 117 if ve, ok := err.(*errors.Validation); ok { 118 return ve.ValidateName("spec") 119 } else if ce, ok := err.(*errors.CompositeError); ok { 120 return ce.ValidateName("spec") 121 } 122 return err 123 } 124 } 125 126 return nil 127 } 128 129 func (m *Endpoint) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error { 130 131 if m.Status != nil { 132 133 if swag.IsZero(m.Status) { // not required 134 return nil 135 } 136 137 if err := m.Status.ContextValidate(ctx, formats); err != nil { 138 if ve, ok := err.(*errors.Validation); ok { 139 return ve.ValidateName("status") 140 } else if ce, ok := err.(*errors.CompositeError); ok { 141 return ce.ValidateName("status") 142 } 143 return err 144 } 145 } 146 147 return nil 148 } 149 150 // MarshalBinary interface implementation 151 func (m *Endpoint) MarshalBinary() ([]byte, error) { 152 if m == nil { 153 return nil, nil 154 } 155 return swag.WriteJSON(m) 156 } 157 158 // UnmarshalBinary interface implementation 159 func (m *Endpoint) UnmarshalBinary(b []byte) error { 160 var res Endpoint 161 if err := swag.ReadJSON(b, &res); err != nil { 162 return err 163 } 164 *m = res 165 return nil 166 }