github.com/minio/console@v1.4.1/api/operations/bucket/update_bucket_lifecycle_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 bucket 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/validate" 34 35 "github.com/minio/console/models" 36 ) 37 38 // NewUpdateBucketLifecycleParams creates a new UpdateBucketLifecycleParams object 39 // 40 // There are no default values defined in the spec. 41 func NewUpdateBucketLifecycleParams() UpdateBucketLifecycleParams { 42 43 return UpdateBucketLifecycleParams{} 44 } 45 46 // UpdateBucketLifecycleParams contains all the bound params for the update bucket lifecycle operation 47 // typically these are obtained from a http.Request 48 // 49 // swagger:parameters UpdateBucketLifecycle 50 type UpdateBucketLifecycleParams struct { 51 52 // HTTP Request Object 53 HTTPRequest *http.Request `json:"-"` 54 55 /* 56 Required: true 57 In: body 58 */ 59 Body *models.UpdateBucketLifecycle 60 /* 61 Required: true 62 In: path 63 */ 64 BucketName string 65 /* 66 Required: true 67 In: path 68 */ 69 LifecycleID string 70 } 71 72 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 73 // for simple values it will use straight method calls. 74 // 75 // To ensure default values, the struct must have been initialized with NewUpdateBucketLifecycleParams() beforehand. 76 func (o *UpdateBucketLifecycleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 77 var res []error 78 79 o.HTTPRequest = r 80 81 if runtime.HasBody(r) { 82 defer r.Body.Close() 83 var body models.UpdateBucketLifecycle 84 if err := route.Consumer.Consume(r.Body, &body); err != nil { 85 if err == io.EOF { 86 res = append(res, errors.Required("body", "body", "")) 87 } else { 88 res = append(res, errors.NewParseError("body", "body", "", err)) 89 } 90 } else { 91 // validate body object 92 if err := body.Validate(route.Formats); err != nil { 93 res = append(res, err) 94 } 95 96 ctx := validate.WithOperationRequest(r.Context()) 97 if err := body.ContextValidate(ctx, route.Formats); err != nil { 98 res = append(res, err) 99 } 100 101 if len(res) == 0 { 102 o.Body = &body 103 } 104 } 105 } else { 106 res = append(res, errors.Required("body", "body", "")) 107 } 108 109 rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name") 110 if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil { 111 res = append(res, err) 112 } 113 114 rLifecycleID, rhkLifecycleID, _ := route.Params.GetOK("lifecycle_id") 115 if err := o.bindLifecycleID(rLifecycleID, rhkLifecycleID, route.Formats); err != nil { 116 res = append(res, err) 117 } 118 if len(res) > 0 { 119 return errors.CompositeValidationError(res...) 120 } 121 return nil 122 } 123 124 // bindBucketName binds and validates parameter BucketName from path. 125 func (o *UpdateBucketLifecycleParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error { 126 var raw string 127 if len(rawData) > 0 { 128 raw = rawData[len(rawData)-1] 129 } 130 131 // Required: true 132 // Parameter is provided by construction from the route 133 o.BucketName = raw 134 135 return nil 136 } 137 138 // bindLifecycleID binds and validates parameter LifecycleID from path. 139 func (o *UpdateBucketLifecycleParams) bindLifecycleID(rawData []string, hasKey bool, formats strfmt.Registry) error { 140 var raw string 141 if len(rawData) > 0 { 142 raw = rawData[len(rawData)-1] 143 } 144 145 // Required: true 146 // Parameter is provided by construction from the route 147 o.LifecycleID = raw 148 149 return nil 150 }