github.com/minio/console@v1.4.1/api/operations/logging/log_search_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 logging 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 // NewLogSearchParams creates a new LogSearchParams object 37 // with the default values initialized. 38 func NewLogSearchParams() LogSearchParams { 39 40 var ( 41 // initialize parameters with default values 42 43 orderDefault = string("timeDesc") 44 pageNoDefault = int32(0) 45 pageSizeDefault = int32(10) 46 ) 47 48 return LogSearchParams{ 49 Order: &orderDefault, 50 51 PageNo: &pageNoDefault, 52 53 PageSize: &pageSizeDefault, 54 } 55 } 56 57 // LogSearchParams contains all the bound params for the log search operation 58 // typically these are obtained from a http.Request 59 // 60 // swagger:parameters LogSearch 61 type LogSearchParams struct { 62 63 // HTTP Request Object 64 HTTPRequest *http.Request `json:"-"` 65 66 /*Filter Parameters 67 In: query 68 Collection Format: multi 69 */ 70 Fp []string 71 /* 72 In: query 73 Default: "timeDesc" 74 */ 75 Order *string 76 /* 77 In: query 78 Default: 0 79 */ 80 PageNo *int32 81 /* 82 In: query 83 Default: 10 84 */ 85 PageSize *int32 86 /* 87 In: query 88 */ 89 TimeEnd *string 90 /* 91 In: query 92 */ 93 TimeStart *string 94 } 95 96 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 97 // for simple values it will use straight method calls. 98 // 99 // To ensure default values, the struct must have been initialized with NewLogSearchParams() beforehand. 100 func (o *LogSearchParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 101 var res []error 102 103 o.HTTPRequest = r 104 105 qs := runtime.Values(r.URL.Query()) 106 107 qFp, qhkFp, _ := qs.GetOK("fp") 108 if err := o.bindFp(qFp, qhkFp, route.Formats); err != nil { 109 res = append(res, err) 110 } 111 112 qOrder, qhkOrder, _ := qs.GetOK("order") 113 if err := o.bindOrder(qOrder, qhkOrder, route.Formats); err != nil { 114 res = append(res, err) 115 } 116 117 qPageNo, qhkPageNo, _ := qs.GetOK("pageNo") 118 if err := o.bindPageNo(qPageNo, qhkPageNo, route.Formats); err != nil { 119 res = append(res, err) 120 } 121 122 qPageSize, qhkPageSize, _ := qs.GetOK("pageSize") 123 if err := o.bindPageSize(qPageSize, qhkPageSize, route.Formats); err != nil { 124 res = append(res, err) 125 } 126 127 qTimeEnd, qhkTimeEnd, _ := qs.GetOK("timeEnd") 128 if err := o.bindTimeEnd(qTimeEnd, qhkTimeEnd, route.Formats); err != nil { 129 res = append(res, err) 130 } 131 132 qTimeStart, qhkTimeStart, _ := qs.GetOK("timeStart") 133 if err := o.bindTimeStart(qTimeStart, qhkTimeStart, route.Formats); err != nil { 134 res = append(res, err) 135 } 136 if len(res) > 0 { 137 return errors.CompositeValidationError(res...) 138 } 139 return nil 140 } 141 142 // bindFp binds and validates array parameter Fp from query. 143 // 144 // Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty). 145 func (o *LogSearchParams) bindFp(rawData []string, hasKey bool, formats strfmt.Registry) error { 146 // CollectionFormat: multi 147 fpIC := rawData 148 if len(fpIC) == 0 { 149 return nil 150 } 151 152 var fpIR []string 153 for _, fpIV := range fpIC { 154 fpI := fpIV 155 156 fpIR = append(fpIR, fpI) 157 } 158 159 o.Fp = fpIR 160 161 return nil 162 } 163 164 // bindOrder binds and validates parameter Order from query. 165 func (o *LogSearchParams) bindOrder(rawData []string, hasKey bool, formats strfmt.Registry) error { 166 var raw string 167 if len(rawData) > 0 { 168 raw = rawData[len(rawData)-1] 169 } 170 171 // Required: false 172 // AllowEmptyValue: false 173 174 if raw == "" { // empty values pass all other validations 175 // Default values have been previously initialized by NewLogSearchParams() 176 return nil 177 } 178 o.Order = &raw 179 180 if err := o.validateOrder(formats); err != nil { 181 return err 182 } 183 184 return nil 185 } 186 187 // validateOrder carries on validations for parameter Order 188 func (o *LogSearchParams) validateOrder(formats strfmt.Registry) error { 189 190 if err := validate.EnumCase("order", "query", *o.Order, []interface{}{"timeDesc", "timeAsc"}, true); err != nil { 191 return err 192 } 193 194 return nil 195 } 196 197 // bindPageNo binds and validates parameter PageNo from query. 198 func (o *LogSearchParams) bindPageNo(rawData []string, hasKey bool, formats strfmt.Registry) error { 199 var raw string 200 if len(rawData) > 0 { 201 raw = rawData[len(rawData)-1] 202 } 203 204 // Required: false 205 // AllowEmptyValue: false 206 207 if raw == "" { // empty values pass all other validations 208 // Default values have been previously initialized by NewLogSearchParams() 209 return nil 210 } 211 212 value, err := swag.ConvertInt32(raw) 213 if err != nil { 214 return errors.InvalidType("pageNo", "query", "int32", raw) 215 } 216 o.PageNo = &value 217 218 return nil 219 } 220 221 // bindPageSize binds and validates parameter PageSize from query. 222 func (o *LogSearchParams) bindPageSize(rawData []string, hasKey bool, formats strfmt.Registry) error { 223 var raw string 224 if len(rawData) > 0 { 225 raw = rawData[len(rawData)-1] 226 } 227 228 // Required: false 229 // AllowEmptyValue: false 230 231 if raw == "" { // empty values pass all other validations 232 // Default values have been previously initialized by NewLogSearchParams() 233 return nil 234 } 235 236 value, err := swag.ConvertInt32(raw) 237 if err != nil { 238 return errors.InvalidType("pageSize", "query", "int32", raw) 239 } 240 o.PageSize = &value 241 242 return nil 243 } 244 245 // bindTimeEnd binds and validates parameter TimeEnd from query. 246 func (o *LogSearchParams) bindTimeEnd(rawData []string, hasKey bool, formats strfmt.Registry) error { 247 var raw string 248 if len(rawData) > 0 { 249 raw = rawData[len(rawData)-1] 250 } 251 252 // Required: false 253 // AllowEmptyValue: false 254 255 if raw == "" { // empty values pass all other validations 256 return nil 257 } 258 o.TimeEnd = &raw 259 260 return nil 261 } 262 263 // bindTimeStart binds and validates parameter TimeStart from query. 264 func (o *LogSearchParams) bindTimeStart(rawData []string, hasKey bool, formats strfmt.Registry) error { 265 var raw string 266 if len(rawData) > 0 { 267 raw = rawData[len(rawData)-1] 268 } 269 270 // Required: false 271 // AllowEmptyValue: false 272 273 if raw == "" { // empty values pass all other validations 274 return nil 275 } 276 o.TimeStart = &raw 277 278 return nil 279 }