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