github.com/minio/console@v1.4.1/models/bucket_replication_response.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 "strconv" 28 29 "github.com/go-openapi/errors" 30 "github.com/go-openapi/strfmt" 31 "github.com/go-openapi/swag" 32 ) 33 34 // BucketReplicationResponse bucket replication response 35 // 36 // swagger:model bucketReplicationResponse 37 type BucketReplicationResponse struct { 38 39 // rules 40 Rules []*BucketReplicationRule `json:"rules"` 41 } 42 43 // Validate validates this bucket replication response 44 func (m *BucketReplicationResponse) Validate(formats strfmt.Registry) error { 45 var res []error 46 47 if err := m.validateRules(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if len(res) > 0 { 52 return errors.CompositeValidationError(res...) 53 } 54 return nil 55 } 56 57 func (m *BucketReplicationResponse) validateRules(formats strfmt.Registry) error { 58 if swag.IsZero(m.Rules) { // not required 59 return nil 60 } 61 62 for i := 0; i < len(m.Rules); i++ { 63 if swag.IsZero(m.Rules[i]) { // not required 64 continue 65 } 66 67 if m.Rules[i] != nil { 68 if err := m.Rules[i].Validate(formats); err != nil { 69 if ve, ok := err.(*errors.Validation); ok { 70 return ve.ValidateName("rules" + "." + strconv.Itoa(i)) 71 } else if ce, ok := err.(*errors.CompositeError); ok { 72 return ce.ValidateName("rules" + "." + strconv.Itoa(i)) 73 } 74 return err 75 } 76 } 77 78 } 79 80 return nil 81 } 82 83 // ContextValidate validate this bucket replication response based on the context it is used 84 func (m *BucketReplicationResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 85 var res []error 86 87 if err := m.contextValidateRules(ctx, formats); err != nil { 88 res = append(res, err) 89 } 90 91 if len(res) > 0 { 92 return errors.CompositeValidationError(res...) 93 } 94 return nil 95 } 96 97 func (m *BucketReplicationResponse) contextValidateRules(ctx context.Context, formats strfmt.Registry) error { 98 99 for i := 0; i < len(m.Rules); i++ { 100 101 if m.Rules[i] != nil { 102 103 if swag.IsZero(m.Rules[i]) { // not required 104 return nil 105 } 106 107 if err := m.Rules[i].ContextValidate(ctx, formats); err != nil { 108 if ve, ok := err.(*errors.Validation); ok { 109 return ve.ValidateName("rules" + "." + strconv.Itoa(i)) 110 } else if ce, ok := err.(*errors.CompositeError); ok { 111 return ce.ValidateName("rules" + "." + strconv.Itoa(i)) 112 } 113 return err 114 } 115 } 116 117 } 118 119 return nil 120 } 121 122 // MarshalBinary interface implementation 123 func (m *BucketReplicationResponse) MarshalBinary() ([]byte, error) { 124 if m == nil { 125 return nil, nil 126 } 127 return swag.WriteJSON(m) 128 } 129 130 // UnmarshalBinary interface implementation 131 func (m *BucketReplicationResponse) UnmarshalBinary(b []byte) error { 132 var res BucketReplicationResponse 133 if err := swag.ReadJSON(b, &res); err != nil { 134 return err 135 } 136 *m = res 137 return nil 138 }