github.com/minio/console@v1.4.1/api/operations/bucket/list_bucket_events_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  	"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  // NewListBucketEventsParams creates a new ListBucketEventsParams object
    36  // with the default values initialized.
    37  func NewListBucketEventsParams() ListBucketEventsParams {
    38  
    39  	var (
    40  		// initialize parameters with default values
    41  
    42  		limitDefault  = int32(20)
    43  		offsetDefault = int32(0)
    44  	)
    45  
    46  	return ListBucketEventsParams{
    47  		Limit: &limitDefault,
    48  
    49  		Offset: &offsetDefault,
    50  	}
    51  }
    52  
    53  // ListBucketEventsParams contains all the bound params for the list bucket events operation
    54  // typically these are obtained from a http.Request
    55  //
    56  // swagger:parameters ListBucketEvents
    57  type ListBucketEventsParams struct {
    58  
    59  	// HTTP Request Object
    60  	HTTPRequest *http.Request `json:"-"`
    61  
    62  	/*
    63  	  Required: true
    64  	  In: path
    65  	*/
    66  	BucketName string
    67  	/*
    68  	  In: query
    69  	  Default: 20
    70  	*/
    71  	Limit *int32
    72  	/*
    73  	  In: query
    74  	  Default: 0
    75  	*/
    76  	Offset *int32
    77  }
    78  
    79  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    80  // for simple values it will use straight method calls.
    81  //
    82  // To ensure default values, the struct must have been initialized with NewListBucketEventsParams() beforehand.
    83  func (o *ListBucketEventsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    84  	var res []error
    85  
    86  	o.HTTPRequest = r
    87  
    88  	qs := runtime.Values(r.URL.Query())
    89  
    90  	rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
    91  	if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	qLimit, qhkLimit, _ := qs.GetOK("limit")
    96  	if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	qOffset, qhkOffset, _ := qs.GetOK("offset")
   101  	if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil {
   102  		res = append(res, err)
   103  	}
   104  	if len(res) > 0 {
   105  		return errors.CompositeValidationError(res...)
   106  	}
   107  	return nil
   108  }
   109  
   110  // bindBucketName binds and validates parameter BucketName from path.
   111  func (o *ListBucketEventsParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
   112  	var raw string
   113  	if len(rawData) > 0 {
   114  		raw = rawData[len(rawData)-1]
   115  	}
   116  
   117  	// Required: true
   118  	// Parameter is provided by construction from the route
   119  	o.BucketName = raw
   120  
   121  	return nil
   122  }
   123  
   124  // bindLimit binds and validates parameter Limit from query.
   125  func (o *ListBucketEventsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error {
   126  	var raw string
   127  	if len(rawData) > 0 {
   128  		raw = rawData[len(rawData)-1]
   129  	}
   130  
   131  	// Required: false
   132  	// AllowEmptyValue: false
   133  
   134  	if raw == "" { // empty values pass all other validations
   135  		// Default values have been previously initialized by NewListBucketEventsParams()
   136  		return nil
   137  	}
   138  
   139  	value, err := swag.ConvertInt32(raw)
   140  	if err != nil {
   141  		return errors.InvalidType("limit", "query", "int32", raw)
   142  	}
   143  	o.Limit = &value
   144  
   145  	return nil
   146  }
   147  
   148  // bindOffset binds and validates parameter Offset from query.
   149  func (o *ListBucketEventsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error {
   150  	var raw string
   151  	if len(rawData) > 0 {
   152  		raw = rawData[len(rawData)-1]
   153  	}
   154  
   155  	// Required: false
   156  	// AllowEmptyValue: false
   157  
   158  	if raw == "" { // empty values pass all other validations
   159  		// Default values have been previously initialized by NewListBucketEventsParams()
   160  		return nil
   161  	}
   162  
   163  	value, err := swag.ConvertInt32(raw)
   164  	if err != nil {
   165  		return errors.InvalidType("offset", "query", "int32", raw)
   166  	}
   167  	o.Offset = &value
   168  
   169  	return nil
   170  }