github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/schema/schema_objects_shards_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  	"github.com/go-openapi/validate"
    28  
    29  	"github.com/weaviate/weaviate/entities/models"
    30  )
    31  
    32  // NewSchemaObjectsShardsUpdateParams creates a new SchemaObjectsShardsUpdateParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewSchemaObjectsShardsUpdateParams() SchemaObjectsShardsUpdateParams {
    36  
    37  	return SchemaObjectsShardsUpdateParams{}
    38  }
    39  
    40  // SchemaObjectsShardsUpdateParams contains all the bound params for the schema objects shards update operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters schema.objects.shards.update
    44  type SchemaObjectsShardsUpdateParams struct {
    45  
    46  	// HTTP Request Object
    47  	HTTPRequest *http.Request `json:"-"`
    48  
    49  	/*
    50  	  Required: true
    51  	  In: body
    52  	*/
    53  	Body *models.ShardStatus
    54  	/*
    55  	  Required: true
    56  	  In: path
    57  	*/
    58  	ClassName string
    59  	/*
    60  	  Required: true
    61  	  In: path
    62  	*/
    63  	ShardName string
    64  }
    65  
    66  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    67  // for simple values it will use straight method calls.
    68  //
    69  // To ensure default values, the struct must have been initialized with NewSchemaObjectsShardsUpdateParams() beforehand.
    70  func (o *SchemaObjectsShardsUpdateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    71  	var res []error
    72  
    73  	o.HTTPRequest = r
    74  
    75  	if runtime.HasBody(r) {
    76  		defer r.Body.Close()
    77  		var body models.ShardStatus
    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  	rClassName, rhkClassName, _ := route.Params.GetOK("className")
   104  	if err := o.bindClassName(rClassName, rhkClassName, route.Formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	rShardName, rhkShardName, _ := route.Params.GetOK("shardName")
   109  	if err := o.bindShardName(rShardName, rhkShardName, 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  // bindClassName binds and validates parameter ClassName from path.
   119  func (o *SchemaObjectsShardsUpdateParams) bindClassName(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: true
   126  	// Parameter is provided by construction from the route
   127  	o.ClassName = raw
   128  
   129  	return nil
   130  }
   131  
   132  // bindShardName binds and validates parameter ShardName from path.
   133  func (o *SchemaObjectsShardsUpdateParams) bindShardName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   134  	var raw string
   135  	if len(rawData) > 0 {
   136  		raw = rawData[len(rawData)-1]
   137  	}
   138  
   139  	// Required: true
   140  	// Parameter is provided by construction from the route
   141  	o.ShardName = raw
   142  
   143  	return nil
   144  }