github.com/kubearmor/cilium@v1.6.12/api/v1/models/service_spec.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "strconv" 10 11 strfmt "github.com/go-openapi/strfmt" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // ServiceSpec Configuration of a service 19 // swagger:model ServiceSpec 20 type ServiceSpec struct { 21 22 // List of backend addresses 23 BackendAddresses []*BackendAddress `json:"backend-addresses"` 24 25 // flags 26 Flags *ServiceSpecFlags `json:"flags,omitempty"` 27 28 // Frontend address 29 // Required: true 30 FrontendAddress *FrontendAddress `json:"frontend-address"` 31 32 // Unique identification 33 ID int64 `json:"id,omitempty"` 34 } 35 36 // Validate validates this service spec 37 func (m *ServiceSpec) Validate(formats strfmt.Registry) error { 38 var res []error 39 40 if err := m.validateBackendAddresses(formats); err != nil { 41 res = append(res, err) 42 } 43 44 if err := m.validateFlags(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if err := m.validateFrontendAddress(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if len(res) > 0 { 53 return errors.CompositeValidationError(res...) 54 } 55 return nil 56 } 57 58 func (m *ServiceSpec) validateBackendAddresses(formats strfmt.Registry) error { 59 60 if swag.IsZero(m.BackendAddresses) { // not required 61 return nil 62 } 63 64 for i := 0; i < len(m.BackendAddresses); i++ { 65 if swag.IsZero(m.BackendAddresses[i]) { // not required 66 continue 67 } 68 69 if m.BackendAddresses[i] != nil { 70 if err := m.BackendAddresses[i].Validate(formats); err != nil { 71 if ve, ok := err.(*errors.Validation); ok { 72 return ve.ValidateName("backend-addresses" + "." + strconv.Itoa(i)) 73 } 74 return err 75 } 76 } 77 78 } 79 80 return nil 81 } 82 83 func (m *ServiceSpec) validateFlags(formats strfmt.Registry) error { 84 85 if swag.IsZero(m.Flags) { // not required 86 return nil 87 } 88 89 if m.Flags != nil { 90 if err := m.Flags.Validate(formats); err != nil { 91 if ve, ok := err.(*errors.Validation); ok { 92 return ve.ValidateName("flags") 93 } 94 return err 95 } 96 } 97 98 return nil 99 } 100 101 func (m *ServiceSpec) validateFrontendAddress(formats strfmt.Registry) error { 102 103 if err := validate.Required("frontend-address", "body", m.FrontendAddress); err != nil { 104 return err 105 } 106 107 if m.FrontendAddress != nil { 108 if err := m.FrontendAddress.Validate(formats); err != nil { 109 if ve, ok := err.(*errors.Validation); ok { 110 return ve.ValidateName("frontend-address") 111 } 112 return err 113 } 114 } 115 116 return nil 117 } 118 119 // MarshalBinary interface implementation 120 func (m *ServiceSpec) MarshalBinary() ([]byte, error) { 121 if m == nil { 122 return nil, nil 123 } 124 return swag.WriteJSON(m) 125 } 126 127 // UnmarshalBinary interface implementation 128 func (m *ServiceSpec) UnmarshalBinary(b []byte) error { 129 var res ServiceSpec 130 if err := swag.ReadJSON(b, &res); err != nil { 131 return err 132 } 133 *m = res 134 return nil 135 } 136 137 // ServiceSpecFlags Optional service configuration flags 138 // swagger:model ServiceSpecFlags 139 type ServiceSpecFlags struct { 140 141 // Frontend to backend translation activated 142 ActiveFrontend bool `json:"active-frontend,omitempty"` 143 144 // Perform direct server return 145 DirectServerReturn bool `json:"direct-server-return,omitempty"` 146 147 // Service is of Nodeport type 148 NodePort bool `json:"node-port,omitempty"` 149 } 150 151 // Validate validates this service spec flags 152 func (m *ServiceSpecFlags) Validate(formats strfmt.Registry) error { 153 return nil 154 } 155 156 // MarshalBinary interface implementation 157 func (m *ServiceSpecFlags) MarshalBinary() ([]byte, error) { 158 if m == nil { 159 return nil, nil 160 } 161 return swag.WriteJSON(m) 162 } 163 164 // UnmarshalBinary interface implementation 165 func (m *ServiceSpecFlags) UnmarshalBinary(b []byte) error { 166 var res ServiceSpecFlags 167 if err := swag.ReadJSON(b, &res); err != nil { 168 return err 169 } 170 *m = res 171 return nil 172 }