github.com/minio/console@v1.4.1/models/make_bucket_request.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 models 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 "context" 27 28 "github.com/go-openapi/errors" 29 "github.com/go-openapi/strfmt" 30 "github.com/go-openapi/swag" 31 "github.com/go-openapi/validate" 32 ) 33 34 // MakeBucketRequest make bucket request 35 // 36 // swagger:model makeBucketRequest 37 type MakeBucketRequest struct { 38 39 // locking 40 Locking bool `json:"locking,omitempty"` 41 42 // name 43 // Required: true 44 Name *string `json:"name"` 45 46 // quota 47 Quota *SetBucketQuota `json:"quota,omitempty"` 48 49 // retention 50 Retention *PutBucketRetentionRequest `json:"retention,omitempty"` 51 52 // versioning 53 Versioning *SetBucketVersioning `json:"versioning,omitempty"` 54 } 55 56 // Validate validates this make bucket request 57 func (m *MakeBucketRequest) Validate(formats strfmt.Registry) error { 58 var res []error 59 60 if err := m.validateName(formats); err != nil { 61 res = append(res, err) 62 } 63 64 if err := m.validateQuota(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if err := m.validateRetention(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if err := m.validateVersioning(formats); err != nil { 73 res = append(res, err) 74 } 75 76 if len(res) > 0 { 77 return errors.CompositeValidationError(res...) 78 } 79 return nil 80 } 81 82 func (m *MakeBucketRequest) validateName(formats strfmt.Registry) error { 83 84 if err := validate.Required("name", "body", m.Name); err != nil { 85 return err 86 } 87 88 return nil 89 } 90 91 func (m *MakeBucketRequest) validateQuota(formats strfmt.Registry) error { 92 if swag.IsZero(m.Quota) { // not required 93 return nil 94 } 95 96 if m.Quota != nil { 97 if err := m.Quota.Validate(formats); err != nil { 98 if ve, ok := err.(*errors.Validation); ok { 99 return ve.ValidateName("quota") 100 } else if ce, ok := err.(*errors.CompositeError); ok { 101 return ce.ValidateName("quota") 102 } 103 return err 104 } 105 } 106 107 return nil 108 } 109 110 func (m *MakeBucketRequest) validateRetention(formats strfmt.Registry) error { 111 if swag.IsZero(m.Retention) { // not required 112 return nil 113 } 114 115 if m.Retention != nil { 116 if err := m.Retention.Validate(formats); err != nil { 117 if ve, ok := err.(*errors.Validation); ok { 118 return ve.ValidateName("retention") 119 } else if ce, ok := err.(*errors.CompositeError); ok { 120 return ce.ValidateName("retention") 121 } 122 return err 123 } 124 } 125 126 return nil 127 } 128 129 func (m *MakeBucketRequest) validateVersioning(formats strfmt.Registry) error { 130 if swag.IsZero(m.Versioning) { // not required 131 return nil 132 } 133 134 if m.Versioning != nil { 135 if err := m.Versioning.Validate(formats); err != nil { 136 if ve, ok := err.(*errors.Validation); ok { 137 return ve.ValidateName("versioning") 138 } else if ce, ok := err.(*errors.CompositeError); ok { 139 return ce.ValidateName("versioning") 140 } 141 return err 142 } 143 } 144 145 return nil 146 } 147 148 // ContextValidate validate this make bucket request based on the context it is used 149 func (m *MakeBucketRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 150 var res []error 151 152 if err := m.contextValidateQuota(ctx, formats); err != nil { 153 res = append(res, err) 154 } 155 156 if err := m.contextValidateRetention(ctx, formats); err != nil { 157 res = append(res, err) 158 } 159 160 if err := m.contextValidateVersioning(ctx, formats); err != nil { 161 res = append(res, err) 162 } 163 164 if len(res) > 0 { 165 return errors.CompositeValidationError(res...) 166 } 167 return nil 168 } 169 170 func (m *MakeBucketRequest) contextValidateQuota(ctx context.Context, formats strfmt.Registry) error { 171 172 if m.Quota != nil { 173 174 if swag.IsZero(m.Quota) { // not required 175 return nil 176 } 177 178 if err := m.Quota.ContextValidate(ctx, formats); err != nil { 179 if ve, ok := err.(*errors.Validation); ok { 180 return ve.ValidateName("quota") 181 } else if ce, ok := err.(*errors.CompositeError); ok { 182 return ce.ValidateName("quota") 183 } 184 return err 185 } 186 } 187 188 return nil 189 } 190 191 func (m *MakeBucketRequest) contextValidateRetention(ctx context.Context, formats strfmt.Registry) error { 192 193 if m.Retention != nil { 194 195 if swag.IsZero(m.Retention) { // not required 196 return nil 197 } 198 199 if err := m.Retention.ContextValidate(ctx, formats); err != nil { 200 if ve, ok := err.(*errors.Validation); ok { 201 return ve.ValidateName("retention") 202 } else if ce, ok := err.(*errors.CompositeError); ok { 203 return ce.ValidateName("retention") 204 } 205 return err 206 } 207 } 208 209 return nil 210 } 211 212 func (m *MakeBucketRequest) contextValidateVersioning(ctx context.Context, formats strfmt.Registry) error { 213 214 if m.Versioning != nil { 215 216 if swag.IsZero(m.Versioning) { // not required 217 return nil 218 } 219 220 if err := m.Versioning.ContextValidate(ctx, formats); err != nil { 221 if ve, ok := err.(*errors.Validation); ok { 222 return ve.ValidateName("versioning") 223 } else if ce, ok := err.(*errors.CompositeError); ok { 224 return ce.ValidateName("versioning") 225 } 226 return err 227 } 228 } 229 230 return nil 231 } 232 233 // MarshalBinary interface implementation 234 func (m *MakeBucketRequest) MarshalBinary() ([]byte, error) { 235 if m == nil { 236 return nil, nil 237 } 238 return swag.WriteJSON(m) 239 } 240 241 // UnmarshalBinary interface implementation 242 func (m *MakeBucketRequest) UnmarshalBinary(b []byte) error { 243 var res MakeBucketRequest 244 if err := swag.ReadJSON(b, &res); err != nil { 245 return err 246 } 247 *m = res 248 return nil 249 }