github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_class_patch.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 generate command 18 19 import ( 20 "net/http" 21 22 "github.com/go-openapi/runtime/middleware" 23 24 "github.com/weaviate/weaviate/entities/models" 25 ) 26 27 // ObjectsClassPatchHandlerFunc turns a function with the right signature into a objects class patch handler 28 type ObjectsClassPatchHandlerFunc func(ObjectsClassPatchParams, *models.Principal) middleware.Responder 29 30 // Handle executing the request and returning a response 31 func (fn ObjectsClassPatchHandlerFunc) Handle(params ObjectsClassPatchParams, principal *models.Principal) middleware.Responder { 32 return fn(params, principal) 33 } 34 35 // ObjectsClassPatchHandler interface for that can handle valid objects class patch params 36 type ObjectsClassPatchHandler interface { 37 Handle(ObjectsClassPatchParams, *models.Principal) middleware.Responder 38 } 39 40 // NewObjectsClassPatch creates a new http.Handler for the objects class patch operation 41 func NewObjectsClassPatch(ctx *middleware.Context, handler ObjectsClassPatchHandler) *ObjectsClassPatch { 42 return &ObjectsClassPatch{Context: ctx, Handler: handler} 43 } 44 45 /* 46 ObjectsClassPatch swagger:route PATCH /objects/{className}/{id} objects objectsClassPatch 47 48 Update an Object based on its UUID (using patch semantics). 49 50 Update an individual data object based on its class and uuid. This method supports json-merge style patch semantics (RFC 7396). Provided meta-data and schema values are validated. LastUpdateTime is set to the time this function is called. 51 */ 52 type ObjectsClassPatch struct { 53 Context *middleware.Context 54 Handler ObjectsClassPatchHandler 55 } 56 57 func (o *ObjectsClassPatch) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 58 route, rCtx, _ := o.Context.RouteInfo(r) 59 if rCtx != nil { 60 *r = *rCtx 61 } 62 var Params = NewObjectsClassPatchParams() 63 uprinc, aCtx, err := o.Context.Authorize(r, route) 64 if err != nil { 65 o.Context.Respond(rw, r, route.Produces, route, err) 66 return 67 } 68 if aCtx != nil { 69 *r = *aCtx 70 } 71 var principal *models.Principal 72 if uprinc != nil { 73 principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise 74 } 75 76 if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 77 o.Context.Respond(rw, r, route.Produces, route, err) 78 return 79 } 80 81 res := o.Handler.Handle(Params, principal) // actually handle the request 82 o.Context.Respond(rw, r, route.Produces, route, res) 83 84 }