github.com/minio/console@v1.4.1/api/operations/object/put_object_legal_hold_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 object
    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  // NewPutObjectLegalHoldParams creates a new PutObjectLegalHoldParams object
    39  //
    40  // There are no default values defined in the spec.
    41  func NewPutObjectLegalHoldParams() PutObjectLegalHoldParams {
    42  
    43  	return PutObjectLegalHoldParams{}
    44  }
    45  
    46  // PutObjectLegalHoldParams contains all the bound params for the put object legal hold operation
    47  // typically these are obtained from a http.Request
    48  //
    49  // swagger:parameters PutObjectLegalHold
    50  type PutObjectLegalHoldParams struct {
    51  
    52  	// HTTP Request Object
    53  	HTTPRequest *http.Request `json:"-"`
    54  
    55  	/*
    56  	  Required: true
    57  	  In: body
    58  	*/
    59  	Body *models.PutObjectLegalHoldRequest
    60  	/*
    61  	  Required: true
    62  	  In: path
    63  	*/
    64  	BucketName string
    65  	/*
    66  	  Required: true
    67  	  In: query
    68  	*/
    69  	Prefix string
    70  	/*
    71  	  Required: true
    72  	  In: query
    73  	*/
    74  	VersionID string
    75  }
    76  
    77  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    78  // for simple values it will use straight method calls.
    79  //
    80  // To ensure default values, the struct must have been initialized with NewPutObjectLegalHoldParams() beforehand.
    81  func (o *PutObjectLegalHoldParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    82  	var res []error
    83  
    84  	o.HTTPRequest = r
    85  
    86  	qs := runtime.Values(r.URL.Query())
    87  
    88  	if runtime.HasBody(r) {
    89  		defer r.Body.Close()
    90  		var body models.PutObjectLegalHoldRequest
    91  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    92  			if err == io.EOF {
    93  				res = append(res, errors.Required("body", "body", ""))
    94  			} else {
    95  				res = append(res, errors.NewParseError("body", "body", "", err))
    96  			}
    97  		} else {
    98  			// validate body object
    99  			if err := body.Validate(route.Formats); err != nil {
   100  				res = append(res, err)
   101  			}
   102  
   103  			ctx := validate.WithOperationRequest(r.Context())
   104  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
   105  				res = append(res, err)
   106  			}
   107  
   108  			if len(res) == 0 {
   109  				o.Body = &body
   110  			}
   111  		}
   112  	} else {
   113  		res = append(res, errors.Required("body", "body", ""))
   114  	}
   115  
   116  	rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
   117  	if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
   118  		res = append(res, err)
   119  	}
   120  
   121  	qPrefix, qhkPrefix, _ := qs.GetOK("prefix")
   122  	if err := o.bindPrefix(qPrefix, qhkPrefix, route.Formats); err != nil {
   123  		res = append(res, err)
   124  	}
   125  
   126  	qVersionID, qhkVersionID, _ := qs.GetOK("version_id")
   127  	if err := o.bindVersionID(qVersionID, qhkVersionID, route.Formats); err != nil {
   128  		res = append(res, err)
   129  	}
   130  	if len(res) > 0 {
   131  		return errors.CompositeValidationError(res...)
   132  	}
   133  	return nil
   134  }
   135  
   136  // bindBucketName binds and validates parameter BucketName from path.
   137  func (o *PutObjectLegalHoldParams) bindBucketName(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: true
   144  	// Parameter is provided by construction from the route
   145  	o.BucketName = raw
   146  
   147  	return nil
   148  }
   149  
   150  // bindPrefix binds and validates parameter Prefix from query.
   151  func (o *PutObjectLegalHoldParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error {
   152  	if !hasKey {
   153  		return errors.Required("prefix", "query", rawData)
   154  	}
   155  	var raw string
   156  	if len(rawData) > 0 {
   157  		raw = rawData[len(rawData)-1]
   158  	}
   159  
   160  	// Required: true
   161  	// AllowEmptyValue: false
   162  
   163  	if err := validate.RequiredString("prefix", "query", raw); err != nil {
   164  		return err
   165  	}
   166  	o.Prefix = raw
   167  
   168  	return nil
   169  }
   170  
   171  // bindVersionID binds and validates parameter VersionID from query.
   172  func (o *PutObjectLegalHoldParams) bindVersionID(rawData []string, hasKey bool, formats strfmt.Registry) error {
   173  	if !hasKey {
   174  		return errors.Required("version_id", "query", rawData)
   175  	}
   176  	var raw string
   177  	if len(rawData) > 0 {
   178  		raw = rawData[len(rawData)-1]
   179  	}
   180  
   181  	// Required: true
   182  	// AllowEmptyValue: false
   183  
   184  	if err := validate.RequiredString("version_id", "query", raw); err != nil {
   185  		return err
   186  	}
   187  	o.VersionID = raw
   188  
   189  	return nil
   190  }