github.com/cilium/cilium@v1.16.2/api/v1/health/models/health_status_response.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package models
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"context"
    13  	"strconv"
    14  
    15  	"github.com/go-openapi/errors"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  )
    19  
    20  // HealthStatusResponse Connectivity status to other daemons
    21  //
    22  // swagger:model HealthStatusResponse
    23  type HealthStatusResponse struct {
    24  
    25  	// Description of the local node
    26  	Local *SelfStatus `json:"local,omitempty"`
    27  
    28  	// Connectivity status to each other node
    29  	Nodes []*NodeStatus `json:"nodes"`
    30  
    31  	// timestamp
    32  	Timestamp string `json:"timestamp,omitempty"`
    33  }
    34  
    35  // Validate validates this health status response
    36  func (m *HealthStatusResponse) Validate(formats strfmt.Registry) error {
    37  	var res []error
    38  
    39  	if err := m.validateLocal(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateNodes(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if len(res) > 0 {
    48  		return errors.CompositeValidationError(res...)
    49  	}
    50  	return nil
    51  }
    52  
    53  func (m *HealthStatusResponse) validateLocal(formats strfmt.Registry) error {
    54  	if swag.IsZero(m.Local) { // not required
    55  		return nil
    56  	}
    57  
    58  	if m.Local != nil {
    59  		if err := m.Local.Validate(formats); err != nil {
    60  			if ve, ok := err.(*errors.Validation); ok {
    61  				return ve.ValidateName("local")
    62  			} else if ce, ok := err.(*errors.CompositeError); ok {
    63  				return ce.ValidateName("local")
    64  			}
    65  			return err
    66  		}
    67  	}
    68  
    69  	return nil
    70  }
    71  
    72  func (m *HealthStatusResponse) validateNodes(formats strfmt.Registry) error {
    73  	if swag.IsZero(m.Nodes) { // not required
    74  		return nil
    75  	}
    76  
    77  	for i := 0; i < len(m.Nodes); i++ {
    78  		if swag.IsZero(m.Nodes[i]) { // not required
    79  			continue
    80  		}
    81  
    82  		if m.Nodes[i] != nil {
    83  			if err := m.Nodes[i].Validate(formats); err != nil {
    84  				if ve, ok := err.(*errors.Validation); ok {
    85  					return ve.ValidateName("nodes" + "." + strconv.Itoa(i))
    86  				} else if ce, ok := err.(*errors.CompositeError); ok {
    87  					return ce.ValidateName("nodes" + "." + strconv.Itoa(i))
    88  				}
    89  				return err
    90  			}
    91  		}
    92  
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  // ContextValidate validate this health status response based on the context it is used
    99  func (m *HealthStatusResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   100  	var res []error
   101  
   102  	if err := m.contextValidateLocal(ctx, formats); err != nil {
   103  		res = append(res, err)
   104  	}
   105  
   106  	if err := m.contextValidateNodes(ctx, formats); err != nil {
   107  		res = append(res, err)
   108  	}
   109  
   110  	if len(res) > 0 {
   111  		return errors.CompositeValidationError(res...)
   112  	}
   113  	return nil
   114  }
   115  
   116  func (m *HealthStatusResponse) contextValidateLocal(ctx context.Context, formats strfmt.Registry) error {
   117  
   118  	if m.Local != nil {
   119  
   120  		if swag.IsZero(m.Local) { // not required
   121  			return nil
   122  		}
   123  
   124  		if err := m.Local.ContextValidate(ctx, formats); err != nil {
   125  			if ve, ok := err.(*errors.Validation); ok {
   126  				return ve.ValidateName("local")
   127  			} else if ce, ok := err.(*errors.CompositeError); ok {
   128  				return ce.ValidateName("local")
   129  			}
   130  			return err
   131  		}
   132  	}
   133  
   134  	return nil
   135  }
   136  
   137  func (m *HealthStatusResponse) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error {
   138  
   139  	for i := 0; i < len(m.Nodes); i++ {
   140  
   141  		if m.Nodes[i] != nil {
   142  
   143  			if swag.IsZero(m.Nodes[i]) { // not required
   144  				return nil
   145  			}
   146  
   147  			if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil {
   148  				if ve, ok := err.(*errors.Validation); ok {
   149  					return ve.ValidateName("nodes" + "." + strconv.Itoa(i))
   150  				} else if ce, ok := err.(*errors.CompositeError); ok {
   151  					return ce.ValidateName("nodes" + "." + strconv.Itoa(i))
   152  				}
   153  				return err
   154  			}
   155  		}
   156  
   157  	}
   158  
   159  	return nil
   160  }
   161  
   162  // MarshalBinary interface implementation
   163  func (m *HealthStatusResponse) MarshalBinary() ([]byte, error) {
   164  	if m == nil {
   165  		return nil, nil
   166  	}
   167  	return swag.WriteJSON(m)
   168  }
   169  
   170  // UnmarshalBinary interface implementation
   171  func (m *HealthStatusResponse) UnmarshalBinary(b []byte) error {
   172  	var res HealthStatusResponse
   173  	if err := swag.ReadJSON(b, &res); err != nil {
   174  		return err
   175  	}
   176  	*m = res
   177  	return nil
   178  }