github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/schema/tenants_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 schema
    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  
    28  	"github.com/weaviate/weaviate/entities/models"
    29  )
    30  
    31  // NewTenantsUpdateParams creates a new TenantsUpdateParams object
    32  //
    33  // There are no default values defined in the spec.
    34  func NewTenantsUpdateParams() TenantsUpdateParams {
    35  
    36  	return TenantsUpdateParams{}
    37  }
    38  
    39  // TenantsUpdateParams contains all the bound params for the tenants update operation
    40  // typically these are obtained from a http.Request
    41  //
    42  // swagger:parameters tenants.update
    43  type TenantsUpdateParams struct {
    44  
    45  	// HTTP Request Object
    46  	HTTPRequest *http.Request `json:"-"`
    47  
    48  	/*
    49  	  Required: true
    50  	  In: body
    51  	*/
    52  	Body []*models.Tenant
    53  	/*
    54  	  Required: true
    55  	  In: path
    56  	*/
    57  	ClassName string
    58  }
    59  
    60  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    61  // for simple values it will use straight method calls.
    62  //
    63  // To ensure default values, the struct must have been initialized with NewTenantsUpdateParams() beforehand.
    64  func (o *TenantsUpdateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    65  	var res []error
    66  
    67  	o.HTTPRequest = r
    68  
    69  	if runtime.HasBody(r) {
    70  		defer r.Body.Close()
    71  		var body []*models.Tenant
    72  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    73  			if err == io.EOF {
    74  				res = append(res, errors.Required("body", "body", ""))
    75  			} else {
    76  				res = append(res, errors.NewParseError("body", "body", "", err))
    77  			}
    78  		} else {
    79  
    80  			// validate array of body objects
    81  			for i := range body {
    82  				if body[i] == nil {
    83  					continue
    84  				}
    85  				if err := body[i].Validate(route.Formats); err != nil {
    86  					res = append(res, err)
    87  					break
    88  				}
    89  			}
    90  
    91  			if len(res) == 0 {
    92  				o.Body = body
    93  			}
    94  		}
    95  	} else {
    96  		res = append(res, errors.Required("body", "body", ""))
    97  	}
    98  
    99  	rClassName, rhkClassName, _ := route.Params.GetOK("className")
   100  	if err := o.bindClassName(rClassName, rhkClassName, route.Formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  	if len(res) > 0 {
   104  		return errors.CompositeValidationError(res...)
   105  	}
   106  	return nil
   107  }
   108  
   109  // bindClassName binds and validates parameter ClassName from path.
   110  func (o *TenantsUpdateParams) bindClassName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   111  	var raw string
   112  	if len(rawData) > 0 {
   113  		raw = rawData[len(rawData)-1]
   114  	}
   115  
   116  	// Required: true
   117  	// Parameter is provided by construction from the route
   118  	o.ClassName = raw
   119  
   120  	return nil
   121  }