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