github.com/weaviate/weaviate@v1.24.6/entities/models/object.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 22 "github.com/go-openapi/errors" 23 "github.com/go-openapi/strfmt" 24 "github.com/go-openapi/swag" 25 "github.com/go-openapi/validate" 26 ) 27 28 // Object object 29 // 30 // swagger:model Object 31 type Object struct { 32 33 // additional 34 Additional AdditionalProperties `json:"additional,omitempty"` 35 36 // Class of the Object, defined in the schema. 37 Class string `json:"class,omitempty"` 38 39 // Timestamp of creation of this Object in milliseconds since epoch UTC. 40 CreationTimeUnix int64 `json:"creationTimeUnix,omitempty"` 41 42 // ID of the Object. 43 // Format: uuid 44 ID strfmt.UUID `json:"id,omitempty"` 45 46 // Timestamp of the last Object update in milliseconds since epoch UTC. 47 LastUpdateTimeUnix int64 `json:"lastUpdateTimeUnix,omitempty"` 48 49 // properties 50 Properties PropertySchema `json:"properties,omitempty"` 51 52 // Name of the Objects tenant. 53 Tenant string `json:"tenant,omitempty"` 54 55 // This field returns vectors associated with the Object. C11yVector, Vector or Vectors values are possible. 56 Vector C11yVector `json:"vector,omitempty"` 57 58 // vector weights 59 VectorWeights VectorWeights `json:"vectorWeights,omitempty"` 60 61 // This field returns vectors associated with the Object. 62 Vectors Vectors `json:"vectors,omitempty"` 63 } 64 65 // Validate validates this object 66 func (m *Object) Validate(formats strfmt.Registry) error { 67 var res []error 68 69 if err := m.validateAdditional(formats); err != nil { 70 res = append(res, err) 71 } 72 73 if err := m.validateID(formats); err != nil { 74 res = append(res, err) 75 } 76 77 if err := m.validateVector(formats); err != nil { 78 res = append(res, err) 79 } 80 81 if err := m.validateVectors(formats); err != nil { 82 res = append(res, err) 83 } 84 85 if len(res) > 0 { 86 return errors.CompositeValidationError(res...) 87 } 88 return nil 89 } 90 91 func (m *Object) validateAdditional(formats strfmt.Registry) error { 92 if swag.IsZero(m.Additional) { // not required 93 return nil 94 } 95 96 if m.Additional != nil { 97 if err := m.Additional.Validate(formats); err != nil { 98 if ve, ok := err.(*errors.Validation); ok { 99 return ve.ValidateName("additional") 100 } else if ce, ok := err.(*errors.CompositeError); ok { 101 return ce.ValidateName("additional") 102 } 103 return err 104 } 105 } 106 107 return nil 108 } 109 110 func (m *Object) validateID(formats strfmt.Registry) error { 111 if swag.IsZero(m.ID) { // not required 112 return nil 113 } 114 115 if err := validate.FormatOf("id", "body", "uuid", m.ID.String(), formats); err != nil { 116 return err 117 } 118 119 return nil 120 } 121 122 func (m *Object) validateVector(formats strfmt.Registry) error { 123 if swag.IsZero(m.Vector) { // not required 124 return nil 125 } 126 127 if err := m.Vector.Validate(formats); err != nil { 128 if ve, ok := err.(*errors.Validation); ok { 129 return ve.ValidateName("vector") 130 } else if ce, ok := err.(*errors.CompositeError); ok { 131 return ce.ValidateName("vector") 132 } 133 return err 134 } 135 136 return nil 137 } 138 139 func (m *Object) validateVectors(formats strfmt.Registry) error { 140 if swag.IsZero(m.Vectors) { // not required 141 return nil 142 } 143 144 if m.Vectors != nil { 145 if err := m.Vectors.Validate(formats); err != nil { 146 if ve, ok := err.(*errors.Validation); ok { 147 return ve.ValidateName("vectors") 148 } else if ce, ok := err.(*errors.CompositeError); ok { 149 return ce.ValidateName("vectors") 150 } 151 return err 152 } 153 } 154 155 return nil 156 } 157 158 // ContextValidate validate this object based on the context it is used 159 func (m *Object) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 160 var res []error 161 162 if err := m.contextValidateAdditional(ctx, formats); err != nil { 163 res = append(res, err) 164 } 165 166 if err := m.contextValidateVector(ctx, formats); err != nil { 167 res = append(res, err) 168 } 169 170 if err := m.contextValidateVectors(ctx, formats); err != nil { 171 res = append(res, err) 172 } 173 174 if len(res) > 0 { 175 return errors.CompositeValidationError(res...) 176 } 177 return nil 178 } 179 180 func (m *Object) contextValidateAdditional(ctx context.Context, formats strfmt.Registry) error { 181 182 if err := m.Additional.ContextValidate(ctx, formats); err != nil { 183 if ve, ok := err.(*errors.Validation); ok { 184 return ve.ValidateName("additional") 185 } else if ce, ok := err.(*errors.CompositeError); ok { 186 return ce.ValidateName("additional") 187 } 188 return err 189 } 190 191 return nil 192 } 193 194 func (m *Object) contextValidateVector(ctx context.Context, formats strfmt.Registry) error { 195 196 if err := m.Vector.ContextValidate(ctx, formats); err != nil { 197 if ve, ok := err.(*errors.Validation); ok { 198 return ve.ValidateName("vector") 199 } else if ce, ok := err.(*errors.CompositeError); ok { 200 return ce.ValidateName("vector") 201 } 202 return err 203 } 204 205 return nil 206 } 207 208 func (m *Object) contextValidateVectors(ctx context.Context, formats strfmt.Registry) error { 209 210 if err := m.Vectors.ContextValidate(ctx, formats); err != nil { 211 if ve, ok := err.(*errors.Validation); ok { 212 return ve.ValidateName("vectors") 213 } else if ce, ok := err.(*errors.CompositeError); ok { 214 return ce.ValidateName("vectors") 215 } 216 return err 217 } 218 219 return nil 220 } 221 222 // MarshalBinary interface implementation 223 func (m *Object) MarshalBinary() ([]byte, error) { 224 if m == nil { 225 return nil, nil 226 } 227 return swag.WriteJSON(m) 228 } 229 230 // UnmarshalBinary interface implementation 231 func (m *Object) UnmarshalBinary(b []byte) error { 232 var res Object 233 if err := swag.ReadJSON(b, &res); err != nil { 234 return err 235 } 236 *m = res 237 return nil 238 }