github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/batch/batch_objects_delete_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 batch
    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  // NewBatchObjectsDeleteParams creates a new BatchObjectsDeleteParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewBatchObjectsDeleteParams() BatchObjectsDeleteParams {
    36  
    37  	return BatchObjectsDeleteParams{}
    38  }
    39  
    40  // BatchObjectsDeleteParams contains all the bound params for the batch objects delete operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters batch.objects.delete
    44  type BatchObjectsDeleteParams struct {
    45  
    46  	// HTTP Request Object
    47  	HTTPRequest *http.Request `json:"-"`
    48  
    49  	/*
    50  	  Required: true
    51  	  In: body
    52  	*/
    53  	Body *models.BatchDelete
    54  	/*Determines how many replicas must acknowledge a request before it is considered successful
    55  	  In: query
    56  	*/
    57  	ConsistencyLevel *string
    58  	/*Specifies the tenant in a request targeting a multi-tenant class
    59  	  In: query
    60  	*/
    61  	Tenant *string
    62  }
    63  
    64  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    65  // for simple values it will use straight method calls.
    66  //
    67  // To ensure default values, the struct must have been initialized with NewBatchObjectsDeleteParams() beforehand.
    68  func (o *BatchObjectsDeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    69  	var res []error
    70  
    71  	o.HTTPRequest = r
    72  
    73  	qs := runtime.Values(r.URL.Query())
    74  
    75  	if runtime.HasBody(r) {
    76  		defer r.Body.Close()
    77  		var body models.BatchDelete
    78  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    79  			if err == io.EOF {
    80  				res = append(res, errors.Required("body", "body", ""))
    81  			} else {
    82  				res = append(res, errors.NewParseError("body", "body", "", err))
    83  			}
    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  	} else {
   100  		res = append(res, errors.Required("body", "body", ""))
   101  	}
   102  
   103  	qConsistencyLevel, qhkConsistencyLevel, _ := qs.GetOK("consistency_level")
   104  	if err := o.bindConsistencyLevel(qConsistencyLevel, qhkConsistencyLevel, route.Formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	qTenant, qhkTenant, _ := qs.GetOK("tenant")
   109  	if err := o.bindTenant(qTenant, qhkTenant, route.Formats); err != nil {
   110  		res = append(res, err)
   111  	}
   112  	if len(res) > 0 {
   113  		return errors.CompositeValidationError(res...)
   114  	}
   115  	return nil
   116  }
   117  
   118  // bindConsistencyLevel binds and validates parameter ConsistencyLevel from query.
   119  func (o *BatchObjectsDeleteParams) bindConsistencyLevel(rawData []string, hasKey bool, formats strfmt.Registry) error {
   120  	var raw string
   121  	if len(rawData) > 0 {
   122  		raw = rawData[len(rawData)-1]
   123  	}
   124  
   125  	// Required: false
   126  	// AllowEmptyValue: false
   127  
   128  	if raw == "" { // empty values pass all other validations
   129  		return nil
   130  	}
   131  	o.ConsistencyLevel = &raw
   132  
   133  	return nil
   134  }
   135  
   136  // bindTenant binds and validates parameter Tenant from query.
   137  func (o *BatchObjectsDeleteParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
   138  	var raw string
   139  	if len(rawData) > 0 {
   140  		raw = rawData[len(rawData)-1]
   141  	}
   142  
   143  	// Required: false
   144  	// AllowEmptyValue: false
   145  
   146  	if raw == "" { // empty values pass all other validations
   147  		return nil
   148  	}
   149  	o.Tenant = &raw
   150  
   151  	return nil
   152  }