github.com/minio/console@v1.4.1/api/operations/object/get_object_metadata_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  	"net/http"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/runtime"
    30  	"github.com/go-openapi/runtime/middleware"
    31  	"github.com/go-openapi/strfmt"
    32  	"github.com/go-openapi/validate"
    33  )
    34  
    35  // NewGetObjectMetadataParams creates a new GetObjectMetadataParams object
    36  //
    37  // There are no default values defined in the spec.
    38  func NewGetObjectMetadataParams() GetObjectMetadataParams {
    39  
    40  	return GetObjectMetadataParams{}
    41  }
    42  
    43  // GetObjectMetadataParams contains all the bound params for the get object metadata operation
    44  // typically these are obtained from a http.Request
    45  //
    46  // swagger:parameters GetObjectMetadata
    47  type GetObjectMetadataParams struct {
    48  
    49  	// HTTP Request Object
    50  	HTTPRequest *http.Request `json:"-"`
    51  
    52  	/*
    53  	  Required: true
    54  	  In: path
    55  	*/
    56  	BucketName string
    57  	/*
    58  	  Required: true
    59  	  In: query
    60  	*/
    61  	Prefix string
    62  	/*
    63  	  In: query
    64  	*/
    65  	VersionID *string
    66  }
    67  
    68  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    69  // for simple values it will use straight method calls.
    70  //
    71  // To ensure default values, the struct must have been initialized with NewGetObjectMetadataParams() beforehand.
    72  func (o *GetObjectMetadataParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    73  	var res []error
    74  
    75  	o.HTTPRequest = r
    76  
    77  	qs := runtime.Values(r.URL.Query())
    78  
    79  	rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
    80  	if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
    81  		res = append(res, err)
    82  	}
    83  
    84  	qPrefix, qhkPrefix, _ := qs.GetOK("prefix")
    85  	if err := o.bindPrefix(qPrefix, qhkPrefix, route.Formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	qVersionID, qhkVersionID, _ := qs.GetOK("versionID")
    90  	if err := o.bindVersionID(qVersionID, qhkVersionID, route.Formats); err != nil {
    91  		res = append(res, err)
    92  	}
    93  	if len(res) > 0 {
    94  		return errors.CompositeValidationError(res...)
    95  	}
    96  	return nil
    97  }
    98  
    99  // bindBucketName binds and validates parameter BucketName from path.
   100  func (o *GetObjectMetadataParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   101  	var raw string
   102  	if len(rawData) > 0 {
   103  		raw = rawData[len(rawData)-1]
   104  	}
   105  
   106  	// Required: true
   107  	// Parameter is provided by construction from the route
   108  	o.BucketName = raw
   109  
   110  	return nil
   111  }
   112  
   113  // bindPrefix binds and validates parameter Prefix from query.
   114  func (o *GetObjectMetadataParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error {
   115  	if !hasKey {
   116  		return errors.Required("prefix", "query", rawData)
   117  	}
   118  	var raw string
   119  	if len(rawData) > 0 {
   120  		raw = rawData[len(rawData)-1]
   121  	}
   122  
   123  	// Required: true
   124  	// AllowEmptyValue: false
   125  
   126  	if err := validate.RequiredString("prefix", "query", raw); err != nil {
   127  		return err
   128  	}
   129  	o.Prefix = raw
   130  
   131  	return nil
   132  }
   133  
   134  // bindVersionID binds and validates parameter VersionID from query.
   135  func (o *GetObjectMetadataParams) bindVersionID(rawData []string, hasKey bool, formats strfmt.Registry) error {
   136  	var raw string
   137  	if len(rawData) > 0 {
   138  		raw = rawData[len(rawData)-1]
   139  	}
   140  
   141  	// Required: false
   142  	// AllowEmptyValue: false
   143  
   144  	if raw == "" { // empty values pass all other validations
   145  		return nil
   146  	}
   147  	o.VersionID = &raw
   148  
   149  	return nil
   150  }