github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/batch/batch_references_create_parameters.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 batch 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 "io" 21 "net/http" 22 23 "github.com/go-openapi/errors" 24 "github.com/go-openapi/runtime" 25 "github.com/go-openapi/runtime/middleware" 26 "github.com/go-openapi/strfmt" 27 28 "github.com/weaviate/weaviate/entities/models" 29 ) 30 31 // NewBatchReferencesCreateParams creates a new BatchReferencesCreateParams object 32 // 33 // There are no default values defined in the spec. 34 func NewBatchReferencesCreateParams() BatchReferencesCreateParams { 35 36 return BatchReferencesCreateParams{} 37 } 38 39 // BatchReferencesCreateParams contains all the bound params for the batch references create operation 40 // typically these are obtained from a http.Request 41 // 42 // swagger:parameters batch.references.create 43 type BatchReferencesCreateParams struct { 44 45 // HTTP Request Object 46 HTTPRequest *http.Request `json:"-"` 47 48 /*A list of references to be batched. The ideal size depends on the used database connector. Please see the documentation of the used connector for help 49 Required: true 50 In: body 51 */ 52 Body []*models.BatchReference 53 /*Determines how many replicas must acknowledge a request before it is considered successful 54 In: query 55 */ 56 ConsistencyLevel *string 57 } 58 59 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 60 // for simple values it will use straight method calls. 61 // 62 // To ensure default values, the struct must have been initialized with NewBatchReferencesCreateParams() beforehand. 63 func (o *BatchReferencesCreateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 64 var res []error 65 66 o.HTTPRequest = r 67 68 qs := runtime.Values(r.URL.Query()) 69 70 if runtime.HasBody(r) { 71 defer r.Body.Close() 72 var body []*models.BatchReference 73 if err := route.Consumer.Consume(r.Body, &body); err != nil { 74 if err == io.EOF { 75 res = append(res, errors.Required("body", "body", "")) 76 } else { 77 res = append(res, errors.NewParseError("body", "body", "", err)) 78 } 79 } else { 80 81 // validate array of body objects 82 for i := range body { 83 if body[i] == nil { 84 continue 85 } 86 if err := body[i].Validate(route.Formats); err != nil { 87 res = append(res, err) 88 break 89 } 90 } 91 92 if len(res) == 0 { 93 o.Body = body 94 } 95 } 96 } else { 97 res = append(res, errors.Required("body", "body", "")) 98 } 99 100 qConsistencyLevel, qhkConsistencyLevel, _ := qs.GetOK("consistency_level") 101 if err := o.bindConsistencyLevel(qConsistencyLevel, qhkConsistencyLevel, route.Formats); err != nil { 102 res = append(res, err) 103 } 104 if len(res) > 0 { 105 return errors.CompositeValidationError(res...) 106 } 107 return nil 108 } 109 110 // bindConsistencyLevel binds and validates parameter ConsistencyLevel from query. 111 func (o *BatchReferencesCreateParams) bindConsistencyLevel(rawData []string, hasKey bool, formats strfmt.Registry) error { 112 var raw string 113 if len(rawData) > 0 { 114 raw = rawData[len(rawData)-1] 115 } 116 117 // Required: false 118 // AllowEmptyValue: false 119 120 if raw == "" { // empty values pass all other validations 121 return nil 122 } 123 o.ConsistencyLevel = &raw 124 125 return nil 126 }