github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_references_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 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  // NewObjectsReferencesUpdateParams creates a new ObjectsReferencesUpdateParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewObjectsReferencesUpdateParams() ObjectsReferencesUpdateParams {
    36  
    37  	return ObjectsReferencesUpdateParams{}
    38  }
    39  
    40  // ObjectsReferencesUpdateParams contains all the bound params for the objects references update operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters objects.references.update
    44  type ObjectsReferencesUpdateParams 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  	/*Unique ID of the Object.
    55  	  Required: true
    56  	  In: path
    57  	*/
    58  	ID strfmt.UUID
    59  	/*Unique name of the property related to the Object.
    60  	  Required: true
    61  	  In: path
    62  	*/
    63  	PropertyName string
    64  	/*Specifies the tenant in a request targeting a multi-tenant class
    65  	  In: query
    66  	*/
    67  	Tenant *string
    68  }
    69  
    70  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    71  // for simple values it will use straight method calls.
    72  //
    73  // To ensure default values, the struct must have been initialized with NewObjectsReferencesUpdateParams() beforehand.
    74  func (o *ObjectsReferencesUpdateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    75  	var res []error
    76  
    77  	o.HTTPRequest = r
    78  
    79  	qs := runtime.Values(r.URL.Query())
    80  
    81  	if runtime.HasBody(r) {
    82  		defer r.Body.Close()
    83  		var body models.MultipleRef
    84  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    85  			if err == io.EOF {
    86  				res = append(res, errors.Required("body", "body", ""))
    87  			} else {
    88  				res = append(res, errors.NewParseError("body", "body", "", err))
    89  			}
    90  		} else {
    91  			// validate body object
    92  			if err := body.Validate(route.Formats); err != nil {
    93  				res = append(res, err)
    94  			}
    95  
    96  			ctx := validate.WithOperationRequest(r.Context())
    97  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    98  				res = append(res, err)
    99  			}
   100  
   101  			if len(res) == 0 {
   102  				o.Body = body
   103  			}
   104  		}
   105  	} else {
   106  		res = append(res, errors.Required("body", "body", ""))
   107  	}
   108  
   109  	rID, rhkID, _ := route.Params.GetOK("id")
   110  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
   111  		res = append(res, err)
   112  	}
   113  
   114  	rPropertyName, rhkPropertyName, _ := route.Params.GetOK("propertyName")
   115  	if err := o.bindPropertyName(rPropertyName, rhkPropertyName, route.Formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	qTenant, qhkTenant, _ := qs.GetOK("tenant")
   120  	if err := o.bindTenant(qTenant, qhkTenant, route.Formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  	if len(res) > 0 {
   124  		return errors.CompositeValidationError(res...)
   125  	}
   126  	return nil
   127  }
   128  
   129  // bindID binds and validates parameter ID from path.
   130  func (o *ObjectsReferencesUpdateParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
   131  	var raw string
   132  	if len(rawData) > 0 {
   133  		raw = rawData[len(rawData)-1]
   134  	}
   135  
   136  	// Required: true
   137  	// Parameter is provided by construction from the route
   138  
   139  	// Format: uuid
   140  	value, err := formats.Parse("uuid", raw)
   141  	if err != nil {
   142  		return errors.InvalidType("id", "path", "strfmt.UUID", raw)
   143  	}
   144  	o.ID = *(value.(*strfmt.UUID))
   145  
   146  	if err := o.validateID(formats); err != nil {
   147  		return err
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  // validateID carries on validations for parameter ID
   154  func (o *ObjectsReferencesUpdateParams) validateID(formats strfmt.Registry) error {
   155  
   156  	if err := validate.FormatOf("id", "path", "uuid", o.ID.String(), formats); err != nil {
   157  		return err
   158  	}
   159  	return nil
   160  }
   161  
   162  // bindPropertyName binds and validates parameter PropertyName from path.
   163  func (o *ObjectsReferencesUpdateParams) bindPropertyName(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: true
   170  	// Parameter is provided by construction from the route
   171  	o.PropertyName = raw
   172  
   173  	return nil
   174  }
   175  
   176  // bindTenant binds and validates parameter Tenant from query.
   177  func (o *ObjectsReferencesUpdateParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
   178  	var raw string
   179  	if len(rawData) > 0 {
   180  		raw = rawData[len(rawData)-1]
   181  	}
   182  
   183  	// Required: false
   184  	// AllowEmptyValue: false
   185  
   186  	if raw == "" { // empty values pass all other validations
   187  		return nil
   188  	}
   189  	o.Tenant = &raw
   190  
   191  	return nil
   192  }