github.com/weaviate/weaviate@v1.24.6/entities/models/objects_list_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  	"strconv"
    22  
    23  	"github.com/go-openapi/errors"
    24  	"github.com/go-openapi/strfmt"
    25  	"github.com/go-openapi/swag"
    26  )
    27  
    28  // ObjectsListResponse List of Objects.
    29  //
    30  // swagger:model ObjectsListResponse
    31  type ObjectsListResponse struct {
    32  
    33  	// deprecations
    34  	Deprecations []*Deprecation `json:"deprecations"`
    35  
    36  	// The actual list of Objects.
    37  	Objects []*Object `json:"objects"`
    38  
    39  	// The total number of Objects for the query. The number of items in a response may be smaller due to paging.
    40  	TotalResults int64 `json:"totalResults,omitempty"`
    41  }
    42  
    43  // Validate validates this objects list response
    44  func (m *ObjectsListResponse) Validate(formats strfmt.Registry) error {
    45  	var res []error
    46  
    47  	if err := m.validateDeprecations(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validateObjects(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if len(res) > 0 {
    56  		return errors.CompositeValidationError(res...)
    57  	}
    58  	return nil
    59  }
    60  
    61  func (m *ObjectsListResponse) validateDeprecations(formats strfmt.Registry) error {
    62  	if swag.IsZero(m.Deprecations) { // not required
    63  		return nil
    64  	}
    65  
    66  	for i := 0; i < len(m.Deprecations); i++ {
    67  		if swag.IsZero(m.Deprecations[i]) { // not required
    68  			continue
    69  		}
    70  
    71  		if m.Deprecations[i] != nil {
    72  			if err := m.Deprecations[i].Validate(formats); err != nil {
    73  				if ve, ok := err.(*errors.Validation); ok {
    74  					return ve.ValidateName("deprecations" + "." + strconv.Itoa(i))
    75  				} else if ce, ok := err.(*errors.CompositeError); ok {
    76  					return ce.ValidateName("deprecations" + "." + strconv.Itoa(i))
    77  				}
    78  				return err
    79  			}
    80  		}
    81  
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  func (m *ObjectsListResponse) validateObjects(formats strfmt.Registry) error {
    88  	if swag.IsZero(m.Objects) { // not required
    89  		return nil
    90  	}
    91  
    92  	for i := 0; i < len(m.Objects); i++ {
    93  		if swag.IsZero(m.Objects[i]) { // not required
    94  			continue
    95  		}
    96  
    97  		if m.Objects[i] != nil {
    98  			if err := m.Objects[i].Validate(formats); err != nil {
    99  				if ve, ok := err.(*errors.Validation); ok {
   100  					return ve.ValidateName("objects" + "." + strconv.Itoa(i))
   101  				} else if ce, ok := err.(*errors.CompositeError); ok {
   102  					return ce.ValidateName("objects" + "." + strconv.Itoa(i))
   103  				}
   104  				return err
   105  			}
   106  		}
   107  
   108  	}
   109  
   110  	return nil
   111  }
   112  
   113  // ContextValidate validate this objects list response based on the context it is used
   114  func (m *ObjectsListResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   115  	var res []error
   116  
   117  	if err := m.contextValidateDeprecations(ctx, formats); err != nil {
   118  		res = append(res, err)
   119  	}
   120  
   121  	if err := m.contextValidateObjects(ctx, formats); err != nil {
   122  		res = append(res, err)
   123  	}
   124  
   125  	if len(res) > 0 {
   126  		return errors.CompositeValidationError(res...)
   127  	}
   128  	return nil
   129  }
   130  
   131  func (m *ObjectsListResponse) contextValidateDeprecations(ctx context.Context, formats strfmt.Registry) error {
   132  
   133  	for i := 0; i < len(m.Deprecations); i++ {
   134  
   135  		if m.Deprecations[i] != nil {
   136  			if err := m.Deprecations[i].ContextValidate(ctx, formats); err != nil {
   137  				if ve, ok := err.(*errors.Validation); ok {
   138  					return ve.ValidateName("deprecations" + "." + strconv.Itoa(i))
   139  				} else if ce, ok := err.(*errors.CompositeError); ok {
   140  					return ce.ValidateName("deprecations" + "." + strconv.Itoa(i))
   141  				}
   142  				return err
   143  			}
   144  		}
   145  
   146  	}
   147  
   148  	return nil
   149  }
   150  
   151  func (m *ObjectsListResponse) contextValidateObjects(ctx context.Context, formats strfmt.Registry) error {
   152  
   153  	for i := 0; i < len(m.Objects); i++ {
   154  
   155  		if m.Objects[i] != nil {
   156  			if err := m.Objects[i].ContextValidate(ctx, formats); err != nil {
   157  				if ve, ok := err.(*errors.Validation); ok {
   158  					return ve.ValidateName("objects" + "." + strconv.Itoa(i))
   159  				} else if ce, ok := err.(*errors.CompositeError); ok {
   160  					return ce.ValidateName("objects" + "." + strconv.Itoa(i))
   161  				}
   162  				return err
   163  			}
   164  		}
   165  
   166  	}
   167  
   168  	return nil
   169  }
   170  
   171  // MarshalBinary interface implementation
   172  func (m *ObjectsListResponse) MarshalBinary() ([]byte, error) {
   173  	if m == nil {
   174  		return nil, nil
   175  	}
   176  	return swag.WriteJSON(m)
   177  }
   178  
   179  // UnmarshalBinary interface implementation
   180  func (m *ObjectsListResponse) UnmarshalBinary(b []byte) error {
   181  	var res ObjectsListResponse
   182  	if err := swag.ReadJSON(b, &res); err != nil {
   183  		return err
   184  	}
   185  	*m = res
   186  	return nil
   187  }