github.com/minio/console@v1.4.1/api/operations/object/list_objects_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/swag"
    33  )
    34  
    35  // NewListObjectsParams creates a new ListObjectsParams object
    36  // with the default values initialized.
    37  func NewListObjectsParams() ListObjectsParams {
    38  
    39  	var (
    40  		// initialize parameters with default values
    41  
    42  		limitDefault = int32(20)
    43  	)
    44  
    45  	return ListObjectsParams{
    46  		Limit: &limitDefault,
    47  	}
    48  }
    49  
    50  // ListObjectsParams contains all the bound params for the list objects operation
    51  // typically these are obtained from a http.Request
    52  //
    53  // swagger:parameters ListObjects
    54  type ListObjectsParams struct {
    55  
    56  	// HTTP Request Object
    57  	HTTPRequest *http.Request `json:"-"`
    58  
    59  	/*
    60  	  Required: true
    61  	  In: path
    62  	*/
    63  	BucketName string
    64  	/*
    65  	  In: query
    66  	  Default: 20
    67  	*/
    68  	Limit *int32
    69  	/*
    70  	  In: query
    71  	*/
    72  	Prefix *string
    73  	/*
    74  	  In: query
    75  	*/
    76  	Recursive *bool
    77  	/*
    78  	  In: query
    79  	*/
    80  	WithMetadata *bool
    81  	/*
    82  	  In: query
    83  	*/
    84  	WithVersions *bool
    85  }
    86  
    87  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    88  // for simple values it will use straight method calls.
    89  //
    90  // To ensure default values, the struct must have been initialized with NewListObjectsParams() beforehand.
    91  func (o *ListObjectsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    92  	var res []error
    93  
    94  	o.HTTPRequest = r
    95  
    96  	qs := runtime.Values(r.URL.Query())
    97  
    98  	rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
    99  	if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
   100  		res = append(res, err)
   101  	}
   102  
   103  	qLimit, qhkLimit, _ := qs.GetOK("limit")
   104  	if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	qPrefix, qhkPrefix, _ := qs.GetOK("prefix")
   109  	if err := o.bindPrefix(qPrefix, qhkPrefix, route.Formats); err != nil {
   110  		res = append(res, err)
   111  	}
   112  
   113  	qRecursive, qhkRecursive, _ := qs.GetOK("recursive")
   114  	if err := o.bindRecursive(qRecursive, qhkRecursive, route.Formats); err != nil {
   115  		res = append(res, err)
   116  	}
   117  
   118  	qWithMetadata, qhkWithMetadata, _ := qs.GetOK("with_metadata")
   119  	if err := o.bindWithMetadata(qWithMetadata, qhkWithMetadata, route.Formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	qWithVersions, qhkWithVersions, _ := qs.GetOK("with_versions")
   124  	if err := o.bindWithVersions(qWithVersions, qhkWithVersions, route.Formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  	if len(res) > 0 {
   128  		return errors.CompositeValidationError(res...)
   129  	}
   130  	return nil
   131  }
   132  
   133  // bindBucketName binds and validates parameter BucketName from path.
   134  func (o *ListObjectsParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   135  	var raw string
   136  	if len(rawData) > 0 {
   137  		raw = rawData[len(rawData)-1]
   138  	}
   139  
   140  	// Required: true
   141  	// Parameter is provided by construction from the route
   142  	o.BucketName = raw
   143  
   144  	return nil
   145  }
   146  
   147  // bindLimit binds and validates parameter Limit from query.
   148  func (o *ListObjectsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error {
   149  	var raw string
   150  	if len(rawData) > 0 {
   151  		raw = rawData[len(rawData)-1]
   152  	}
   153  
   154  	// Required: false
   155  	// AllowEmptyValue: false
   156  
   157  	if raw == "" { // empty values pass all other validations
   158  		// Default values have been previously initialized by NewListObjectsParams()
   159  		return nil
   160  	}
   161  
   162  	value, err := swag.ConvertInt32(raw)
   163  	if err != nil {
   164  		return errors.InvalidType("limit", "query", "int32", raw)
   165  	}
   166  	o.Limit = &value
   167  
   168  	return nil
   169  }
   170  
   171  // bindPrefix binds and validates parameter Prefix from query.
   172  func (o *ListObjectsParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error {
   173  	var raw string
   174  	if len(rawData) > 0 {
   175  		raw = rawData[len(rawData)-1]
   176  	}
   177  
   178  	// Required: false
   179  	// AllowEmptyValue: false
   180  
   181  	if raw == "" { // empty values pass all other validations
   182  		return nil
   183  	}
   184  	o.Prefix = &raw
   185  
   186  	return nil
   187  }
   188  
   189  // bindRecursive binds and validates parameter Recursive from query.
   190  func (o *ListObjectsParams) bindRecursive(rawData []string, hasKey bool, formats strfmt.Registry) error {
   191  	var raw string
   192  	if len(rawData) > 0 {
   193  		raw = rawData[len(rawData)-1]
   194  	}
   195  
   196  	// Required: false
   197  	// AllowEmptyValue: false
   198  
   199  	if raw == "" { // empty values pass all other validations
   200  		return nil
   201  	}
   202  
   203  	value, err := swag.ConvertBool(raw)
   204  	if err != nil {
   205  		return errors.InvalidType("recursive", "query", "bool", raw)
   206  	}
   207  	o.Recursive = &value
   208  
   209  	return nil
   210  }
   211  
   212  // bindWithMetadata binds and validates parameter WithMetadata from query.
   213  func (o *ListObjectsParams) bindWithMetadata(rawData []string, hasKey bool, formats strfmt.Registry) error {
   214  	var raw string
   215  	if len(rawData) > 0 {
   216  		raw = rawData[len(rawData)-1]
   217  	}
   218  
   219  	// Required: false
   220  	// AllowEmptyValue: false
   221  
   222  	if raw == "" { // empty values pass all other validations
   223  		return nil
   224  	}
   225  
   226  	value, err := swag.ConvertBool(raw)
   227  	if err != nil {
   228  		return errors.InvalidType("with_metadata", "query", "bool", raw)
   229  	}
   230  	o.WithMetadata = &value
   231  
   232  	return nil
   233  }
   234  
   235  // bindWithVersions binds and validates parameter WithVersions from query.
   236  func (o *ListObjectsParams) bindWithVersions(rawData []string, hasKey bool, formats strfmt.Registry) error {
   237  	var raw string
   238  	if len(rawData) > 0 {
   239  		raw = rawData[len(rawData)-1]
   240  	}
   241  
   242  	// Required: false
   243  	// AllowEmptyValue: false
   244  
   245  	if raw == "" { // empty values pass all other validations
   246  		return nil
   247  	}
   248  
   249  	value, err := swag.ConvertBool(raw)
   250  	if err != nil {
   251  		return errors.InvalidType("with_versions", "query", "bool", raw)
   252  	}
   253  	o.WithVersions = &value
   254  
   255  	return nil
   256  }