github.com/minio/console@v1.4.1/api/operations/inspect/inspect_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 inspect
    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  // NewInspectParams creates a new InspectParams object
    37  //
    38  // There are no default values defined in the spec.
    39  func NewInspectParams() InspectParams {
    40  
    41  	return InspectParams{}
    42  }
    43  
    44  // InspectParams contains all the bound params for the inspect operation
    45  // typically these are obtained from a http.Request
    46  //
    47  // swagger:parameters Inspect
    48  type InspectParams struct {
    49  
    50  	// HTTP Request Object
    51  	HTTPRequest *http.Request `json:"-"`
    52  
    53  	/*
    54  	  In: query
    55  	*/
    56  	Encrypt *bool
    57  	/*
    58  	  Required: true
    59  	  In: query
    60  	*/
    61  	File string
    62  	/*
    63  	  Required: true
    64  	  In: query
    65  	*/
    66  	Volume string
    67  }
    68  
    69  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    70  // for simple values it will use straight method calls.
    71  //
    72  // To ensure default values, the struct must have been initialized with NewInspectParams() beforehand.
    73  func (o *InspectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    74  	var res []error
    75  
    76  	o.HTTPRequest = r
    77  
    78  	qs := runtime.Values(r.URL.Query())
    79  
    80  	qEncrypt, qhkEncrypt, _ := qs.GetOK("encrypt")
    81  	if err := o.bindEncrypt(qEncrypt, qhkEncrypt, route.Formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	qFile, qhkFile, _ := qs.GetOK("file")
    86  	if err := o.bindFile(qFile, qhkFile, route.Formats); err != nil {
    87  		res = append(res, err)
    88  	}
    89  
    90  	qVolume, qhkVolume, _ := qs.GetOK("volume")
    91  	if err := o.bindVolume(qVolume, qhkVolume, route.Formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  	if len(res) > 0 {
    95  		return errors.CompositeValidationError(res...)
    96  	}
    97  	return nil
    98  }
    99  
   100  // bindEncrypt binds and validates parameter Encrypt from query.
   101  func (o *InspectParams) bindEncrypt(rawData []string, hasKey bool, formats strfmt.Registry) error {
   102  	var raw string
   103  	if len(rawData) > 0 {
   104  		raw = rawData[len(rawData)-1]
   105  	}
   106  
   107  	// Required: false
   108  	// AllowEmptyValue: false
   109  
   110  	if raw == "" { // empty values pass all other validations
   111  		return nil
   112  	}
   113  
   114  	value, err := swag.ConvertBool(raw)
   115  	if err != nil {
   116  		return errors.InvalidType("encrypt", "query", "bool", raw)
   117  	}
   118  	o.Encrypt = &value
   119  
   120  	return nil
   121  }
   122  
   123  // bindFile binds and validates parameter File from query.
   124  func (o *InspectParams) bindFile(rawData []string, hasKey bool, formats strfmt.Registry) error {
   125  	if !hasKey {
   126  		return errors.Required("file", "query", rawData)
   127  	}
   128  	var raw string
   129  	if len(rawData) > 0 {
   130  		raw = rawData[len(rawData)-1]
   131  	}
   132  
   133  	// Required: true
   134  	// AllowEmptyValue: false
   135  
   136  	if err := validate.RequiredString("file", "query", raw); err != nil {
   137  		return err
   138  	}
   139  	o.File = raw
   140  
   141  	return nil
   142  }
   143  
   144  // bindVolume binds and validates parameter Volume from query.
   145  func (o *InspectParams) bindVolume(rawData []string, hasKey bool, formats strfmt.Registry) error {
   146  	if !hasKey {
   147  		return errors.Required("volume", "query", rawData)
   148  	}
   149  	var raw string
   150  	if len(rawData) > 0 {
   151  		raw = rawData[len(rawData)-1]
   152  	}
   153  
   154  	// Required: true
   155  	// AllowEmptyValue: false
   156  
   157  	if err := validate.RequiredString("volume", "query", raw); err != nil {
   158  		return err
   159  	}
   160  	o.Volume = raw
   161  
   162  	return nil
   163  }