github.com/weaviate/weaviate@v1.24.6/entities/models/node_status.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  // NodeStatus The definition of a backup node status response body
    31  //
    32  // swagger:model NodeStatus
    33  type NodeStatus struct {
    34  
    35  	// Weaviate batch statistics.
    36  	BatchStats *BatchStats `json:"batchStats,omitempty"`
    37  
    38  	// The gitHash of Weaviate.
    39  	GitHash string `json:"gitHash,omitempty"`
    40  
    41  	// The name of the node.
    42  	Name string `json:"name,omitempty"`
    43  
    44  	// The list of the shards with it's statistics.
    45  	Shards []*NodeShardStatus `json:"shards"`
    46  
    47  	// Weaviate overall statistics.
    48  	Stats *NodeStats `json:"stats,omitempty"`
    49  
    50  	// Node's status.
    51  	// Enum: [HEALTHY UNHEALTHY UNAVAILABLE TIMEOUT]
    52  	Status *string `json:"status,omitempty"`
    53  
    54  	// The version of Weaviate.
    55  	Version string `json:"version,omitempty"`
    56  }
    57  
    58  // Validate validates this node status
    59  func (m *NodeStatus) Validate(formats strfmt.Registry) error {
    60  	var res []error
    61  
    62  	if err := m.validateBatchStats(formats); err != nil {
    63  		res = append(res, err)
    64  	}
    65  
    66  	if err := m.validateShards(formats); err != nil {
    67  		res = append(res, err)
    68  	}
    69  
    70  	if err := m.validateStats(formats); err != nil {
    71  		res = append(res, err)
    72  	}
    73  
    74  	if err := m.validateStatus(formats); err != nil {
    75  		res = append(res, err)
    76  	}
    77  
    78  	if len(res) > 0 {
    79  		return errors.CompositeValidationError(res...)
    80  	}
    81  	return nil
    82  }
    83  
    84  func (m *NodeStatus) validateBatchStats(formats strfmt.Registry) error {
    85  	if swag.IsZero(m.BatchStats) { // not required
    86  		return nil
    87  	}
    88  
    89  	if m.BatchStats != nil {
    90  		if err := m.BatchStats.Validate(formats); err != nil {
    91  			if ve, ok := err.(*errors.Validation); ok {
    92  				return ve.ValidateName("batchStats")
    93  			} else if ce, ok := err.(*errors.CompositeError); ok {
    94  				return ce.ValidateName("batchStats")
    95  			}
    96  			return err
    97  		}
    98  	}
    99  
   100  	return nil
   101  }
   102  
   103  func (m *NodeStatus) validateShards(formats strfmt.Registry) error {
   104  	if swag.IsZero(m.Shards) { // not required
   105  		return nil
   106  	}
   107  
   108  	for i := 0; i < len(m.Shards); i++ {
   109  		if swag.IsZero(m.Shards[i]) { // not required
   110  			continue
   111  		}
   112  
   113  		if m.Shards[i] != nil {
   114  			if err := m.Shards[i].Validate(formats); err != nil {
   115  				if ve, ok := err.(*errors.Validation); ok {
   116  					return ve.ValidateName("shards" + "." + strconv.Itoa(i))
   117  				} else if ce, ok := err.(*errors.CompositeError); ok {
   118  					return ce.ValidateName("shards" + "." + strconv.Itoa(i))
   119  				}
   120  				return err
   121  			}
   122  		}
   123  
   124  	}
   125  
   126  	return nil
   127  }
   128  
   129  func (m *NodeStatus) validateStats(formats strfmt.Registry) error {
   130  	if swag.IsZero(m.Stats) { // not required
   131  		return nil
   132  	}
   133  
   134  	if m.Stats != nil {
   135  		if err := m.Stats.Validate(formats); err != nil {
   136  			if ve, ok := err.(*errors.Validation); ok {
   137  				return ve.ValidateName("stats")
   138  			} else if ce, ok := err.(*errors.CompositeError); ok {
   139  				return ce.ValidateName("stats")
   140  			}
   141  			return err
   142  		}
   143  	}
   144  
   145  	return nil
   146  }
   147  
   148  var nodeStatusTypeStatusPropEnum []interface{}
   149  
   150  func init() {
   151  	var res []string
   152  	if err := json.Unmarshal([]byte(`["HEALTHY","UNHEALTHY","UNAVAILABLE","TIMEOUT"]`), &res); err != nil {
   153  		panic(err)
   154  	}
   155  	for _, v := range res {
   156  		nodeStatusTypeStatusPropEnum = append(nodeStatusTypeStatusPropEnum, v)
   157  	}
   158  }
   159  
   160  const (
   161  
   162  	// NodeStatusStatusHEALTHY captures enum value "HEALTHY"
   163  	NodeStatusStatusHEALTHY string = "HEALTHY"
   164  
   165  	// NodeStatusStatusUNHEALTHY captures enum value "UNHEALTHY"
   166  	NodeStatusStatusUNHEALTHY string = "UNHEALTHY"
   167  
   168  	// NodeStatusStatusUNAVAILABLE captures enum value "UNAVAILABLE"
   169  	NodeStatusStatusUNAVAILABLE string = "UNAVAILABLE"
   170  
   171  	// NodeStatusStatusTIMEOUT captures enum value "TIMEOUT"
   172  	NodeStatusStatusTIMEOUT string = "TIMEOUT"
   173  )
   174  
   175  // prop value enum
   176  func (m *NodeStatus) validateStatusEnum(path, location string, value string) error {
   177  	if err := validate.EnumCase(path, location, value, nodeStatusTypeStatusPropEnum, true); err != nil {
   178  		return err
   179  	}
   180  	return nil
   181  }
   182  
   183  func (m *NodeStatus) validateStatus(formats strfmt.Registry) error {
   184  	if swag.IsZero(m.Status) { // not required
   185  		return nil
   186  	}
   187  
   188  	// value enum
   189  	if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
   190  		return err
   191  	}
   192  
   193  	return nil
   194  }
   195  
   196  // ContextValidate validate this node status based on the context it is used
   197  func (m *NodeStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   198  	var res []error
   199  
   200  	if err := m.contextValidateBatchStats(ctx, formats); err != nil {
   201  		res = append(res, err)
   202  	}
   203  
   204  	if err := m.contextValidateShards(ctx, formats); err != nil {
   205  		res = append(res, err)
   206  	}
   207  
   208  	if err := m.contextValidateStats(ctx, formats); err != nil {
   209  		res = append(res, err)
   210  	}
   211  
   212  	if len(res) > 0 {
   213  		return errors.CompositeValidationError(res...)
   214  	}
   215  	return nil
   216  }
   217  
   218  func (m *NodeStatus) contextValidateBatchStats(ctx context.Context, formats strfmt.Registry) error {
   219  
   220  	if m.BatchStats != nil {
   221  		if err := m.BatchStats.ContextValidate(ctx, formats); err != nil {
   222  			if ve, ok := err.(*errors.Validation); ok {
   223  				return ve.ValidateName("batchStats")
   224  			} else if ce, ok := err.(*errors.CompositeError); ok {
   225  				return ce.ValidateName("batchStats")
   226  			}
   227  			return err
   228  		}
   229  	}
   230  
   231  	return nil
   232  }
   233  
   234  func (m *NodeStatus) contextValidateShards(ctx context.Context, formats strfmt.Registry) error {
   235  
   236  	for i := 0; i < len(m.Shards); i++ {
   237  
   238  		if m.Shards[i] != nil {
   239  			if err := m.Shards[i].ContextValidate(ctx, formats); err != nil {
   240  				if ve, ok := err.(*errors.Validation); ok {
   241  					return ve.ValidateName("shards" + "." + strconv.Itoa(i))
   242  				} else if ce, ok := err.(*errors.CompositeError); ok {
   243  					return ce.ValidateName("shards" + "." + strconv.Itoa(i))
   244  				}
   245  				return err
   246  			}
   247  		}
   248  
   249  	}
   250  
   251  	return nil
   252  }
   253  
   254  func (m *NodeStatus) contextValidateStats(ctx context.Context, formats strfmt.Registry) error {
   255  
   256  	if m.Stats != nil {
   257  		if err := m.Stats.ContextValidate(ctx, formats); err != nil {
   258  			if ve, ok := err.(*errors.Validation); ok {
   259  				return ve.ValidateName("stats")
   260  			} else if ce, ok := err.(*errors.CompositeError); ok {
   261  				return ce.ValidateName("stats")
   262  			}
   263  			return err
   264  		}
   265  	}
   266  
   267  	return nil
   268  }
   269  
   270  // MarshalBinary interface implementation
   271  func (m *NodeStatus) MarshalBinary() ([]byte, error) {
   272  	if m == nil {
   273  		return nil, nil
   274  	}
   275  	return swag.WriteJSON(m)
   276  }
   277  
   278  // UnmarshalBinary interface implementation
   279  func (m *NodeStatus) UnmarshalBinary(b []byte) error {
   280  	var res NodeStatus
   281  	if err := swag.ReadJSON(b, &res); err != nil {
   282  		return err
   283  	}
   284  	*m = res
   285  	return nil
   286  }