github.com/weaviate/weaviate@v1.24.6/entities/models/objects_get_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  // ObjectsGetResponse objects get response
    31  //
    32  // swagger:model ObjectsGetResponse
    33  type ObjectsGetResponse struct {
    34  	Object
    35  
    36  	// deprecations
    37  	Deprecations []*Deprecation `json:"deprecations"`
    38  
    39  	// result
    40  	Result *ObjectsGetResponseAO2Result `json:"result,omitempty"`
    41  }
    42  
    43  // UnmarshalJSON unmarshals this object from a JSON structure
    44  func (m *ObjectsGetResponse) UnmarshalJSON(raw []byte) error {
    45  	// AO0
    46  	var aO0 Object
    47  	if err := swag.ReadJSON(raw, &aO0); err != nil {
    48  		return err
    49  	}
    50  	m.Object = aO0
    51  
    52  	// AO1
    53  	var dataAO1 struct {
    54  		Deprecations []*Deprecation `json:"deprecations"`
    55  	}
    56  	if err := swag.ReadJSON(raw, &dataAO1); err != nil {
    57  		return err
    58  	}
    59  
    60  	m.Deprecations = dataAO1.Deprecations
    61  
    62  	// AO2
    63  	var dataAO2 struct {
    64  		Result *ObjectsGetResponseAO2Result `json:"result,omitempty"`
    65  	}
    66  	if err := swag.ReadJSON(raw, &dataAO2); err != nil {
    67  		return err
    68  	}
    69  
    70  	m.Result = dataAO2.Result
    71  
    72  	return nil
    73  }
    74  
    75  // MarshalJSON marshals this object to a JSON structure
    76  func (m ObjectsGetResponse) MarshalJSON() ([]byte, error) {
    77  	_parts := make([][]byte, 0, 3)
    78  
    79  	aO0, err := swag.WriteJSON(m.Object)
    80  	if err != nil {
    81  		return nil, err
    82  	}
    83  	_parts = append(_parts, aO0)
    84  	var dataAO1 struct {
    85  		Deprecations []*Deprecation `json:"deprecations"`
    86  	}
    87  
    88  	dataAO1.Deprecations = m.Deprecations
    89  
    90  	jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
    91  	if errAO1 != nil {
    92  		return nil, errAO1
    93  	}
    94  	_parts = append(_parts, jsonDataAO1)
    95  	var dataAO2 struct {
    96  		Result *ObjectsGetResponseAO2Result `json:"result,omitempty"`
    97  	}
    98  
    99  	dataAO2.Result = m.Result
   100  
   101  	jsonDataAO2, errAO2 := swag.WriteJSON(dataAO2)
   102  	if errAO2 != nil {
   103  		return nil, errAO2
   104  	}
   105  	_parts = append(_parts, jsonDataAO2)
   106  	return swag.ConcatJSON(_parts...), nil
   107  }
   108  
   109  // Validate validates this objects get response
   110  func (m *ObjectsGetResponse) Validate(formats strfmt.Registry) error {
   111  	var res []error
   112  
   113  	// validation for a type composition with Object
   114  	if err := m.Object.Validate(formats); err != nil {
   115  		res = append(res, err)
   116  	}
   117  
   118  	if err := m.validateDeprecations(formats); err != nil {
   119  		res = append(res, err)
   120  	}
   121  
   122  	if err := m.validateResult(formats); err != nil {
   123  		res = append(res, err)
   124  	}
   125  
   126  	if len(res) > 0 {
   127  		return errors.CompositeValidationError(res...)
   128  	}
   129  	return nil
   130  }
   131  
   132  func (m *ObjectsGetResponse) validateDeprecations(formats strfmt.Registry) error {
   133  
   134  	if swag.IsZero(m.Deprecations) { // not required
   135  		return nil
   136  	}
   137  
   138  	for i := 0; i < len(m.Deprecations); i++ {
   139  		if swag.IsZero(m.Deprecations[i]) { // not required
   140  			continue
   141  		}
   142  
   143  		if m.Deprecations[i] != nil {
   144  			if err := m.Deprecations[i].Validate(formats); err != nil {
   145  				if ve, ok := err.(*errors.Validation); ok {
   146  					return ve.ValidateName("deprecations" + "." + strconv.Itoa(i))
   147  				} else if ce, ok := err.(*errors.CompositeError); ok {
   148  					return ce.ValidateName("deprecations" + "." + strconv.Itoa(i))
   149  				}
   150  				return err
   151  			}
   152  		}
   153  
   154  	}
   155  
   156  	return nil
   157  }
   158  
   159  func (m *ObjectsGetResponse) validateResult(formats strfmt.Registry) error {
   160  
   161  	if swag.IsZero(m.Result) { // not required
   162  		return nil
   163  	}
   164  
   165  	if m.Result != nil {
   166  		if err := m.Result.Validate(formats); err != nil {
   167  			if ve, ok := err.(*errors.Validation); ok {
   168  				return ve.ValidateName("result")
   169  			} else if ce, ok := err.(*errors.CompositeError); ok {
   170  				return ce.ValidateName("result")
   171  			}
   172  			return err
   173  		}
   174  	}
   175  
   176  	return nil
   177  }
   178  
   179  // ContextValidate validate this objects get response based on the context it is used
   180  func (m *ObjectsGetResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   181  	var res []error
   182  
   183  	// validation for a type composition with Object
   184  	if err := m.Object.ContextValidate(ctx, formats); err != nil {
   185  		res = append(res, err)
   186  	}
   187  
   188  	if err := m.contextValidateDeprecations(ctx, formats); err != nil {
   189  		res = append(res, err)
   190  	}
   191  
   192  	if err := m.contextValidateResult(ctx, formats); err != nil {
   193  		res = append(res, err)
   194  	}
   195  
   196  	if len(res) > 0 {
   197  		return errors.CompositeValidationError(res...)
   198  	}
   199  	return nil
   200  }
   201  
   202  func (m *ObjectsGetResponse) contextValidateDeprecations(ctx context.Context, formats strfmt.Registry) error {
   203  
   204  	for i := 0; i < len(m.Deprecations); i++ {
   205  
   206  		if m.Deprecations[i] != nil {
   207  			if err := m.Deprecations[i].ContextValidate(ctx, formats); err != nil {
   208  				if ve, ok := err.(*errors.Validation); ok {
   209  					return ve.ValidateName("deprecations" + "." + strconv.Itoa(i))
   210  				} else if ce, ok := err.(*errors.CompositeError); ok {
   211  					return ce.ValidateName("deprecations" + "." + strconv.Itoa(i))
   212  				}
   213  				return err
   214  			}
   215  		}
   216  
   217  	}
   218  
   219  	return nil
   220  }
   221  
   222  func (m *ObjectsGetResponse) contextValidateResult(ctx context.Context, formats strfmt.Registry) error {
   223  
   224  	if m.Result != nil {
   225  		if err := m.Result.ContextValidate(ctx, formats); err != nil {
   226  			if ve, ok := err.(*errors.Validation); ok {
   227  				return ve.ValidateName("result")
   228  			} else if ce, ok := err.(*errors.CompositeError); ok {
   229  				return ce.ValidateName("result")
   230  			}
   231  			return err
   232  		}
   233  	}
   234  
   235  	return nil
   236  }
   237  
   238  // MarshalBinary interface implementation
   239  func (m *ObjectsGetResponse) MarshalBinary() ([]byte, error) {
   240  	if m == nil {
   241  		return nil, nil
   242  	}
   243  	return swag.WriteJSON(m)
   244  }
   245  
   246  // UnmarshalBinary interface implementation
   247  func (m *ObjectsGetResponse) UnmarshalBinary(b []byte) error {
   248  	var res ObjectsGetResponse
   249  	if err := swag.ReadJSON(b, &res); err != nil {
   250  		return err
   251  	}
   252  	*m = res
   253  	return nil
   254  }
   255  
   256  // ObjectsGetResponseAO2Result Results for this specific Object.
   257  //
   258  // swagger:model ObjectsGetResponseAO2Result
   259  type ObjectsGetResponseAO2Result struct {
   260  
   261  	// errors
   262  	Errors *ErrorResponse `json:"errors,omitempty"`
   263  
   264  	// status
   265  	// Enum: [SUCCESS PENDING FAILED]
   266  	Status *string `json:"status,omitempty"`
   267  }
   268  
   269  // Validate validates this objects get response a o2 result
   270  func (m *ObjectsGetResponseAO2Result) Validate(formats strfmt.Registry) error {
   271  	var res []error
   272  
   273  	if err := m.validateErrors(formats); err != nil {
   274  		res = append(res, err)
   275  	}
   276  
   277  	if err := m.validateStatus(formats); err != nil {
   278  		res = append(res, err)
   279  	}
   280  
   281  	if len(res) > 0 {
   282  		return errors.CompositeValidationError(res...)
   283  	}
   284  	return nil
   285  }
   286  
   287  func (m *ObjectsGetResponseAO2Result) validateErrors(formats strfmt.Registry) error {
   288  	if swag.IsZero(m.Errors) { // not required
   289  		return nil
   290  	}
   291  
   292  	if m.Errors != nil {
   293  		if err := m.Errors.Validate(formats); err != nil {
   294  			if ve, ok := err.(*errors.Validation); ok {
   295  				return ve.ValidateName("result" + "." + "errors")
   296  			} else if ce, ok := err.(*errors.CompositeError); ok {
   297  				return ce.ValidateName("result" + "." + "errors")
   298  			}
   299  			return err
   300  		}
   301  	}
   302  
   303  	return nil
   304  }
   305  
   306  var objectsGetResponseAO2ResultTypeStatusPropEnum []interface{}
   307  
   308  func init() {
   309  	var res []string
   310  	if err := json.Unmarshal([]byte(`["SUCCESS","PENDING","FAILED"]`), &res); err != nil {
   311  		panic(err)
   312  	}
   313  	for _, v := range res {
   314  		objectsGetResponseAO2ResultTypeStatusPropEnum = append(objectsGetResponseAO2ResultTypeStatusPropEnum, v)
   315  	}
   316  }
   317  
   318  const (
   319  
   320  	// ObjectsGetResponseAO2ResultStatusSUCCESS captures enum value "SUCCESS"
   321  	ObjectsGetResponseAO2ResultStatusSUCCESS string = "SUCCESS"
   322  
   323  	// ObjectsGetResponseAO2ResultStatusPENDING captures enum value "PENDING"
   324  	ObjectsGetResponseAO2ResultStatusPENDING string = "PENDING"
   325  
   326  	// ObjectsGetResponseAO2ResultStatusFAILED captures enum value "FAILED"
   327  	ObjectsGetResponseAO2ResultStatusFAILED string = "FAILED"
   328  )
   329  
   330  // prop value enum
   331  func (m *ObjectsGetResponseAO2Result) validateStatusEnum(path, location string, value string) error {
   332  	if err := validate.EnumCase(path, location, value, objectsGetResponseAO2ResultTypeStatusPropEnum, true); err != nil {
   333  		return err
   334  	}
   335  	return nil
   336  }
   337  
   338  func (m *ObjectsGetResponseAO2Result) validateStatus(formats strfmt.Registry) error {
   339  	if swag.IsZero(m.Status) { // not required
   340  		return nil
   341  	}
   342  
   343  	// value enum
   344  	if err := m.validateStatusEnum("result"+"."+"status", "body", *m.Status); err != nil {
   345  		return err
   346  	}
   347  
   348  	return nil
   349  }
   350  
   351  // ContextValidate validate this objects get response a o2 result based on the context it is used
   352  func (m *ObjectsGetResponseAO2Result) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   353  	var res []error
   354  
   355  	if err := m.contextValidateErrors(ctx, formats); err != nil {
   356  		res = append(res, err)
   357  	}
   358  
   359  	if len(res) > 0 {
   360  		return errors.CompositeValidationError(res...)
   361  	}
   362  	return nil
   363  }
   364  
   365  func (m *ObjectsGetResponseAO2Result) contextValidateErrors(ctx context.Context, formats strfmt.Registry) error {
   366  
   367  	if m.Errors != nil {
   368  		if err := m.Errors.ContextValidate(ctx, formats); err != nil {
   369  			if ve, ok := err.(*errors.Validation); ok {
   370  				return ve.ValidateName("result" + "." + "errors")
   371  			} else if ce, ok := err.(*errors.CompositeError); ok {
   372  				return ce.ValidateName("result" + "." + "errors")
   373  			}
   374  			return err
   375  		}
   376  	}
   377  
   378  	return nil
   379  }
   380  
   381  // MarshalBinary interface implementation
   382  func (m *ObjectsGetResponseAO2Result) MarshalBinary() ([]byte, error) {
   383  	if m == nil {
   384  		return nil, nil
   385  	}
   386  	return swag.WriteJSON(m)
   387  }
   388  
   389  // UnmarshalBinary interface implementation
   390  func (m *ObjectsGetResponseAO2Result) UnmarshalBinary(b []byte) error {
   391  	var res ObjectsGetResponseAO2Result
   392  	if err := swag.ReadJSON(b, &res); err != nil {
   393  		return err
   394  	}
   395  	*m = res
   396  	return nil
   397  }