github.com/minio/console@v1.4.1/models/tier.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 "encoding/json" 28 29 "github.com/go-openapi/errors" 30 "github.com/go-openapi/strfmt" 31 "github.com/go-openapi/swag" 32 "github.com/go-openapi/validate" 33 ) 34 35 // Tier tier 36 // 37 // swagger:model tier 38 type Tier struct { 39 40 // azure 41 Azure *TierAzure `json:"azure,omitempty"` 42 43 // gcs 44 Gcs *TierGcs `json:"gcs,omitempty"` 45 46 // minio 47 Minio *TierMinio `json:"minio,omitempty"` 48 49 // s3 50 S3 *TierS3 `json:"s3,omitempty"` 51 52 // status 53 Status bool `json:"status,omitempty"` 54 55 // type 56 // Enum: [s3 gcs azure minio unsupported] 57 Type string `json:"type,omitempty"` 58 } 59 60 // Validate validates this tier 61 func (m *Tier) Validate(formats strfmt.Registry) error { 62 var res []error 63 64 if err := m.validateAzure(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if err := m.validateGcs(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if err := m.validateMinio(formats); err != nil { 73 res = append(res, err) 74 } 75 76 if err := m.validateS3(formats); err != nil { 77 res = append(res, err) 78 } 79 80 if err := m.validateType(formats); err != nil { 81 res = append(res, err) 82 } 83 84 if len(res) > 0 { 85 return errors.CompositeValidationError(res...) 86 } 87 return nil 88 } 89 90 func (m *Tier) validateAzure(formats strfmt.Registry) error { 91 if swag.IsZero(m.Azure) { // not required 92 return nil 93 } 94 95 if m.Azure != nil { 96 if err := m.Azure.Validate(formats); err != nil { 97 if ve, ok := err.(*errors.Validation); ok { 98 return ve.ValidateName("azure") 99 } else if ce, ok := err.(*errors.CompositeError); ok { 100 return ce.ValidateName("azure") 101 } 102 return err 103 } 104 } 105 106 return nil 107 } 108 109 func (m *Tier) validateGcs(formats strfmt.Registry) error { 110 if swag.IsZero(m.Gcs) { // not required 111 return nil 112 } 113 114 if m.Gcs != nil { 115 if err := m.Gcs.Validate(formats); err != nil { 116 if ve, ok := err.(*errors.Validation); ok { 117 return ve.ValidateName("gcs") 118 } else if ce, ok := err.(*errors.CompositeError); ok { 119 return ce.ValidateName("gcs") 120 } 121 return err 122 } 123 } 124 125 return nil 126 } 127 128 func (m *Tier) validateMinio(formats strfmt.Registry) error { 129 if swag.IsZero(m.Minio) { // not required 130 return nil 131 } 132 133 if m.Minio != nil { 134 if err := m.Minio.Validate(formats); err != nil { 135 if ve, ok := err.(*errors.Validation); ok { 136 return ve.ValidateName("minio") 137 } else if ce, ok := err.(*errors.CompositeError); ok { 138 return ce.ValidateName("minio") 139 } 140 return err 141 } 142 } 143 144 return nil 145 } 146 147 func (m *Tier) validateS3(formats strfmt.Registry) error { 148 if swag.IsZero(m.S3) { // not required 149 return nil 150 } 151 152 if m.S3 != nil { 153 if err := m.S3.Validate(formats); err != nil { 154 if ve, ok := err.(*errors.Validation); ok { 155 return ve.ValidateName("s3") 156 } else if ce, ok := err.(*errors.CompositeError); ok { 157 return ce.ValidateName("s3") 158 } 159 return err 160 } 161 } 162 163 return nil 164 } 165 166 var tierTypeTypePropEnum []interface{} 167 168 func init() { 169 var res []string 170 if err := json.Unmarshal([]byte(`["s3","gcs","azure","minio","unsupported"]`), &res); err != nil { 171 panic(err) 172 } 173 for _, v := range res { 174 tierTypeTypePropEnum = append(tierTypeTypePropEnum, v) 175 } 176 } 177 178 const ( 179 180 // TierTypeS3 captures enum value "s3" 181 TierTypeS3 string = "s3" 182 183 // TierTypeGcs captures enum value "gcs" 184 TierTypeGcs string = "gcs" 185 186 // TierTypeAzure captures enum value "azure" 187 TierTypeAzure string = "azure" 188 189 // TierTypeMinio captures enum value "minio" 190 TierTypeMinio string = "minio" 191 192 // TierTypeUnsupported captures enum value "unsupported" 193 TierTypeUnsupported string = "unsupported" 194 ) 195 196 // prop value enum 197 func (m *Tier) validateTypeEnum(path, location string, value string) error { 198 if err := validate.EnumCase(path, location, value, tierTypeTypePropEnum, true); err != nil { 199 return err 200 } 201 return nil 202 } 203 204 func (m *Tier) validateType(formats strfmt.Registry) error { 205 if swag.IsZero(m.Type) { // not required 206 return nil 207 } 208 209 // value enum 210 if err := m.validateTypeEnum("type", "body", m.Type); err != nil { 211 return err 212 } 213 214 return nil 215 } 216 217 // ContextValidate validate this tier based on the context it is used 218 func (m *Tier) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 219 var res []error 220 221 if err := m.contextValidateAzure(ctx, formats); err != nil { 222 res = append(res, err) 223 } 224 225 if err := m.contextValidateGcs(ctx, formats); err != nil { 226 res = append(res, err) 227 } 228 229 if err := m.contextValidateMinio(ctx, formats); err != nil { 230 res = append(res, err) 231 } 232 233 if err := m.contextValidateS3(ctx, formats); err != nil { 234 res = append(res, err) 235 } 236 237 if len(res) > 0 { 238 return errors.CompositeValidationError(res...) 239 } 240 return nil 241 } 242 243 func (m *Tier) contextValidateAzure(ctx context.Context, formats strfmt.Registry) error { 244 245 if m.Azure != nil { 246 247 if swag.IsZero(m.Azure) { // not required 248 return nil 249 } 250 251 if err := m.Azure.ContextValidate(ctx, formats); err != nil { 252 if ve, ok := err.(*errors.Validation); ok { 253 return ve.ValidateName("azure") 254 } else if ce, ok := err.(*errors.CompositeError); ok { 255 return ce.ValidateName("azure") 256 } 257 return err 258 } 259 } 260 261 return nil 262 } 263 264 func (m *Tier) contextValidateGcs(ctx context.Context, formats strfmt.Registry) error { 265 266 if m.Gcs != nil { 267 268 if swag.IsZero(m.Gcs) { // not required 269 return nil 270 } 271 272 if err := m.Gcs.ContextValidate(ctx, formats); err != nil { 273 if ve, ok := err.(*errors.Validation); ok { 274 return ve.ValidateName("gcs") 275 } else if ce, ok := err.(*errors.CompositeError); ok { 276 return ce.ValidateName("gcs") 277 } 278 return err 279 } 280 } 281 282 return nil 283 } 284 285 func (m *Tier) contextValidateMinio(ctx context.Context, formats strfmt.Registry) error { 286 287 if m.Minio != nil { 288 289 if swag.IsZero(m.Minio) { // not required 290 return nil 291 } 292 293 if err := m.Minio.ContextValidate(ctx, formats); err != nil { 294 if ve, ok := err.(*errors.Validation); ok { 295 return ve.ValidateName("minio") 296 } else if ce, ok := err.(*errors.CompositeError); ok { 297 return ce.ValidateName("minio") 298 } 299 return err 300 } 301 } 302 303 return nil 304 } 305 306 func (m *Tier) contextValidateS3(ctx context.Context, formats strfmt.Registry) error { 307 308 if m.S3 != nil { 309 310 if swag.IsZero(m.S3) { // not required 311 return nil 312 } 313 314 if err := m.S3.ContextValidate(ctx, formats); err != nil { 315 if ve, ok := err.(*errors.Validation); ok { 316 return ve.ValidateName("s3") 317 } else if ce, ok := err.(*errors.CompositeError); ok { 318 return ce.ValidateName("s3") 319 } 320 return err 321 } 322 } 323 324 return nil 325 } 326 327 // MarshalBinary interface implementation 328 func (m *Tier) MarshalBinary() ([]byte, error) { 329 if m == nil { 330 return nil, nil 331 } 332 return swag.WriteJSON(m) 333 } 334 335 // UnmarshalBinary interface implementation 336 func (m *Tier) UnmarshalBinary(b []byte) error { 337 var res Tier 338 if err := swag.ReadJSON(b, &res); err != nil { 339 return err 340 } 341 *m = res 342 return nil 343 }