github.com/weaviate/weaviate@v1.24.6/entities/models/backup_config.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 "encoding/json" 22 23 "github.com/go-openapi/errors" 24 "github.com/go-openapi/strfmt" 25 "github.com/go-openapi/swag" 26 "github.com/go-openapi/validate" 27 ) 28 29 // BackupConfig Backup custom configuration 30 // 31 // swagger:model BackupConfig 32 type BackupConfig struct { 33 34 // Desired CPU core utilization ranging from 1%-80% 35 // Maximum: 80 36 // Minimum: 1 37 CPUPercentage int64 `json:"CPUPercentage,omitempty"` 38 39 // Weaviate will attempt to come close the specified size, with a minimum of 2MB, default of 128MB, and a maximum of 512MB 40 // Maximum: 512 41 // Minimum: 2 42 ChunkSize int64 `json:"ChunkSize,omitempty"` 43 44 // compression level used by compression algorithm 45 // Enum: [DefaultCompression BestSpeed BestCompression] 46 CompressionLevel string `json:"CompressionLevel,omitempty"` 47 } 48 49 // Validate validates this backup config 50 func (m *BackupConfig) Validate(formats strfmt.Registry) error { 51 var res []error 52 53 if err := m.validateCPUPercentage(formats); err != nil { 54 res = append(res, err) 55 } 56 57 if err := m.validateChunkSize(formats); err != nil { 58 res = append(res, err) 59 } 60 61 if err := m.validateCompressionLevel(formats); err != nil { 62 res = append(res, err) 63 } 64 65 if len(res) > 0 { 66 return errors.CompositeValidationError(res...) 67 } 68 return nil 69 } 70 71 func (m *BackupConfig) validateCPUPercentage(formats strfmt.Registry) error { 72 if swag.IsZero(m.CPUPercentage) { // not required 73 return nil 74 } 75 76 if err := validate.MinimumInt("CPUPercentage", "body", m.CPUPercentage, 1, false); err != nil { 77 return err 78 } 79 80 if err := validate.MaximumInt("CPUPercentage", "body", m.CPUPercentage, 80, false); err != nil { 81 return err 82 } 83 84 return nil 85 } 86 87 func (m *BackupConfig) validateChunkSize(formats strfmt.Registry) error { 88 if swag.IsZero(m.ChunkSize) { // not required 89 return nil 90 } 91 92 if err := validate.MinimumInt("ChunkSize", "body", m.ChunkSize, 2, false); err != nil { 93 return err 94 } 95 96 if err := validate.MaximumInt("ChunkSize", "body", m.ChunkSize, 512, false); err != nil { 97 return err 98 } 99 100 return nil 101 } 102 103 var backupConfigTypeCompressionLevelPropEnum []interface{} 104 105 func init() { 106 var res []string 107 if err := json.Unmarshal([]byte(`["DefaultCompression","BestSpeed","BestCompression"]`), &res); err != nil { 108 panic(err) 109 } 110 for _, v := range res { 111 backupConfigTypeCompressionLevelPropEnum = append(backupConfigTypeCompressionLevelPropEnum, v) 112 } 113 } 114 115 const ( 116 117 // BackupConfigCompressionLevelDefaultCompression captures enum value "DefaultCompression" 118 BackupConfigCompressionLevelDefaultCompression string = "DefaultCompression" 119 120 // BackupConfigCompressionLevelBestSpeed captures enum value "BestSpeed" 121 BackupConfigCompressionLevelBestSpeed string = "BestSpeed" 122 123 // BackupConfigCompressionLevelBestCompression captures enum value "BestCompression" 124 BackupConfigCompressionLevelBestCompression string = "BestCompression" 125 ) 126 127 // prop value enum 128 func (m *BackupConfig) validateCompressionLevelEnum(path, location string, value string) error { 129 if err := validate.EnumCase(path, location, value, backupConfigTypeCompressionLevelPropEnum, true); err != nil { 130 return err 131 } 132 return nil 133 } 134 135 func (m *BackupConfig) validateCompressionLevel(formats strfmt.Registry) error { 136 if swag.IsZero(m.CompressionLevel) { // not required 137 return nil 138 } 139 140 // value enum 141 if err := m.validateCompressionLevelEnum("CompressionLevel", "body", m.CompressionLevel); err != nil { 142 return err 143 } 144 145 return nil 146 } 147 148 // ContextValidate validates this backup config based on context it is used 149 func (m *BackupConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 150 return nil 151 } 152 153 // MarshalBinary interface implementation 154 func (m *BackupConfig) MarshalBinary() ([]byte, error) { 155 if m == nil { 156 return nil, nil 157 } 158 return swag.WriteJSON(m) 159 } 160 161 // UnmarshalBinary interface implementation 162 func (m *BackupConfig) UnmarshalBinary(b []byte) error { 163 var res BackupConfig 164 if err := swag.ReadJSON(b, &res); err != nil { 165 return err 166 } 167 *m = res 168 return nil 169 }