github.com/minio/console@v1.4.1/api/operations/bucket/set_bucket_quota_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package bucket
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the swagger generate command
    24  
    25  import (
    26  	"io"
    27  	"net/http"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/runtime"
    31  	"github.com/go-openapi/runtime/middleware"
    32  	"github.com/go-openapi/strfmt"
    33  	"github.com/go-openapi/validate"
    34  
    35  	"github.com/minio/console/models"
    36  )
    37  
    38  // NewSetBucketQuotaParams creates a new SetBucketQuotaParams object
    39  //
    40  // There are no default values defined in the spec.
    41  func NewSetBucketQuotaParams() SetBucketQuotaParams {
    42  
    43  	return SetBucketQuotaParams{}
    44  }
    45  
    46  // SetBucketQuotaParams contains all the bound params for the set bucket quota operation
    47  // typically these are obtained from a http.Request
    48  //
    49  // swagger:parameters SetBucketQuota
    50  type SetBucketQuotaParams struct {
    51  
    52  	// HTTP Request Object
    53  	HTTPRequest *http.Request `json:"-"`
    54  
    55  	/*
    56  	  Required: true
    57  	  In: body
    58  	*/
    59  	Body *models.SetBucketQuota
    60  	/*
    61  	  Required: true
    62  	  In: path
    63  	*/
    64  	Name string
    65  }
    66  
    67  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    68  // for simple values it will use straight method calls.
    69  //
    70  // To ensure default values, the struct must have been initialized with NewSetBucketQuotaParams() beforehand.
    71  func (o *SetBucketQuotaParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    72  	var res []error
    73  
    74  	o.HTTPRequest = r
    75  
    76  	if runtime.HasBody(r) {
    77  		defer r.Body.Close()
    78  		var body models.SetBucketQuota
    79  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    80  			if err == io.EOF {
    81  				res = append(res, errors.Required("body", "body", ""))
    82  			} else {
    83  				res = append(res, errors.NewParseError("body", "body", "", err))
    84  			}
    85  		} else {
    86  			// validate body object
    87  			if err := body.Validate(route.Formats); err != nil {
    88  				res = append(res, err)
    89  			}
    90  
    91  			ctx := validate.WithOperationRequest(r.Context())
    92  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    93  				res = append(res, err)
    94  			}
    95  
    96  			if len(res) == 0 {
    97  				o.Body = &body
    98  			}
    99  		}
   100  	} else {
   101  		res = append(res, errors.Required("body", "body", ""))
   102  	}
   103  
   104  	rName, rhkName, _ := route.Params.GetOK("name")
   105  	if err := o.bindName(rName, rhkName, route.Formats); err != nil {
   106  		res = append(res, err)
   107  	}
   108  	if len(res) > 0 {
   109  		return errors.CompositeValidationError(res...)
   110  	}
   111  	return nil
   112  }
   113  
   114  // bindName binds and validates parameter Name from path.
   115  func (o *SetBucketQuotaParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   116  	var raw string
   117  	if len(rawData) > 0 {
   118  		raw = rawData[len(rawData)-1]
   119  	}
   120  
   121  	// Required: true
   122  	// Parameter is provided by construction from the route
   123  	o.Name = raw
   124  
   125  	return nil
   126  }