github.com/minio/console@v1.4.1/api/operations/profile/profiling_start_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 profile
    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  	"net/http"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/runtime"
    31  	"github.com/go-openapi/runtime/middleware"
    32  	"github.com/go-openapi/validate"
    33  
    34  	"github.com/minio/console/models"
    35  )
    36  
    37  // NewProfilingStartParams creates a new ProfilingStartParams object
    38  //
    39  // There are no default values defined in the spec.
    40  func NewProfilingStartParams() ProfilingStartParams {
    41  
    42  	return ProfilingStartParams{}
    43  }
    44  
    45  // ProfilingStartParams contains all the bound params for the profiling start operation
    46  // typically these are obtained from a http.Request
    47  //
    48  // swagger:parameters ProfilingStart
    49  type ProfilingStartParams struct {
    50  
    51  	// HTTP Request Object
    52  	HTTPRequest *http.Request `json:"-"`
    53  
    54  	/*
    55  	  Required: true
    56  	  In: body
    57  	*/
    58  	Body *models.ProfilingStartRequest
    59  }
    60  
    61  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    62  // for simple values it will use straight method calls.
    63  //
    64  // To ensure default values, the struct must have been initialized with NewProfilingStartParams() beforehand.
    65  func (o *ProfilingStartParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    66  	var res []error
    67  
    68  	o.HTTPRequest = r
    69  
    70  	if runtime.HasBody(r) {
    71  		defer r.Body.Close()
    72  		var body models.ProfilingStartRequest
    73  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    74  			if err == io.EOF {
    75  				res = append(res, errors.Required("body", "body", ""))
    76  			} else {
    77  				res = append(res, errors.NewParseError("body", "body", "", err))
    78  			}
    79  		} else {
    80  			// validate body object
    81  			if err := body.Validate(route.Formats); err != nil {
    82  				res = append(res, err)
    83  			}
    84  
    85  			ctx := validate.WithOperationRequest(r.Context())
    86  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    87  				res = append(res, err)
    88  			}
    89  
    90  			if len(res) == 0 {
    91  				o.Body = &body
    92  			}
    93  		}
    94  	} else {
    95  		res = append(res, errors.Required("body", "body", ""))
    96  	}
    97  	if len(res) > 0 {
    98  		return errors.CompositeValidationError(res...)
    99  	}
   100  	return nil
   101  }