github.com/cilium/cilium@v1.16.2/api/v1/models/ip_list_entry.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 // IPListEntry IP entry with metadata 21 // 22 // swagger:model IPListEntry 23 type IPListEntry struct { 24 25 // Key of the entry in the form of a CIDR range 26 // Required: true 27 Cidr *string `json:"cidr"` 28 29 // The context ID for the encryption session 30 EncryptKey int64 `json:"encryptKey,omitempty"` 31 32 // IP address of the host 33 HostIP string `json:"hostIP,omitempty"` 34 35 // Numerical identity assigned to the IP 36 // Required: true 37 Identity *int64 `json:"identity"` 38 39 // metadata 40 Metadata *IPListEntryMetadata `json:"metadata,omitempty"` 41 } 42 43 // Validate validates this IP list entry 44 func (m *IPListEntry) Validate(formats strfmt.Registry) error { 45 var res []error 46 47 if err := m.validateCidr(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if err := m.validateIdentity(formats); err != nil { 52 res = append(res, err) 53 } 54 55 if err := m.validateMetadata(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if len(res) > 0 { 60 return errors.CompositeValidationError(res...) 61 } 62 return nil 63 } 64 65 func (m *IPListEntry) validateCidr(formats strfmt.Registry) error { 66 67 if err := validate.Required("cidr", "body", m.Cidr); err != nil { 68 return err 69 } 70 71 return nil 72 } 73 74 func (m *IPListEntry) validateIdentity(formats strfmt.Registry) error { 75 76 if err := validate.Required("identity", "body", m.Identity); err != nil { 77 return err 78 } 79 80 return nil 81 } 82 83 func (m *IPListEntry) validateMetadata(formats strfmt.Registry) error { 84 if swag.IsZero(m.Metadata) { // not required 85 return nil 86 } 87 88 if m.Metadata != nil { 89 if err := m.Metadata.Validate(formats); err != nil { 90 if ve, ok := err.(*errors.Validation); ok { 91 return ve.ValidateName("metadata") 92 } else if ce, ok := err.(*errors.CompositeError); ok { 93 return ce.ValidateName("metadata") 94 } 95 return err 96 } 97 } 98 99 return nil 100 } 101 102 // ContextValidate validate this IP list entry based on the context it is used 103 func (m *IPListEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 104 var res []error 105 106 if err := m.contextValidateMetadata(ctx, formats); err != nil { 107 res = append(res, err) 108 } 109 110 if len(res) > 0 { 111 return errors.CompositeValidationError(res...) 112 } 113 return nil 114 } 115 116 func (m *IPListEntry) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error { 117 118 if m.Metadata != nil { 119 120 if swag.IsZero(m.Metadata) { // not required 121 return nil 122 } 123 124 if err := m.Metadata.ContextValidate(ctx, formats); err != nil { 125 if ve, ok := err.(*errors.Validation); ok { 126 return ve.ValidateName("metadata") 127 } else if ce, ok := err.(*errors.CompositeError); ok { 128 return ce.ValidateName("metadata") 129 } 130 return err 131 } 132 } 133 134 return nil 135 } 136 137 // MarshalBinary interface implementation 138 func (m *IPListEntry) MarshalBinary() ([]byte, error) { 139 if m == nil { 140 return nil, nil 141 } 142 return swag.WriteJSON(m) 143 } 144 145 // UnmarshalBinary interface implementation 146 func (m *IPListEntry) UnmarshalBinary(b []byte) error { 147 var res IPListEntry 148 if err := swag.ReadJSON(b, &res); err != nil { 149 return err 150 } 151 *m = res 152 return nil 153 }