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