github.com/kubearmor/cilium@v1.6.12/api/v1/health/models/host_status.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  )
    16  
    17  // HostStatus Connectivity status to host cilium-health instance via different paths,
    18  // probing via all known IP addresses
    19  //
    20  // swagger:model HostStatus
    21  type HostStatus struct {
    22  
    23  	// primary address
    24  	PrimaryAddress *PathStatus `json:"primary-address,omitempty"`
    25  
    26  	// secondary addresses
    27  	SecondaryAddresses []*PathStatus `json:"secondary-addresses"`
    28  }
    29  
    30  // Validate validates this host status
    31  func (m *HostStatus) Validate(formats strfmt.Registry) error {
    32  	var res []error
    33  
    34  	if err := m.validatePrimaryAddress(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if err := m.validateSecondaryAddresses(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if len(res) > 0 {
    43  		return errors.CompositeValidationError(res...)
    44  	}
    45  	return nil
    46  }
    47  
    48  func (m *HostStatus) validatePrimaryAddress(formats strfmt.Registry) error {
    49  
    50  	if swag.IsZero(m.PrimaryAddress) { // not required
    51  		return nil
    52  	}
    53  
    54  	if m.PrimaryAddress != nil {
    55  		if err := m.PrimaryAddress.Validate(formats); err != nil {
    56  			if ve, ok := err.(*errors.Validation); ok {
    57  				return ve.ValidateName("primary-address")
    58  			}
    59  			return err
    60  		}
    61  	}
    62  
    63  	return nil
    64  }
    65  
    66  func (m *HostStatus) validateSecondaryAddresses(formats strfmt.Registry) error {
    67  
    68  	if swag.IsZero(m.SecondaryAddresses) { // not required
    69  		return nil
    70  	}
    71  
    72  	for i := 0; i < len(m.SecondaryAddresses); i++ {
    73  		if swag.IsZero(m.SecondaryAddresses[i]) { // not required
    74  			continue
    75  		}
    76  
    77  		if m.SecondaryAddresses[i] != nil {
    78  			if err := m.SecondaryAddresses[i].Validate(formats); err != nil {
    79  				if ve, ok := err.(*errors.Validation); ok {
    80  					return ve.ValidateName("secondary-addresses" + "." + strconv.Itoa(i))
    81  				}
    82  				return err
    83  			}
    84  		}
    85  
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  // MarshalBinary interface implementation
    92  func (m *HostStatus) MarshalBinary() ([]byte, error) {
    93  	if m == nil {
    94  		return nil, nil
    95  	}
    96  	return swag.WriteJSON(m)
    97  }
    98  
    99  // UnmarshalBinary interface implementation
   100  func (m *HostStatus) UnmarshalBinary(b []byte) error {
   101  	var res HostStatus
   102  	if err := swag.ReadJSON(b, &res); err != nil {
   103  		return err
   104  	}
   105  	*m = res
   106  	return nil
   107  }