github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_class_put_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 // NewObjectsClassPutParams creates a new ObjectsClassPutParams object 33 // 34 // There are no default values defined in the spec. 35 func NewObjectsClassPutParams() ObjectsClassPutParams { 36 37 return ObjectsClassPutParams{} 38 } 39 40 // ObjectsClassPutParams contains all the bound params for the objects class put operation 41 // typically these are obtained from a http.Request 42 // 43 // swagger:parameters objects.class.put 44 type ObjectsClassPutParams 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 /* 55 Required: true 56 In: path 57 */ 58 ClassName string 59 /*Determines how many replicas must acknowledge a request before it is considered successful 60 In: query 61 */ 62 ConsistencyLevel *string 63 /*The uuid of the data object to update. 64 Required: true 65 In: path 66 */ 67 ID strfmt.UUID 68 } 69 70 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 71 // for simple values it will use straight method calls. 72 // 73 // To ensure default values, the struct must have been initialized with NewObjectsClassPutParams() beforehand. 74 func (o *ObjectsClassPutParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 75 var res []error 76 77 o.HTTPRequest = r 78 79 qs := runtime.Values(r.URL.Query()) 80 81 if runtime.HasBody(r) { 82 defer r.Body.Close() 83 var body models.Object 84 if err := route.Consumer.Consume(r.Body, &body); err != nil { 85 if err == io.EOF { 86 res = append(res, errors.Required("body", "body", "")) 87 } else { 88 res = append(res, errors.NewParseError("body", "body", "", err)) 89 } 90 } else { 91 // validate body object 92 if err := body.Validate(route.Formats); err != nil { 93 res = append(res, err) 94 } 95 96 ctx := validate.WithOperationRequest(r.Context()) 97 if err := body.ContextValidate(ctx, route.Formats); err != nil { 98 res = append(res, err) 99 } 100 101 if len(res) == 0 { 102 o.Body = &body 103 } 104 } 105 } else { 106 res = append(res, errors.Required("body", "body", "")) 107 } 108 109 rClassName, rhkClassName, _ := route.Params.GetOK("className") 110 if err := o.bindClassName(rClassName, rhkClassName, route.Formats); err != nil { 111 res = append(res, err) 112 } 113 114 qConsistencyLevel, qhkConsistencyLevel, _ := qs.GetOK("consistency_level") 115 if err := o.bindConsistencyLevel(qConsistencyLevel, qhkConsistencyLevel, route.Formats); err != nil { 116 res = append(res, err) 117 } 118 119 rID, rhkID, _ := route.Params.GetOK("id") 120 if err := o.bindID(rID, rhkID, route.Formats); err != nil { 121 res = append(res, err) 122 } 123 if len(res) > 0 { 124 return errors.CompositeValidationError(res...) 125 } 126 return nil 127 } 128 129 // bindClassName binds and validates parameter ClassName from path. 130 func (o *ObjectsClassPutParams) bindClassName(rawData []string, hasKey bool, formats strfmt.Registry) error { 131 var raw string 132 if len(rawData) > 0 { 133 raw = rawData[len(rawData)-1] 134 } 135 136 // Required: true 137 // Parameter is provided by construction from the route 138 o.ClassName = raw 139 140 return nil 141 } 142 143 // bindConsistencyLevel binds and validates parameter ConsistencyLevel from query. 144 func (o *ObjectsClassPutParams) bindConsistencyLevel(rawData []string, hasKey bool, formats strfmt.Registry) error { 145 var raw string 146 if len(rawData) > 0 { 147 raw = rawData[len(rawData)-1] 148 } 149 150 // Required: false 151 // AllowEmptyValue: false 152 153 if raw == "" { // empty values pass all other validations 154 return nil 155 } 156 o.ConsistencyLevel = &raw 157 158 return nil 159 } 160 161 // bindID binds and validates parameter ID from path. 162 func (o *ObjectsClassPutParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { 163 var raw string 164 if len(rawData) > 0 { 165 raw = rawData[len(rawData)-1] 166 } 167 168 // Required: true 169 // Parameter is provided by construction from the route 170 171 // Format: uuid 172 value, err := formats.Parse("uuid", raw) 173 if err != nil { 174 return errors.InvalidType("id", "path", "strfmt.UUID", raw) 175 } 176 o.ID = *(value.(*strfmt.UUID)) 177 178 if err := o.validateID(formats); err != nil { 179 return err 180 } 181 182 return nil 183 } 184 185 // validateID carries on validations for parameter ID 186 func (o *ObjectsClassPutParams) validateID(formats strfmt.Registry) error { 187 188 if err := validate.FormatOf("id", "path", "uuid", o.ID.String(), formats); err != nil { 189 return err 190 } 191 return nil 192 }