github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_get_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  
    29  // NewObjectsGetParams creates a new ObjectsGetParams object
    30  //
    31  // There are no default values defined in the spec.
    32  func NewObjectsGetParams() ObjectsGetParams {
    33  
    34  	return ObjectsGetParams{}
    35  }
    36  
    37  // ObjectsGetParams contains all the bound params for the objects get operation
    38  // typically these are obtained from a http.Request
    39  //
    40  // swagger:parameters objects.get
    41  type ObjectsGetParams struct {
    42  
    43  	// HTTP Request Object
    44  	HTTPRequest *http.Request `json:"-"`
    45  
    46  	/*Unique ID of the Object.
    47  	  Required: true
    48  	  In: path
    49  	*/
    50  	ID strfmt.UUID
    51  	/*Include additional information, such as classification infos. Allowed values include: classification, vector, interpretation
    52  	  In: query
    53  	*/
    54  	Include *string
    55  }
    56  
    57  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    58  // for simple values it will use straight method calls.
    59  //
    60  // To ensure default values, the struct must have been initialized with NewObjectsGetParams() beforehand.
    61  func (o *ObjectsGetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    62  	var res []error
    63  
    64  	o.HTTPRequest = r
    65  
    66  	qs := runtime.Values(r.URL.Query())
    67  
    68  	rID, rhkID, _ := route.Params.GetOK("id")
    69  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	qInclude, qhkInclude, _ := qs.GetOK("include")
    74  	if err := o.bindInclude(qInclude, qhkInclude, route.Formats); err != nil {
    75  		res = append(res, err)
    76  	}
    77  	if len(res) > 0 {
    78  		return errors.CompositeValidationError(res...)
    79  	}
    80  	return nil
    81  }
    82  
    83  // bindID binds and validates parameter ID from path.
    84  func (o *ObjectsGetParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    85  	var raw string
    86  	if len(rawData) > 0 {
    87  		raw = rawData[len(rawData)-1]
    88  	}
    89  
    90  	// Required: true
    91  	// Parameter is provided by construction from the route
    92  
    93  	// Format: uuid
    94  	value, err := formats.Parse("uuid", raw)
    95  	if err != nil {
    96  		return errors.InvalidType("id", "path", "strfmt.UUID", raw)
    97  	}
    98  	o.ID = *(value.(*strfmt.UUID))
    99  
   100  	if err := o.validateID(formats); err != nil {
   101  		return err
   102  	}
   103  
   104  	return nil
   105  }
   106  
   107  // validateID carries on validations for parameter ID
   108  func (o *ObjectsGetParams) validateID(formats strfmt.Registry) error {
   109  
   110  	if err := validate.FormatOf("id", "path", "uuid", o.ID.String(), formats); err != nil {
   111  		return err
   112  	}
   113  	return nil
   114  }
   115  
   116  // bindInclude binds and validates parameter Include from query.
   117  func (o *ObjectsGetParams) bindInclude(rawData []string, hasKey bool, formats strfmt.Registry) error {
   118  	var raw string
   119  	if len(rawData) > 0 {
   120  		raw = rawData[len(rawData)-1]
   121  	}
   122  
   123  	// Required: false
   124  	// AllowEmptyValue: false
   125  
   126  	if raw == "" { // empty values pass all other validations
   127  		return nil
   128  	}
   129  	o.Include = &raw
   130  
   131  	return nil
   132  }