github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_class_references_put_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  // NewObjectsClassReferencesPutParams creates a new ObjectsClassReferencesPutParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewObjectsClassReferencesPutParams() ObjectsClassReferencesPutParams {
    36  
    37  	return ObjectsClassReferencesPutParams{}
    38  }
    39  
    40  // ObjectsClassReferencesPutParams contains all the bound params for the objects class references put operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters objects.class.references.put
    44  type ObjectsClassReferencesPutParams struct {
    45  
    46  	// HTTP Request Object
    47  	HTTPRequest *http.Request `json:"-"`
    48  
    49  	/*
    50  	  Required: true
    51  	  In: body
    52  	*/
    53  	Body models.MultipleRef
    54  	/*The class name as defined in the schema
    55  	  Required: true
    56  	  In: path
    57  	*/
    58  	ClassName string
    59  	/*Determines how many replicas must acknowledge a request before it is considered successful
    60  	  In: query
    61  	*/
    62  	ConsistencyLevel *string
    63  	/*Unique ID of the Object.
    64  	  Required: true
    65  	  In: path
    66  	*/
    67  	ID strfmt.UUID
    68  	/*Unique name of the property related to the Object.
    69  	  Required: true
    70  	  In: path
    71  	*/
    72  	PropertyName string
    73  	/*Specifies the tenant in a request targeting a multi-tenant class
    74  	  In: query
    75  	*/
    76  	Tenant *string
    77  }
    78  
    79  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    80  // for simple values it will use straight method calls.
    81  //
    82  // To ensure default values, the struct must have been initialized with NewObjectsClassReferencesPutParams() beforehand.
    83  func (o *ObjectsClassReferencesPutParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    84  	var res []error
    85  
    86  	o.HTTPRequest = r
    87  
    88  	qs := runtime.Values(r.URL.Query())
    89  
    90  	if runtime.HasBody(r) {
    91  		defer r.Body.Close()
    92  		var body models.MultipleRef
    93  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    94  			if err == io.EOF {
    95  				res = append(res, errors.Required("body", "body", ""))
    96  			} else {
    97  				res = append(res, errors.NewParseError("body", "body", "", err))
    98  			}
    99  		} else {
   100  			// validate body object
   101  			if err := body.Validate(route.Formats); err != nil {
   102  				res = append(res, err)
   103  			}
   104  
   105  			ctx := validate.WithOperationRequest(r.Context())
   106  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
   107  				res = append(res, err)
   108  			}
   109  
   110  			if len(res) == 0 {
   111  				o.Body = body
   112  			}
   113  		}
   114  	} else {
   115  		res = append(res, errors.Required("body", "body", ""))
   116  	}
   117  
   118  	rClassName, rhkClassName, _ := route.Params.GetOK("className")
   119  	if err := o.bindClassName(rClassName, rhkClassName, route.Formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	qConsistencyLevel, qhkConsistencyLevel, _ := qs.GetOK("consistency_level")
   124  	if err := o.bindConsistencyLevel(qConsistencyLevel, qhkConsistencyLevel, route.Formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	rID, rhkID, _ := route.Params.GetOK("id")
   129  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
   130  		res = append(res, err)
   131  	}
   132  
   133  	rPropertyName, rhkPropertyName, _ := route.Params.GetOK("propertyName")
   134  	if err := o.bindPropertyName(rPropertyName, rhkPropertyName, route.Formats); err != nil {
   135  		res = append(res, err)
   136  	}
   137  
   138  	qTenant, qhkTenant, _ := qs.GetOK("tenant")
   139  	if err := o.bindTenant(qTenant, qhkTenant, route.Formats); err != nil {
   140  		res = append(res, err)
   141  	}
   142  	if len(res) > 0 {
   143  		return errors.CompositeValidationError(res...)
   144  	}
   145  	return nil
   146  }
   147  
   148  // bindClassName binds and validates parameter ClassName from path.
   149  func (o *ObjectsClassReferencesPutParams) bindClassName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   150  	var raw string
   151  	if len(rawData) > 0 {
   152  		raw = rawData[len(rawData)-1]
   153  	}
   154  
   155  	// Required: true
   156  	// Parameter is provided by construction from the route
   157  	o.ClassName = raw
   158  
   159  	return nil
   160  }
   161  
   162  // bindConsistencyLevel binds and validates parameter ConsistencyLevel from query.
   163  func (o *ObjectsClassReferencesPutParams) bindConsistencyLevel(rawData []string, hasKey bool, formats strfmt.Registry) error {
   164  	var raw string
   165  	if len(rawData) > 0 {
   166  		raw = rawData[len(rawData)-1]
   167  	}
   168  
   169  	// Required: false
   170  	// AllowEmptyValue: false
   171  
   172  	if raw == "" { // empty values pass all other validations
   173  		return nil
   174  	}
   175  	o.ConsistencyLevel = &raw
   176  
   177  	return nil
   178  }
   179  
   180  // bindID binds and validates parameter ID from path.
   181  func (o *ObjectsClassReferencesPutParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
   182  	var raw string
   183  	if len(rawData) > 0 {
   184  		raw = rawData[len(rawData)-1]
   185  	}
   186  
   187  	// Required: true
   188  	// Parameter is provided by construction from the route
   189  
   190  	// Format: uuid
   191  	value, err := formats.Parse("uuid", raw)
   192  	if err != nil {
   193  		return errors.InvalidType("id", "path", "strfmt.UUID", raw)
   194  	}
   195  	o.ID = *(value.(*strfmt.UUID))
   196  
   197  	if err := o.validateID(formats); err != nil {
   198  		return err
   199  	}
   200  
   201  	return nil
   202  }
   203  
   204  // validateID carries on validations for parameter ID
   205  func (o *ObjectsClassReferencesPutParams) validateID(formats strfmt.Registry) error {
   206  
   207  	if err := validate.FormatOf("id", "path", "uuid", o.ID.String(), formats); err != nil {
   208  		return err
   209  	}
   210  	return nil
   211  }
   212  
   213  // bindPropertyName binds and validates parameter PropertyName from path.
   214  func (o *ObjectsClassReferencesPutParams) bindPropertyName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   215  	var raw string
   216  	if len(rawData) > 0 {
   217  		raw = rawData[len(rawData)-1]
   218  	}
   219  
   220  	// Required: true
   221  	// Parameter is provided by construction from the route
   222  	o.PropertyName = raw
   223  
   224  	return nil
   225  }
   226  
   227  // bindTenant binds and validates parameter Tenant from query.
   228  func (o *ObjectsClassReferencesPutParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
   229  	var raw string
   230  	if len(rawData) > 0 {
   231  		raw = rawData[len(rawData)-1]
   232  	}
   233  
   234  	// Required: false
   235  	// AllowEmptyValue: false
   236  
   237  	if raw == "" { // empty values pass all other validations
   238  		return nil
   239  	}
   240  	o.Tenant = &raw
   241  
   242  	return nil
   243  }