github.com/minio/console@v1.3.0/models/object_bucket_lifecycle.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 // ObjectBucketLifecycle object bucket lifecycle 35 // 36 // swagger:model objectBucketLifecycle 37 type ObjectBucketLifecycle struct { 38 39 // expiration 40 Expiration *ExpirationResponse `json:"expiration,omitempty"` 41 42 // id 43 ID string `json:"id,omitempty"` 44 45 // prefix 46 Prefix string `json:"prefix,omitempty"` 47 48 // status 49 Status string `json:"status,omitempty"` 50 51 // tags 52 Tags []*LifecycleTag `json:"tags"` 53 54 // transition 55 Transition *TransitionResponse `json:"transition,omitempty"` 56 } 57 58 // Validate validates this object bucket lifecycle 59 func (m *ObjectBucketLifecycle) Validate(formats strfmt.Registry) error { 60 var res []error 61 62 if err := m.validateExpiration(formats); err != nil { 63 res = append(res, err) 64 } 65 66 if err := m.validateTags(formats); err != nil { 67 res = append(res, err) 68 } 69 70 if err := m.validateTransition(formats); err != nil { 71 res = append(res, err) 72 } 73 74 if len(res) > 0 { 75 return errors.CompositeValidationError(res...) 76 } 77 return nil 78 } 79 80 func (m *ObjectBucketLifecycle) validateExpiration(formats strfmt.Registry) error { 81 if swag.IsZero(m.Expiration) { // not required 82 return nil 83 } 84 85 if m.Expiration != nil { 86 if err := m.Expiration.Validate(formats); err != nil { 87 if ve, ok := err.(*errors.Validation); ok { 88 return ve.ValidateName("expiration") 89 } else if ce, ok := err.(*errors.CompositeError); ok { 90 return ce.ValidateName("expiration") 91 } 92 return err 93 } 94 } 95 96 return nil 97 } 98 99 func (m *ObjectBucketLifecycle) validateTags(formats strfmt.Registry) error { 100 if swag.IsZero(m.Tags) { // not required 101 return nil 102 } 103 104 for i := 0; i < len(m.Tags); i++ { 105 if swag.IsZero(m.Tags[i]) { // not required 106 continue 107 } 108 109 if m.Tags[i] != nil { 110 if err := m.Tags[i].Validate(formats); err != nil { 111 if ve, ok := err.(*errors.Validation); ok { 112 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 113 } else if ce, ok := err.(*errors.CompositeError); ok { 114 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 115 } 116 return err 117 } 118 } 119 120 } 121 122 return nil 123 } 124 125 func (m *ObjectBucketLifecycle) validateTransition(formats strfmt.Registry) error { 126 if swag.IsZero(m.Transition) { // not required 127 return nil 128 } 129 130 if m.Transition != nil { 131 if err := m.Transition.Validate(formats); err != nil { 132 if ve, ok := err.(*errors.Validation); ok { 133 return ve.ValidateName("transition") 134 } else if ce, ok := err.(*errors.CompositeError); ok { 135 return ce.ValidateName("transition") 136 } 137 return err 138 } 139 } 140 141 return nil 142 } 143 144 // ContextValidate validate this object bucket lifecycle based on the context it is used 145 func (m *ObjectBucketLifecycle) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 146 var res []error 147 148 if err := m.contextValidateExpiration(ctx, formats); err != nil { 149 res = append(res, err) 150 } 151 152 if err := m.contextValidateTags(ctx, formats); err != nil { 153 res = append(res, err) 154 } 155 156 if err := m.contextValidateTransition(ctx, formats); err != nil { 157 res = append(res, err) 158 } 159 160 if len(res) > 0 { 161 return errors.CompositeValidationError(res...) 162 } 163 return nil 164 } 165 166 func (m *ObjectBucketLifecycle) contextValidateExpiration(ctx context.Context, formats strfmt.Registry) error { 167 168 if m.Expiration != nil { 169 170 if swag.IsZero(m.Expiration) { // not required 171 return nil 172 } 173 174 if err := m.Expiration.ContextValidate(ctx, formats); err != nil { 175 if ve, ok := err.(*errors.Validation); ok { 176 return ve.ValidateName("expiration") 177 } else if ce, ok := err.(*errors.CompositeError); ok { 178 return ce.ValidateName("expiration") 179 } 180 return err 181 } 182 } 183 184 return nil 185 } 186 187 func (m *ObjectBucketLifecycle) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 188 189 for i := 0; i < len(m.Tags); i++ { 190 191 if m.Tags[i] != nil { 192 193 if swag.IsZero(m.Tags[i]) { // not required 194 return nil 195 } 196 197 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 198 if ve, ok := err.(*errors.Validation); ok { 199 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 200 } else if ce, ok := err.(*errors.CompositeError); ok { 201 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 202 } 203 return err 204 } 205 } 206 207 } 208 209 return nil 210 } 211 212 func (m *ObjectBucketLifecycle) contextValidateTransition(ctx context.Context, formats strfmt.Registry) error { 213 214 if m.Transition != nil { 215 216 if swag.IsZero(m.Transition) { // not required 217 return nil 218 } 219 220 if err := m.Transition.ContextValidate(ctx, formats); err != nil { 221 if ve, ok := err.(*errors.Validation); ok { 222 return ve.ValidateName("transition") 223 } else if ce, ok := err.(*errors.CompositeError); ok { 224 return ce.ValidateName("transition") 225 } 226 return err 227 } 228 } 229 230 return nil 231 } 232 233 // MarshalBinary interface implementation 234 func (m *ObjectBucketLifecycle) 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 *ObjectBucketLifecycle) UnmarshalBinary(b []byte) error { 243 var res ObjectBucketLifecycle 244 if err := swag.ReadJSON(b, &res); err != nil { 245 return err 246 } 247 *m = res 248 return nil 249 }