github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_list_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/swag"
    27  )
    28  
    29  // NewObjectsListParams creates a new ObjectsListParams object
    30  // with the default values initialized.
    31  func NewObjectsListParams() ObjectsListParams {
    32  
    33  	var (
    34  		// initialize parameters with default values
    35  
    36  		offsetDefault = int64(0)
    37  	)
    38  
    39  	return ObjectsListParams{
    40  		Offset: &offsetDefault,
    41  	}
    42  }
    43  
    44  // ObjectsListParams contains all the bound params for the objects list operation
    45  // typically these are obtained from a http.Request
    46  //
    47  // swagger:parameters objects.list
    48  type ObjectsListParams struct {
    49  
    50  	// HTTP Request Object
    51  	HTTPRequest *http.Request `json:"-"`
    52  
    53  	/*The starting ID of the result window.
    54  	  In: query
    55  	*/
    56  	After *string
    57  	/*Class parameter specifies the class from which to query objects
    58  	  In: query
    59  	*/
    60  	Class *string
    61  	/*Include additional information, such as classification infos. Allowed values include: classification, vector, interpretation
    62  	  In: query
    63  	*/
    64  	Include *string
    65  	/*The maximum number of items to be returned per page. Default value is set in Weaviate config.
    66  	  In: query
    67  	*/
    68  	Limit *int64
    69  	/*The starting index of the result window. Default value is 0.
    70  	  In: query
    71  	  Default: 0
    72  	*/
    73  	Offset *int64
    74  	/*Order parameter to tell how to order (asc or desc) data within given field
    75  	  In: query
    76  	*/
    77  	Order *string
    78  	/*Sort parameter to pass an information about the names of the sort fields
    79  	  In: query
    80  	*/
    81  	Sort *string
    82  	/*Specifies the tenant in a request targeting a multi-tenant class
    83  	  In: query
    84  	*/
    85  	Tenant *string
    86  }
    87  
    88  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    89  // for simple values it will use straight method calls.
    90  //
    91  // To ensure default values, the struct must have been initialized with NewObjectsListParams() beforehand.
    92  func (o *ObjectsListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    93  	var res []error
    94  
    95  	o.HTTPRequest = r
    96  
    97  	qs := runtime.Values(r.URL.Query())
    98  
    99  	qAfter, qhkAfter, _ := qs.GetOK("after")
   100  	if err := o.bindAfter(qAfter, qhkAfter, route.Formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	qClass, qhkClass, _ := qs.GetOK("class")
   105  	if err := o.bindClass(qClass, qhkClass, route.Formats); err != nil {
   106  		res = append(res, err)
   107  	}
   108  
   109  	qInclude, qhkInclude, _ := qs.GetOK("include")
   110  	if err := o.bindInclude(qInclude, qhkInclude, route.Formats); err != nil {
   111  		res = append(res, err)
   112  	}
   113  
   114  	qLimit, qhkLimit, _ := qs.GetOK("limit")
   115  	if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	qOffset, qhkOffset, _ := qs.GetOK("offset")
   120  	if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	qOrder, qhkOrder, _ := qs.GetOK("order")
   125  	if err := o.bindOrder(qOrder, qhkOrder, route.Formats); err != nil {
   126  		res = append(res, err)
   127  	}
   128  
   129  	qSort, qhkSort, _ := qs.GetOK("sort")
   130  	if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil {
   131  		res = append(res, err)
   132  	}
   133  
   134  	qTenant, qhkTenant, _ := qs.GetOK("tenant")
   135  	if err := o.bindTenant(qTenant, qhkTenant, route.Formats); err != nil {
   136  		res = append(res, err)
   137  	}
   138  	if len(res) > 0 {
   139  		return errors.CompositeValidationError(res...)
   140  	}
   141  	return nil
   142  }
   143  
   144  // bindAfter binds and validates parameter After from query.
   145  func (o *ObjectsListParams) bindAfter(rawData []string, hasKey bool, formats strfmt.Registry) error {
   146  	var raw string
   147  	if len(rawData) > 0 {
   148  		raw = rawData[len(rawData)-1]
   149  	}
   150  
   151  	// Required: false
   152  	// AllowEmptyValue: false
   153  
   154  	if raw == "" { // empty values pass all other validations
   155  		return nil
   156  	}
   157  	o.After = &raw
   158  
   159  	return nil
   160  }
   161  
   162  // bindClass binds and validates parameter Class from query.
   163  func (o *ObjectsListParams) bindClass(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.Class = &raw
   176  
   177  	return nil
   178  }
   179  
   180  // bindInclude binds and validates parameter Include from query.
   181  func (o *ObjectsListParams) bindInclude(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: false
   188  	// AllowEmptyValue: false
   189  
   190  	if raw == "" { // empty values pass all other validations
   191  		return nil
   192  	}
   193  	o.Include = &raw
   194  
   195  	return nil
   196  }
   197  
   198  // bindLimit binds and validates parameter Limit from query.
   199  func (o *ObjectsListParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error {
   200  	var raw string
   201  	if len(rawData) > 0 {
   202  		raw = rawData[len(rawData)-1]
   203  	}
   204  
   205  	// Required: false
   206  	// AllowEmptyValue: false
   207  
   208  	if raw == "" { // empty values pass all other validations
   209  		return nil
   210  	}
   211  
   212  	value, err := swag.ConvertInt64(raw)
   213  	if err != nil {
   214  		return errors.InvalidType("limit", "query", "int64", raw)
   215  	}
   216  	o.Limit = &value
   217  
   218  	return nil
   219  }
   220  
   221  // bindOffset binds and validates parameter Offset from query.
   222  func (o *ObjectsListParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error {
   223  	var raw string
   224  	if len(rawData) > 0 {
   225  		raw = rawData[len(rawData)-1]
   226  	}
   227  
   228  	// Required: false
   229  	// AllowEmptyValue: false
   230  
   231  	if raw == "" { // empty values pass all other validations
   232  		// Default values have been previously initialized by NewObjectsListParams()
   233  		return nil
   234  	}
   235  
   236  	value, err := swag.ConvertInt64(raw)
   237  	if err != nil {
   238  		return errors.InvalidType("offset", "query", "int64", raw)
   239  	}
   240  	o.Offset = &value
   241  
   242  	return nil
   243  }
   244  
   245  // bindOrder binds and validates parameter Order from query.
   246  func (o *ObjectsListParams) bindOrder(rawData []string, hasKey bool, formats strfmt.Registry) error {
   247  	var raw string
   248  	if len(rawData) > 0 {
   249  		raw = rawData[len(rawData)-1]
   250  	}
   251  
   252  	// Required: false
   253  	// AllowEmptyValue: false
   254  
   255  	if raw == "" { // empty values pass all other validations
   256  		return nil
   257  	}
   258  	o.Order = &raw
   259  
   260  	return nil
   261  }
   262  
   263  // bindSort binds and validates parameter Sort from query.
   264  func (o *ObjectsListParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error {
   265  	var raw string
   266  	if len(rawData) > 0 {
   267  		raw = rawData[len(rawData)-1]
   268  	}
   269  
   270  	// Required: false
   271  	// AllowEmptyValue: false
   272  
   273  	if raw == "" { // empty values pass all other validations
   274  		return nil
   275  	}
   276  	o.Sort = &raw
   277  
   278  	return nil
   279  }
   280  
   281  // bindTenant binds and validates parameter Tenant from query.
   282  func (o *ObjectsListParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
   283  	var raw string
   284  	if len(rawData) > 0 {
   285  		raw = rawData[len(rawData)-1]
   286  	}
   287  
   288  	// Required: false
   289  	// AllowEmptyValue: false
   290  
   291  	if raw == "" { // empty values pass all other validations
   292  		return nil
   293  	}
   294  	o.Tenant = &raw
   295  
   296  	return nil
   297  }