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