github.com/weaviate/weaviate@v1.24.6/entities/models/batch_delete_response.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  	"strconv"
    23  
    24  	"github.com/go-openapi/errors"
    25  	"github.com/go-openapi/strfmt"
    26  	"github.com/go-openapi/swag"
    27  	"github.com/go-openapi/validate"
    28  )
    29  
    30  // BatchDeleteResponse Delete Objects response.
    31  //
    32  // swagger:model BatchDeleteResponse
    33  type BatchDeleteResponse struct {
    34  
    35  	// If true, objects will not be deleted yet, but merely listed. Defaults to false.
    36  	DryRun *bool `json:"dryRun,omitempty"`
    37  
    38  	// match
    39  	Match *BatchDeleteResponseMatch `json:"match,omitempty"`
    40  
    41  	// Controls the verbosity of the output, possible values are: "minimal", "verbose". Defaults to "minimal".
    42  	Output *string `json:"output,omitempty"`
    43  
    44  	// results
    45  	Results *BatchDeleteResponseResults `json:"results,omitempty"`
    46  }
    47  
    48  // Validate validates this batch delete response
    49  func (m *BatchDeleteResponse) Validate(formats strfmt.Registry) error {
    50  	var res []error
    51  
    52  	if err := m.validateMatch(formats); err != nil {
    53  		res = append(res, err)
    54  	}
    55  
    56  	if err := m.validateResults(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if len(res) > 0 {
    61  		return errors.CompositeValidationError(res...)
    62  	}
    63  	return nil
    64  }
    65  
    66  func (m *BatchDeleteResponse) validateMatch(formats strfmt.Registry) error {
    67  	if swag.IsZero(m.Match) { // not required
    68  		return nil
    69  	}
    70  
    71  	if m.Match != nil {
    72  		if err := m.Match.Validate(formats); err != nil {
    73  			if ve, ok := err.(*errors.Validation); ok {
    74  				return ve.ValidateName("match")
    75  			} else if ce, ok := err.(*errors.CompositeError); ok {
    76  				return ce.ValidateName("match")
    77  			}
    78  			return err
    79  		}
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  func (m *BatchDeleteResponse) validateResults(formats strfmt.Registry) error {
    86  	if swag.IsZero(m.Results) { // not required
    87  		return nil
    88  	}
    89  
    90  	if m.Results != nil {
    91  		if err := m.Results.Validate(formats); err != nil {
    92  			if ve, ok := err.(*errors.Validation); ok {
    93  				return ve.ValidateName("results")
    94  			} else if ce, ok := err.(*errors.CompositeError); ok {
    95  				return ce.ValidateName("results")
    96  			}
    97  			return err
    98  		}
    99  	}
   100  
   101  	return nil
   102  }
   103  
   104  // ContextValidate validate this batch delete response based on the context it is used
   105  func (m *BatchDeleteResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   106  	var res []error
   107  
   108  	if err := m.contextValidateMatch(ctx, formats); err != nil {
   109  		res = append(res, err)
   110  	}
   111  
   112  	if err := m.contextValidateResults(ctx, formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if len(res) > 0 {
   117  		return errors.CompositeValidationError(res...)
   118  	}
   119  	return nil
   120  }
   121  
   122  func (m *BatchDeleteResponse) contextValidateMatch(ctx context.Context, formats strfmt.Registry) error {
   123  
   124  	if m.Match != nil {
   125  		if err := m.Match.ContextValidate(ctx, formats); err != nil {
   126  			if ve, ok := err.(*errors.Validation); ok {
   127  				return ve.ValidateName("match")
   128  			} else if ce, ok := err.(*errors.CompositeError); ok {
   129  				return ce.ValidateName("match")
   130  			}
   131  			return err
   132  		}
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  func (m *BatchDeleteResponse) contextValidateResults(ctx context.Context, formats strfmt.Registry) error {
   139  
   140  	if m.Results != nil {
   141  		if err := m.Results.ContextValidate(ctx, formats); err != nil {
   142  			if ve, ok := err.(*errors.Validation); ok {
   143  				return ve.ValidateName("results")
   144  			} else if ce, ok := err.(*errors.CompositeError); ok {
   145  				return ce.ValidateName("results")
   146  			}
   147  			return err
   148  		}
   149  	}
   150  
   151  	return nil
   152  }
   153  
   154  // MarshalBinary interface implementation
   155  func (m *BatchDeleteResponse) MarshalBinary() ([]byte, error) {
   156  	if m == nil {
   157  		return nil, nil
   158  	}
   159  	return swag.WriteJSON(m)
   160  }
   161  
   162  // UnmarshalBinary interface implementation
   163  func (m *BatchDeleteResponse) UnmarshalBinary(b []byte) error {
   164  	var res BatchDeleteResponse
   165  	if err := swag.ReadJSON(b, &res); err != nil {
   166  		return err
   167  	}
   168  	*m = res
   169  	return nil
   170  }
   171  
   172  // BatchDeleteResponseMatch Outlines how to find the objects to be deleted.
   173  //
   174  // swagger:model BatchDeleteResponseMatch
   175  type BatchDeleteResponseMatch struct {
   176  
   177  	// Class (name) which objects will be deleted.
   178  	// Example: City
   179  	Class string `json:"class,omitempty"`
   180  
   181  	// Filter to limit the objects to be deleted.
   182  	Where *WhereFilter `json:"where,omitempty"`
   183  }
   184  
   185  // Validate validates this batch delete response match
   186  func (m *BatchDeleteResponseMatch) Validate(formats strfmt.Registry) error {
   187  	var res []error
   188  
   189  	if err := m.validateWhere(formats); err != nil {
   190  		res = append(res, err)
   191  	}
   192  
   193  	if len(res) > 0 {
   194  		return errors.CompositeValidationError(res...)
   195  	}
   196  	return nil
   197  }
   198  
   199  func (m *BatchDeleteResponseMatch) validateWhere(formats strfmt.Registry) error {
   200  	if swag.IsZero(m.Where) { // not required
   201  		return nil
   202  	}
   203  
   204  	if m.Where != nil {
   205  		if err := m.Where.Validate(formats); err != nil {
   206  			if ve, ok := err.(*errors.Validation); ok {
   207  				return ve.ValidateName("match" + "." + "where")
   208  			} else if ce, ok := err.(*errors.CompositeError); ok {
   209  				return ce.ValidateName("match" + "." + "where")
   210  			}
   211  			return err
   212  		}
   213  	}
   214  
   215  	return nil
   216  }
   217  
   218  // ContextValidate validate this batch delete response match based on the context it is used
   219  func (m *BatchDeleteResponseMatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   220  	var res []error
   221  
   222  	if err := m.contextValidateWhere(ctx, formats); err != nil {
   223  		res = append(res, err)
   224  	}
   225  
   226  	if len(res) > 0 {
   227  		return errors.CompositeValidationError(res...)
   228  	}
   229  	return nil
   230  }
   231  
   232  func (m *BatchDeleteResponseMatch) contextValidateWhere(ctx context.Context, formats strfmt.Registry) error {
   233  
   234  	if m.Where != nil {
   235  		if err := m.Where.ContextValidate(ctx, formats); err != nil {
   236  			if ve, ok := err.(*errors.Validation); ok {
   237  				return ve.ValidateName("match" + "." + "where")
   238  			} else if ce, ok := err.(*errors.CompositeError); ok {
   239  				return ce.ValidateName("match" + "." + "where")
   240  			}
   241  			return err
   242  		}
   243  	}
   244  
   245  	return nil
   246  }
   247  
   248  // MarshalBinary interface implementation
   249  func (m *BatchDeleteResponseMatch) MarshalBinary() ([]byte, error) {
   250  	if m == nil {
   251  		return nil, nil
   252  	}
   253  	return swag.WriteJSON(m)
   254  }
   255  
   256  // UnmarshalBinary interface implementation
   257  func (m *BatchDeleteResponseMatch) UnmarshalBinary(b []byte) error {
   258  	var res BatchDeleteResponseMatch
   259  	if err := swag.ReadJSON(b, &res); err != nil {
   260  		return err
   261  	}
   262  	*m = res
   263  	return nil
   264  }
   265  
   266  // BatchDeleteResponseResults batch delete response results
   267  //
   268  // swagger:model BatchDeleteResponseResults
   269  type BatchDeleteResponseResults struct {
   270  
   271  	// How many objects should have been deleted but could not be deleted.
   272  	Failed int64 `json:"failed"`
   273  
   274  	// The most amount of objects that can be deleted in a single query, equals QUERY_MAXIMUM_RESULTS.
   275  	Limit int64 `json:"limit"`
   276  
   277  	// How many objects were matched by the filter.
   278  	Matches int64 `json:"matches"`
   279  
   280  	// With output set to "minimal" only objects with error occurred will the be described. Successfully deleted objects would be omitted. Output set to "verbose" will list all of the objets with their respective statuses.
   281  	Objects []*BatchDeleteResponseResultsObjectsItems0 `json:"objects"`
   282  
   283  	// How many objects were successfully deleted in this round.
   284  	Successful int64 `json:"successful"`
   285  }
   286  
   287  // Validate validates this batch delete response results
   288  func (m *BatchDeleteResponseResults) Validate(formats strfmt.Registry) error {
   289  	var res []error
   290  
   291  	if err := m.validateObjects(formats); err != nil {
   292  		res = append(res, err)
   293  	}
   294  
   295  	if len(res) > 0 {
   296  		return errors.CompositeValidationError(res...)
   297  	}
   298  	return nil
   299  }
   300  
   301  func (m *BatchDeleteResponseResults) validateObjects(formats strfmt.Registry) error {
   302  	if swag.IsZero(m.Objects) { // not required
   303  		return nil
   304  	}
   305  
   306  	for i := 0; i < len(m.Objects); i++ {
   307  		if swag.IsZero(m.Objects[i]) { // not required
   308  			continue
   309  		}
   310  
   311  		if m.Objects[i] != nil {
   312  			if err := m.Objects[i].Validate(formats); err != nil {
   313  				if ve, ok := err.(*errors.Validation); ok {
   314  					return ve.ValidateName("results" + "." + "objects" + "." + strconv.Itoa(i))
   315  				} else if ce, ok := err.(*errors.CompositeError); ok {
   316  					return ce.ValidateName("results" + "." + "objects" + "." + strconv.Itoa(i))
   317  				}
   318  				return err
   319  			}
   320  		}
   321  
   322  	}
   323  
   324  	return nil
   325  }
   326  
   327  // ContextValidate validate this batch delete response results based on the context it is used
   328  func (m *BatchDeleteResponseResults) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   329  	var res []error
   330  
   331  	if err := m.contextValidateObjects(ctx, formats); err != nil {
   332  		res = append(res, err)
   333  	}
   334  
   335  	if len(res) > 0 {
   336  		return errors.CompositeValidationError(res...)
   337  	}
   338  	return nil
   339  }
   340  
   341  func (m *BatchDeleteResponseResults) contextValidateObjects(ctx context.Context, formats strfmt.Registry) error {
   342  
   343  	for i := 0; i < len(m.Objects); i++ {
   344  
   345  		if m.Objects[i] != nil {
   346  			if err := m.Objects[i].ContextValidate(ctx, formats); err != nil {
   347  				if ve, ok := err.(*errors.Validation); ok {
   348  					return ve.ValidateName("results" + "." + "objects" + "." + strconv.Itoa(i))
   349  				} else if ce, ok := err.(*errors.CompositeError); ok {
   350  					return ce.ValidateName("results" + "." + "objects" + "." + strconv.Itoa(i))
   351  				}
   352  				return err
   353  			}
   354  		}
   355  
   356  	}
   357  
   358  	return nil
   359  }
   360  
   361  // MarshalBinary interface implementation
   362  func (m *BatchDeleteResponseResults) MarshalBinary() ([]byte, error) {
   363  	if m == nil {
   364  		return nil, nil
   365  	}
   366  	return swag.WriteJSON(m)
   367  }
   368  
   369  // UnmarshalBinary interface implementation
   370  func (m *BatchDeleteResponseResults) UnmarshalBinary(b []byte) error {
   371  	var res BatchDeleteResponseResults
   372  	if err := swag.ReadJSON(b, &res); err != nil {
   373  		return err
   374  	}
   375  	*m = res
   376  	return nil
   377  }
   378  
   379  // BatchDeleteResponseResultsObjectsItems0 Results for this specific Object.
   380  //
   381  // swagger:model BatchDeleteResponseResultsObjectsItems0
   382  type BatchDeleteResponseResultsObjectsItems0 struct {
   383  
   384  	// errors
   385  	Errors *ErrorResponse `json:"errors,omitempty"`
   386  
   387  	// ID of the Object.
   388  	// Format: uuid
   389  	ID strfmt.UUID `json:"id,omitempty"`
   390  
   391  	// status
   392  	// Enum: [SUCCESS DRYRUN FAILED]
   393  	Status *string `json:"status,omitempty"`
   394  }
   395  
   396  // Validate validates this batch delete response results objects items0
   397  func (m *BatchDeleteResponseResultsObjectsItems0) Validate(formats strfmt.Registry) error {
   398  	var res []error
   399  
   400  	if err := m.validateErrors(formats); err != nil {
   401  		res = append(res, err)
   402  	}
   403  
   404  	if err := m.validateID(formats); err != nil {
   405  		res = append(res, err)
   406  	}
   407  
   408  	if err := m.validateStatus(formats); err != nil {
   409  		res = append(res, err)
   410  	}
   411  
   412  	if len(res) > 0 {
   413  		return errors.CompositeValidationError(res...)
   414  	}
   415  	return nil
   416  }
   417  
   418  func (m *BatchDeleteResponseResultsObjectsItems0) validateErrors(formats strfmt.Registry) error {
   419  	if swag.IsZero(m.Errors) { // not required
   420  		return nil
   421  	}
   422  
   423  	if m.Errors != nil {
   424  		if err := m.Errors.Validate(formats); err != nil {
   425  			if ve, ok := err.(*errors.Validation); ok {
   426  				return ve.ValidateName("errors")
   427  			} else if ce, ok := err.(*errors.CompositeError); ok {
   428  				return ce.ValidateName("errors")
   429  			}
   430  			return err
   431  		}
   432  	}
   433  
   434  	return nil
   435  }
   436  
   437  func (m *BatchDeleteResponseResultsObjectsItems0) validateID(formats strfmt.Registry) error {
   438  	if swag.IsZero(m.ID) { // not required
   439  		return nil
   440  	}
   441  
   442  	if err := validate.FormatOf("id", "body", "uuid", m.ID.String(), formats); err != nil {
   443  		return err
   444  	}
   445  
   446  	return nil
   447  }
   448  
   449  var batchDeleteResponseResultsObjectsItems0TypeStatusPropEnum []interface{}
   450  
   451  func init() {
   452  	var res []string
   453  	if err := json.Unmarshal([]byte(`["SUCCESS","DRYRUN","FAILED"]`), &res); err != nil {
   454  		panic(err)
   455  	}
   456  	for _, v := range res {
   457  		batchDeleteResponseResultsObjectsItems0TypeStatusPropEnum = append(batchDeleteResponseResultsObjectsItems0TypeStatusPropEnum, v)
   458  	}
   459  }
   460  
   461  const (
   462  
   463  	// BatchDeleteResponseResultsObjectsItems0StatusSUCCESS captures enum value "SUCCESS"
   464  	BatchDeleteResponseResultsObjectsItems0StatusSUCCESS string = "SUCCESS"
   465  
   466  	// BatchDeleteResponseResultsObjectsItems0StatusDRYRUN captures enum value "DRYRUN"
   467  	BatchDeleteResponseResultsObjectsItems0StatusDRYRUN string = "DRYRUN"
   468  
   469  	// BatchDeleteResponseResultsObjectsItems0StatusFAILED captures enum value "FAILED"
   470  	BatchDeleteResponseResultsObjectsItems0StatusFAILED string = "FAILED"
   471  )
   472  
   473  // prop value enum
   474  func (m *BatchDeleteResponseResultsObjectsItems0) validateStatusEnum(path, location string, value string) error {
   475  	if err := validate.EnumCase(path, location, value, batchDeleteResponseResultsObjectsItems0TypeStatusPropEnum, true); err != nil {
   476  		return err
   477  	}
   478  	return nil
   479  }
   480  
   481  func (m *BatchDeleteResponseResultsObjectsItems0) validateStatus(formats strfmt.Registry) error {
   482  	if swag.IsZero(m.Status) { // not required
   483  		return nil
   484  	}
   485  
   486  	// value enum
   487  	if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
   488  		return err
   489  	}
   490  
   491  	return nil
   492  }
   493  
   494  // ContextValidate validate this batch delete response results objects items0 based on the context it is used
   495  func (m *BatchDeleteResponseResultsObjectsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   496  	var res []error
   497  
   498  	if err := m.contextValidateErrors(ctx, formats); err != nil {
   499  		res = append(res, err)
   500  	}
   501  
   502  	if len(res) > 0 {
   503  		return errors.CompositeValidationError(res...)
   504  	}
   505  	return nil
   506  }
   507  
   508  func (m *BatchDeleteResponseResultsObjectsItems0) contextValidateErrors(ctx context.Context, formats strfmt.Registry) error {
   509  
   510  	if m.Errors != nil {
   511  		if err := m.Errors.ContextValidate(ctx, formats); err != nil {
   512  			if ve, ok := err.(*errors.Validation); ok {
   513  				return ve.ValidateName("errors")
   514  			} else if ce, ok := err.(*errors.CompositeError); ok {
   515  				return ce.ValidateName("errors")
   516  			}
   517  			return err
   518  		}
   519  	}
   520  
   521  	return nil
   522  }
   523  
   524  // MarshalBinary interface implementation
   525  func (m *BatchDeleteResponseResultsObjectsItems0) MarshalBinary() ([]byte, error) {
   526  	if m == nil {
   527  		return nil, nil
   528  	}
   529  	return swag.WriteJSON(m)
   530  }
   531  
   532  // UnmarshalBinary interface implementation
   533  func (m *BatchDeleteResponseResultsObjectsItems0) UnmarshalBinary(b []byte) error {
   534  	var res BatchDeleteResponseResultsObjectsItems0
   535  	if err := swag.ReadJSON(b, &res); err != nil {
   536  		return err
   537  	}
   538  	*m = res
   539  	return nil
   540  }