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