github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/schema/schema_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 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  // NewSchemaObjectsUpdateParams creates a new SchemaObjectsUpdateParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewSchemaObjectsUpdateParams() SchemaObjectsUpdateParams {
    36  
    37  	return SchemaObjectsUpdateParams{}
    38  }
    39  
    40  // SchemaObjectsUpdateParams contains all the bound params for the schema objects update operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters schema.objects.update
    44  type SchemaObjectsUpdateParams struct {
    45  
    46  	// HTTP Request Object
    47  	HTTPRequest *http.Request `json:"-"`
    48  
    49  	/*
    50  	  Required: true
    51  	  In: path
    52  	*/
    53  	ClassName string
    54  	/*
    55  	  Required: true
    56  	  In: body
    57  	*/
    58  	ObjectClass *models.Class
    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 NewSchemaObjectsUpdateParams() beforehand.
    65  func (o *SchemaObjectsUpdateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    66  	var res []error
    67  
    68  	o.HTTPRequest = r
    69  
    70  	rClassName, rhkClassName, _ := route.Params.GetOK("className")
    71  	if err := o.bindClassName(rClassName, rhkClassName, route.Formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if runtime.HasBody(r) {
    76  		defer r.Body.Close()
    77  		var body models.Class
    78  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    79  			if err == io.EOF {
    80  				res = append(res, errors.Required("objectClass", "body", ""))
    81  			} else {
    82  				res = append(res, errors.NewParseError("objectClass", "body", "", err))
    83  			}
    84  		} else {
    85  			// validate body object
    86  			if err := body.Validate(route.Formats); err != nil {
    87  				res = append(res, err)
    88  			}
    89  
    90  			ctx := validate.WithOperationRequest(r.Context())
    91  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    92  				res = append(res, err)
    93  			}
    94  
    95  			if len(res) == 0 {
    96  				o.ObjectClass = &body
    97  			}
    98  		}
    99  	} else {
   100  		res = append(res, errors.Required("objectClass", "body", ""))
   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 *SchemaObjectsUpdateParams) 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  }