github.com/minio/console@v1.4.1/api/operations/bucket/set_access_rule_with_bucket_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 // NewSetAccessRuleWithBucketParams creates a new SetAccessRuleWithBucketParams object 39 // 40 // There are no default values defined in the spec. 41 func NewSetAccessRuleWithBucketParams() SetAccessRuleWithBucketParams { 42 43 return SetAccessRuleWithBucketParams{} 44 } 45 46 // SetAccessRuleWithBucketParams contains all the bound params for the set access rule with bucket operation 47 // typically these are obtained from a http.Request 48 // 49 // swagger:parameters SetAccessRuleWithBucket 50 type SetAccessRuleWithBucketParams struct { 51 52 // HTTP Request Object 53 HTTPRequest *http.Request `json:"-"` 54 55 /* 56 Required: true 57 In: path 58 */ 59 Bucket string 60 /* 61 Required: true 62 In: body 63 */ 64 Prefixaccess *models.PrefixAccessPair 65 } 66 67 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 68 // for simple values it will use straight method calls. 69 // 70 // To ensure default values, the struct must have been initialized with NewSetAccessRuleWithBucketParams() beforehand. 71 func (o *SetAccessRuleWithBucketParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 72 var res []error 73 74 o.HTTPRequest = r 75 76 rBucket, rhkBucket, _ := route.Params.GetOK("bucket") 77 if err := o.bindBucket(rBucket, rhkBucket, route.Formats); err != nil { 78 res = append(res, err) 79 } 80 81 if runtime.HasBody(r) { 82 defer r.Body.Close() 83 var body models.PrefixAccessPair 84 if err := route.Consumer.Consume(r.Body, &body); err != nil { 85 if err == io.EOF { 86 res = append(res, errors.Required("prefixaccess", "body", "")) 87 } else { 88 res = append(res, errors.NewParseError("prefixaccess", "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.Prefixaccess = &body 103 } 104 } 105 } else { 106 res = append(res, errors.Required("prefixaccess", "body", "")) 107 } 108 if len(res) > 0 { 109 return errors.CompositeValidationError(res...) 110 } 111 return nil 112 } 113 114 // bindBucket binds and validates parameter Bucket from path. 115 func (o *SetAccessRuleWithBucketParams) bindBucket(rawData []string, hasKey bool, formats strfmt.Registry) error { 116 var raw string 117 if len(rawData) > 0 { 118 raw = rawData[len(rawData)-1] 119 } 120 121 // Required: true 122 // Parameter is provided by construction from the route 123 o.Bucket = raw 124 125 return nil 126 }