github.com/weaviate/weaviate@v1.24.6/entities/models/batch_delete.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 22 "github.com/go-openapi/errors" 23 "github.com/go-openapi/strfmt" 24 "github.com/go-openapi/swag" 25 ) 26 27 // BatchDelete batch delete 28 // 29 // swagger:model BatchDelete 30 type BatchDelete struct { 31 32 // If true, objects will not be deleted yet, but merely listed. Defaults to false. 33 DryRun *bool `json:"dryRun,omitempty"` 34 35 // match 36 Match *BatchDeleteMatch `json:"match,omitempty"` 37 38 // Controls the verbosity of the output, possible values are: "minimal", "verbose". Defaults to "minimal". 39 Output *string `json:"output,omitempty"` 40 } 41 42 // Validate validates this batch delete 43 func (m *BatchDelete) Validate(formats strfmt.Registry) error { 44 var res []error 45 46 if err := m.validateMatch(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if len(res) > 0 { 51 return errors.CompositeValidationError(res...) 52 } 53 return nil 54 } 55 56 func (m *BatchDelete) validateMatch(formats strfmt.Registry) error { 57 if swag.IsZero(m.Match) { // not required 58 return nil 59 } 60 61 if m.Match != nil { 62 if err := m.Match.Validate(formats); err != nil { 63 if ve, ok := err.(*errors.Validation); ok { 64 return ve.ValidateName("match") 65 } else if ce, ok := err.(*errors.CompositeError); ok { 66 return ce.ValidateName("match") 67 } 68 return err 69 } 70 } 71 72 return nil 73 } 74 75 // ContextValidate validate this batch delete based on the context it is used 76 func (m *BatchDelete) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 var res []error 78 79 if err := m.contextValidateMatch(ctx, formats); err != nil { 80 res = append(res, err) 81 } 82 83 if len(res) > 0 { 84 return errors.CompositeValidationError(res...) 85 } 86 return nil 87 } 88 89 func (m *BatchDelete) contextValidateMatch(ctx context.Context, formats strfmt.Registry) error { 90 91 if m.Match != nil { 92 if err := m.Match.ContextValidate(ctx, formats); err != nil { 93 if ve, ok := err.(*errors.Validation); ok { 94 return ve.ValidateName("match") 95 } else if ce, ok := err.(*errors.CompositeError); ok { 96 return ce.ValidateName("match") 97 } 98 return err 99 } 100 } 101 102 return nil 103 } 104 105 // MarshalBinary interface implementation 106 func (m *BatchDelete) MarshalBinary() ([]byte, error) { 107 if m == nil { 108 return nil, nil 109 } 110 return swag.WriteJSON(m) 111 } 112 113 // UnmarshalBinary interface implementation 114 func (m *BatchDelete) UnmarshalBinary(b []byte) error { 115 var res BatchDelete 116 if err := swag.ReadJSON(b, &res); err != nil { 117 return err 118 } 119 *m = res 120 return nil 121 } 122 123 // BatchDeleteMatch Outlines how to find the objects to be deleted. 124 // 125 // swagger:model BatchDeleteMatch 126 type BatchDeleteMatch struct { 127 128 // Class (name) which objects will be deleted. 129 // Example: City 130 Class string `json:"class,omitempty"` 131 132 // Filter to limit the objects to be deleted. 133 Where *WhereFilter `json:"where,omitempty"` 134 } 135 136 // Validate validates this batch delete match 137 func (m *BatchDeleteMatch) Validate(formats strfmt.Registry) error { 138 var res []error 139 140 if err := m.validateWhere(formats); err != nil { 141 res = append(res, err) 142 } 143 144 if len(res) > 0 { 145 return errors.CompositeValidationError(res...) 146 } 147 return nil 148 } 149 150 func (m *BatchDeleteMatch) validateWhere(formats strfmt.Registry) error { 151 if swag.IsZero(m.Where) { // not required 152 return nil 153 } 154 155 if m.Where != nil { 156 if err := m.Where.Validate(formats); err != nil { 157 if ve, ok := err.(*errors.Validation); ok { 158 return ve.ValidateName("match" + "." + "where") 159 } else if ce, ok := err.(*errors.CompositeError); ok { 160 return ce.ValidateName("match" + "." + "where") 161 } 162 return err 163 } 164 } 165 166 return nil 167 } 168 169 // ContextValidate validate this batch delete match based on the context it is used 170 func (m *BatchDeleteMatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 171 var res []error 172 173 if err := m.contextValidateWhere(ctx, formats); err != nil { 174 res = append(res, err) 175 } 176 177 if len(res) > 0 { 178 return errors.CompositeValidationError(res...) 179 } 180 return nil 181 } 182 183 func (m *BatchDeleteMatch) contextValidateWhere(ctx context.Context, formats strfmt.Registry) error { 184 185 if m.Where != nil { 186 if err := m.Where.ContextValidate(ctx, formats); err != nil { 187 if ve, ok := err.(*errors.Validation); ok { 188 return ve.ValidateName("match" + "." + "where") 189 } else if ce, ok := err.(*errors.CompositeError); ok { 190 return ce.ValidateName("match" + "." + "where") 191 } 192 return err 193 } 194 } 195 196 return nil 197 } 198 199 // MarshalBinary interface implementation 200 func (m *BatchDeleteMatch) MarshalBinary() ([]byte, error) { 201 if m == nil { 202 return nil, nil 203 } 204 return swag.WriteJSON(m) 205 } 206 207 // UnmarshalBinary interface implementation 208 func (m *BatchDeleteMatch) UnmarshalBinary(b []byte) error { 209 var res BatchDeleteMatch 210 if err := swag.ReadJSON(b, &res); err != nil { 211 return err 212 } 213 *m = res 214 return nil 215 }