github.com/minio/console@v1.4.1/api/operations/object/delete_multiple_objects_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 "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/strfmt" 33 "github.com/go-openapi/swag" 34 35 "github.com/minio/console/models" 36 ) 37 38 // NewDeleteMultipleObjectsParams creates a new DeleteMultipleObjectsParams object 39 // 40 // There are no default values defined in the spec. 41 func NewDeleteMultipleObjectsParams() DeleteMultipleObjectsParams { 42 43 return DeleteMultipleObjectsParams{} 44 } 45 46 // DeleteMultipleObjectsParams contains all the bound params for the delete multiple objects operation 47 // typically these are obtained from a http.Request 48 // 49 // swagger:parameters DeleteMultipleObjects 50 type DeleteMultipleObjectsParams struct { 51 52 // HTTP Request Object 53 HTTPRequest *http.Request `json:"-"` 54 55 /* 56 In: query 57 */ 58 AllVersions *bool 59 /* 60 Required: true 61 In: path 62 */ 63 BucketName string 64 /* 65 In: query 66 */ 67 Bypass *bool 68 /* 69 Required: true 70 In: body 71 */ 72 Files []*models.DeleteFile 73 } 74 75 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 76 // for simple values it will use straight method calls. 77 // 78 // To ensure default values, the struct must have been initialized with NewDeleteMultipleObjectsParams() beforehand. 79 func (o *DeleteMultipleObjectsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 80 var res []error 81 82 o.HTTPRequest = r 83 84 qs := runtime.Values(r.URL.Query()) 85 86 qAllVersions, qhkAllVersions, _ := qs.GetOK("all_versions") 87 if err := o.bindAllVersions(qAllVersions, qhkAllVersions, route.Formats); err != nil { 88 res = append(res, err) 89 } 90 91 rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name") 92 if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil { 93 res = append(res, err) 94 } 95 96 qBypass, qhkBypass, _ := qs.GetOK("bypass") 97 if err := o.bindBypass(qBypass, qhkBypass, route.Formats); err != nil { 98 res = append(res, err) 99 } 100 101 if runtime.HasBody(r) { 102 defer r.Body.Close() 103 var body []*models.DeleteFile 104 if err := route.Consumer.Consume(r.Body, &body); err != nil { 105 if err == io.EOF { 106 res = append(res, errors.Required("files", "body", "")) 107 } else { 108 res = append(res, errors.NewParseError("files", "body", "", err)) 109 } 110 } else { 111 112 // validate array of body objects 113 for i := range body { 114 if body[i] == nil { 115 continue 116 } 117 if err := body[i].Validate(route.Formats); err != nil { 118 res = append(res, err) 119 break 120 } 121 } 122 123 if len(res) == 0 { 124 o.Files = body 125 } 126 } 127 } else { 128 res = append(res, errors.Required("files", "body", "")) 129 } 130 if len(res) > 0 { 131 return errors.CompositeValidationError(res...) 132 } 133 return nil 134 } 135 136 // bindAllVersions binds and validates parameter AllVersions from query. 137 func (o *DeleteMultipleObjectsParams) bindAllVersions(rawData []string, hasKey bool, formats strfmt.Registry) error { 138 var raw string 139 if len(rawData) > 0 { 140 raw = rawData[len(rawData)-1] 141 } 142 143 // Required: false 144 // AllowEmptyValue: false 145 146 if raw == "" { // empty values pass all other validations 147 return nil 148 } 149 150 value, err := swag.ConvertBool(raw) 151 if err != nil { 152 return errors.InvalidType("all_versions", "query", "bool", raw) 153 } 154 o.AllVersions = &value 155 156 return nil 157 } 158 159 // bindBucketName binds and validates parameter BucketName from path. 160 func (o *DeleteMultipleObjectsParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error { 161 var raw string 162 if len(rawData) > 0 { 163 raw = rawData[len(rawData)-1] 164 } 165 166 // Required: true 167 // Parameter is provided by construction from the route 168 o.BucketName = raw 169 170 return nil 171 } 172 173 // bindBypass binds and validates parameter Bypass from query. 174 func (o *DeleteMultipleObjectsParams) bindBypass(rawData []string, hasKey bool, formats strfmt.Registry) error { 175 var raw string 176 if len(rawData) > 0 { 177 raw = rawData[len(rawData)-1] 178 } 179 180 // Required: false 181 // AllowEmptyValue: false 182 183 if raw == "" { // empty values pass all other validations 184 return nil 185 } 186 187 value, err := swag.ConvertBool(raw) 188 if err != nil { 189 return errors.InvalidType("bypass", "query", "bool", raw) 190 } 191 o.Bypass = &value 192 193 return nil 194 }