github.com/weaviate/weaviate@v1.24.6/entities/models/classification.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 "encoding/json" 22 23 "github.com/go-openapi/errors" 24 "github.com/go-openapi/strfmt" 25 "github.com/go-openapi/swag" 26 "github.com/go-openapi/validate" 27 ) 28 29 // Classification Manage classifications, trigger them and view status of past classifications. 30 // 31 // swagger:model Classification 32 type Classification struct { 33 34 // base the text-based classification on these fields (of type text) 35 // Example: ["description"] 36 BasedOnProperties []string `json:"basedOnProperties"` 37 38 // class (name) which is used in this classification 39 // Example: City 40 Class string `json:"class,omitempty"` 41 42 // which ref-property to set as part of the classification 43 // Example: ["inCountry"] 44 ClassifyProperties []string `json:"classifyProperties"` 45 46 // error message if status == failed 47 // Example: classify xzy: something went wrong 48 Error string `json:"error,omitempty"` 49 50 // filters 51 Filters *ClassificationFilters `json:"filters,omitempty"` 52 53 // ID to uniquely identify this classification run 54 // Example: ee722219-b8ec-4db1-8f8d-5150bb1a9e0c 55 // Format: uuid 56 ID strfmt.UUID `json:"id,omitempty"` 57 58 // additional meta information about the classification 59 Meta *ClassificationMeta `json:"meta,omitempty"` 60 61 // classification-type specific settings 62 Settings interface{} `json:"settings,omitempty"` 63 64 // status of this classification 65 // Example: running 66 // Enum: [running completed failed] 67 Status string `json:"status,omitempty"` 68 69 // which algorithm to use for classifications 70 Type string `json:"type,omitempty"` 71 } 72 73 // Validate validates this classification 74 func (m *Classification) Validate(formats strfmt.Registry) error { 75 var res []error 76 77 if err := m.validateFilters(formats); err != nil { 78 res = append(res, err) 79 } 80 81 if err := m.validateID(formats); err != nil { 82 res = append(res, err) 83 } 84 85 if err := m.validateMeta(formats); err != nil { 86 res = append(res, err) 87 } 88 89 if err := m.validateStatus(formats); err != nil { 90 res = append(res, err) 91 } 92 93 if len(res) > 0 { 94 return errors.CompositeValidationError(res...) 95 } 96 return nil 97 } 98 99 func (m *Classification) validateFilters(formats strfmt.Registry) error { 100 if swag.IsZero(m.Filters) { // not required 101 return nil 102 } 103 104 if m.Filters != nil { 105 if err := m.Filters.Validate(formats); err != nil { 106 if ve, ok := err.(*errors.Validation); ok { 107 return ve.ValidateName("filters") 108 } else if ce, ok := err.(*errors.CompositeError); ok { 109 return ce.ValidateName("filters") 110 } 111 return err 112 } 113 } 114 115 return nil 116 } 117 118 func (m *Classification) validateID(formats strfmt.Registry) error { 119 if swag.IsZero(m.ID) { // not required 120 return nil 121 } 122 123 if err := validate.FormatOf("id", "body", "uuid", m.ID.String(), formats); err != nil { 124 return err 125 } 126 127 return nil 128 } 129 130 func (m *Classification) validateMeta(formats strfmt.Registry) error { 131 if swag.IsZero(m.Meta) { // not required 132 return nil 133 } 134 135 if m.Meta != nil { 136 if err := m.Meta.Validate(formats); err != nil { 137 if ve, ok := err.(*errors.Validation); ok { 138 return ve.ValidateName("meta") 139 } else if ce, ok := err.(*errors.CompositeError); ok { 140 return ce.ValidateName("meta") 141 } 142 return err 143 } 144 } 145 146 return nil 147 } 148 149 var classificationTypeStatusPropEnum []interface{} 150 151 func init() { 152 var res []string 153 if err := json.Unmarshal([]byte(`["running","completed","failed"]`), &res); err != nil { 154 panic(err) 155 } 156 for _, v := range res { 157 classificationTypeStatusPropEnum = append(classificationTypeStatusPropEnum, v) 158 } 159 } 160 161 const ( 162 163 // ClassificationStatusRunning captures enum value "running" 164 ClassificationStatusRunning string = "running" 165 166 // ClassificationStatusCompleted captures enum value "completed" 167 ClassificationStatusCompleted string = "completed" 168 169 // ClassificationStatusFailed captures enum value "failed" 170 ClassificationStatusFailed string = "failed" 171 ) 172 173 // prop value enum 174 func (m *Classification) validateStatusEnum(path, location string, value string) error { 175 if err := validate.EnumCase(path, location, value, classificationTypeStatusPropEnum, true); err != nil { 176 return err 177 } 178 return nil 179 } 180 181 func (m *Classification) validateStatus(formats strfmt.Registry) error { 182 if swag.IsZero(m.Status) { // not required 183 return nil 184 } 185 186 // value enum 187 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 188 return err 189 } 190 191 return nil 192 } 193 194 // ContextValidate validate this classification based on the context it is used 195 func (m *Classification) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 196 var res []error 197 198 if err := m.contextValidateFilters(ctx, formats); err != nil { 199 res = append(res, err) 200 } 201 202 if err := m.contextValidateMeta(ctx, formats); err != nil { 203 res = append(res, err) 204 } 205 206 if len(res) > 0 { 207 return errors.CompositeValidationError(res...) 208 } 209 return nil 210 } 211 212 func (m *Classification) contextValidateFilters(ctx context.Context, formats strfmt.Registry) error { 213 214 if m.Filters != nil { 215 if err := m.Filters.ContextValidate(ctx, formats); err != nil { 216 if ve, ok := err.(*errors.Validation); ok { 217 return ve.ValidateName("filters") 218 } else if ce, ok := err.(*errors.CompositeError); ok { 219 return ce.ValidateName("filters") 220 } 221 return err 222 } 223 } 224 225 return nil 226 } 227 228 func (m *Classification) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { 229 230 if m.Meta != nil { 231 if err := m.Meta.ContextValidate(ctx, formats); err != nil { 232 if ve, ok := err.(*errors.Validation); ok { 233 return ve.ValidateName("meta") 234 } else if ce, ok := err.(*errors.CompositeError); ok { 235 return ce.ValidateName("meta") 236 } 237 return err 238 } 239 } 240 241 return nil 242 } 243 244 // MarshalBinary interface implementation 245 func (m *Classification) MarshalBinary() ([]byte, error) { 246 if m == nil { 247 return nil, nil 248 } 249 return swag.WriteJSON(m) 250 } 251 252 // UnmarshalBinary interface implementation 253 func (m *Classification) UnmarshalBinary(b []byte) error { 254 var res Classification 255 if err := swag.ReadJSON(b, &res); err != nil { 256 return err 257 } 258 *m = res 259 return nil 260 } 261 262 // ClassificationFilters classification filters 263 // 264 // swagger:model ClassificationFilters 265 type ClassificationFilters struct { 266 267 // limit the objects to be classified 268 SourceWhere *WhereFilter `json:"sourceWhere,omitempty"` 269 270 // Limit the possible sources when using an algorithm which doesn't really on training data, e.g. 'contextual'. When using an algorithm with a training set, such as 'knn', limit the training set instead 271 TargetWhere *WhereFilter `json:"targetWhere,omitempty"` 272 273 // Limit the training objects to be considered during the classification. Can only be used on types with explicit training sets, such as 'knn' 274 TrainingSetWhere *WhereFilter `json:"trainingSetWhere,omitempty"` 275 } 276 277 // Validate validates this classification filters 278 func (m *ClassificationFilters) Validate(formats strfmt.Registry) error { 279 var res []error 280 281 if err := m.validateSourceWhere(formats); err != nil { 282 res = append(res, err) 283 } 284 285 if err := m.validateTargetWhere(formats); err != nil { 286 res = append(res, err) 287 } 288 289 if err := m.validateTrainingSetWhere(formats); err != nil { 290 res = append(res, err) 291 } 292 293 if len(res) > 0 { 294 return errors.CompositeValidationError(res...) 295 } 296 return nil 297 } 298 299 func (m *ClassificationFilters) validateSourceWhere(formats strfmt.Registry) error { 300 if swag.IsZero(m.SourceWhere) { // not required 301 return nil 302 } 303 304 if m.SourceWhere != nil { 305 if err := m.SourceWhere.Validate(formats); err != nil { 306 if ve, ok := err.(*errors.Validation); ok { 307 return ve.ValidateName("filters" + "." + "sourceWhere") 308 } else if ce, ok := err.(*errors.CompositeError); ok { 309 return ce.ValidateName("filters" + "." + "sourceWhere") 310 } 311 return err 312 } 313 } 314 315 return nil 316 } 317 318 func (m *ClassificationFilters) validateTargetWhere(formats strfmt.Registry) error { 319 if swag.IsZero(m.TargetWhere) { // not required 320 return nil 321 } 322 323 if m.TargetWhere != nil { 324 if err := m.TargetWhere.Validate(formats); err != nil { 325 if ve, ok := err.(*errors.Validation); ok { 326 return ve.ValidateName("filters" + "." + "targetWhere") 327 } else if ce, ok := err.(*errors.CompositeError); ok { 328 return ce.ValidateName("filters" + "." + "targetWhere") 329 } 330 return err 331 } 332 } 333 334 return nil 335 } 336 337 func (m *ClassificationFilters) validateTrainingSetWhere(formats strfmt.Registry) error { 338 if swag.IsZero(m.TrainingSetWhere) { // not required 339 return nil 340 } 341 342 if m.TrainingSetWhere != nil { 343 if err := m.TrainingSetWhere.Validate(formats); err != nil { 344 if ve, ok := err.(*errors.Validation); ok { 345 return ve.ValidateName("filters" + "." + "trainingSetWhere") 346 } else if ce, ok := err.(*errors.CompositeError); ok { 347 return ce.ValidateName("filters" + "." + "trainingSetWhere") 348 } 349 return err 350 } 351 } 352 353 return nil 354 } 355 356 // ContextValidate validate this classification filters based on the context it is used 357 func (m *ClassificationFilters) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 358 var res []error 359 360 if err := m.contextValidateSourceWhere(ctx, formats); err != nil { 361 res = append(res, err) 362 } 363 364 if err := m.contextValidateTargetWhere(ctx, formats); err != nil { 365 res = append(res, err) 366 } 367 368 if err := m.contextValidateTrainingSetWhere(ctx, formats); err != nil { 369 res = append(res, err) 370 } 371 372 if len(res) > 0 { 373 return errors.CompositeValidationError(res...) 374 } 375 return nil 376 } 377 378 func (m *ClassificationFilters) contextValidateSourceWhere(ctx context.Context, formats strfmt.Registry) error { 379 380 if m.SourceWhere != nil { 381 if err := m.SourceWhere.ContextValidate(ctx, formats); err != nil { 382 if ve, ok := err.(*errors.Validation); ok { 383 return ve.ValidateName("filters" + "." + "sourceWhere") 384 } else if ce, ok := err.(*errors.CompositeError); ok { 385 return ce.ValidateName("filters" + "." + "sourceWhere") 386 } 387 return err 388 } 389 } 390 391 return nil 392 } 393 394 func (m *ClassificationFilters) contextValidateTargetWhere(ctx context.Context, formats strfmt.Registry) error { 395 396 if m.TargetWhere != nil { 397 if err := m.TargetWhere.ContextValidate(ctx, formats); err != nil { 398 if ve, ok := err.(*errors.Validation); ok { 399 return ve.ValidateName("filters" + "." + "targetWhere") 400 } else if ce, ok := err.(*errors.CompositeError); ok { 401 return ce.ValidateName("filters" + "." + "targetWhere") 402 } 403 return err 404 } 405 } 406 407 return nil 408 } 409 410 func (m *ClassificationFilters) contextValidateTrainingSetWhere(ctx context.Context, formats strfmt.Registry) error { 411 412 if m.TrainingSetWhere != nil { 413 if err := m.TrainingSetWhere.ContextValidate(ctx, formats); err != nil { 414 if ve, ok := err.(*errors.Validation); ok { 415 return ve.ValidateName("filters" + "." + "trainingSetWhere") 416 } else if ce, ok := err.(*errors.CompositeError); ok { 417 return ce.ValidateName("filters" + "." + "trainingSetWhere") 418 } 419 return err 420 } 421 } 422 423 return nil 424 } 425 426 // MarshalBinary interface implementation 427 func (m *ClassificationFilters) MarshalBinary() ([]byte, error) { 428 if m == nil { 429 return nil, nil 430 } 431 return swag.WriteJSON(m) 432 } 433 434 // UnmarshalBinary interface implementation 435 func (m *ClassificationFilters) UnmarshalBinary(b []byte) error { 436 var res ClassificationFilters 437 if err := swag.ReadJSON(b, &res); err != nil { 438 return err 439 } 440 *m = res 441 return nil 442 }