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