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