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