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