github.com/minio/console@v1.4.1/api/operations/configuration/post_configs_import_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 configuration
    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  	"mime/multipart"
    28  	"net/http"
    29  
    30  	"github.com/go-openapi/errors"
    31  	"github.com/go-openapi/runtime"
    32  	"github.com/go-openapi/runtime/middleware"
    33  )
    34  
    35  // PostConfigsImportMaxParseMemory sets the maximum size in bytes for
    36  // the multipart form parser for this operation.
    37  //
    38  // The default value is 32 MB.
    39  // The multipart parser stores up to this + 10MB.
    40  var PostConfigsImportMaxParseMemory int64 = 32 << 20
    41  
    42  // NewPostConfigsImportParams creates a new PostConfigsImportParams object
    43  //
    44  // There are no default values defined in the spec.
    45  func NewPostConfigsImportParams() PostConfigsImportParams {
    46  
    47  	return PostConfigsImportParams{}
    48  }
    49  
    50  // PostConfigsImportParams contains all the bound params for the post configs import operation
    51  // typically these are obtained from a http.Request
    52  //
    53  // swagger:parameters PostConfigsImport
    54  type PostConfigsImportParams struct {
    55  
    56  	// HTTP Request Object
    57  	HTTPRequest *http.Request `json:"-"`
    58  
    59  	/*
    60  	  Required: true
    61  	  In: formData
    62  	*/
    63  	File io.ReadCloser
    64  }
    65  
    66  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    67  // for simple values it will use straight method calls.
    68  //
    69  // To ensure default values, the struct must have been initialized with NewPostConfigsImportParams() beforehand.
    70  func (o *PostConfigsImportParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    71  	var res []error
    72  
    73  	o.HTTPRequest = r
    74  
    75  	if err := r.ParseMultipartForm(PostConfigsImportMaxParseMemory); err != nil {
    76  		if err != http.ErrNotMultipart {
    77  			return errors.New(400, "%v", err)
    78  		} else if err := r.ParseForm(); err != nil {
    79  			return errors.New(400, "%v", err)
    80  		}
    81  	}
    82  
    83  	file, fileHeader, err := r.FormFile("file")
    84  	if err != nil {
    85  		res = append(res, errors.New(400, "reading file %q failed: %v", "file", err))
    86  	} else if err := o.bindFile(file, fileHeader); err != nil {
    87  		// Required: true
    88  		res = append(res, err)
    89  	} else {
    90  		o.File = &runtime.File{Data: file, Header: fileHeader}
    91  	}
    92  	if len(res) > 0 {
    93  		return errors.CompositeValidationError(res...)
    94  	}
    95  	return nil
    96  }
    97  
    98  // bindFile binds file parameter File.
    99  //
   100  // The only supported validations on files are MinLength and MaxLength
   101  func (o *PostConfigsImportParams) bindFile(file multipart.File, header *multipart.FileHeader) error {
   102  	return nil
   103  }