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