github.com/cilium/cilium@v1.16.2/api/v1/models/endpoint_health.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  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/strfmt"
    16  	"github.com/go-openapi/swag"
    17  )
    18  
    19  // EndpointHealth Health of the endpoint
    20  //
    21  // +deepequal-gen=true
    22  //
    23  // swagger:model EndpointHealth
    24  type EndpointHealth struct {
    25  
    26  	// bpf
    27  	Bpf EndpointHealthStatus `json:"bpf,omitempty"`
    28  
    29  	// Is this endpoint reachable
    30  	Connected bool `json:"connected,omitempty"`
    31  
    32  	// overall health
    33  	OverallHealth EndpointHealthStatus `json:"overallHealth,omitempty"`
    34  
    35  	// policy
    36  	Policy EndpointHealthStatus `json:"policy,omitempty"`
    37  }
    38  
    39  // Validate validates this endpoint health
    40  func (m *EndpointHealth) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	if err := m.validateBpf(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if err := m.validateOverallHealth(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validatePolicy(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 *EndpointHealth) validateBpf(formats strfmt.Registry) error {
    62  	if swag.IsZero(m.Bpf) { // not required
    63  		return nil
    64  	}
    65  
    66  	if err := m.Bpf.Validate(formats); err != nil {
    67  		if ve, ok := err.(*errors.Validation); ok {
    68  			return ve.ValidateName("bpf")
    69  		} else if ce, ok := err.(*errors.CompositeError); ok {
    70  			return ce.ValidateName("bpf")
    71  		}
    72  		return err
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  func (m *EndpointHealth) validateOverallHealth(formats strfmt.Registry) error {
    79  	if swag.IsZero(m.OverallHealth) { // not required
    80  		return nil
    81  	}
    82  
    83  	if err := m.OverallHealth.Validate(formats); err != nil {
    84  		if ve, ok := err.(*errors.Validation); ok {
    85  			return ve.ValidateName("overallHealth")
    86  		} else if ce, ok := err.(*errors.CompositeError); ok {
    87  			return ce.ValidateName("overallHealth")
    88  		}
    89  		return err
    90  	}
    91  
    92  	return nil
    93  }
    94  
    95  func (m *EndpointHealth) validatePolicy(formats strfmt.Registry) error {
    96  	if swag.IsZero(m.Policy) { // not required
    97  		return nil
    98  	}
    99  
   100  	if err := m.Policy.Validate(formats); err != nil {
   101  		if ve, ok := err.(*errors.Validation); ok {
   102  			return ve.ValidateName("policy")
   103  		} else if ce, ok := err.(*errors.CompositeError); ok {
   104  			return ce.ValidateName("policy")
   105  		}
   106  		return err
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  // ContextValidate validate this endpoint health based on the context it is used
   113  func (m *EndpointHealth) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   114  	var res []error
   115  
   116  	if err := m.contextValidateBpf(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.contextValidateOverallHealth(ctx, formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.contextValidatePolicy(ctx, formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if len(res) > 0 {
   129  		return errors.CompositeValidationError(res...)
   130  	}
   131  	return nil
   132  }
   133  
   134  func (m *EndpointHealth) contextValidateBpf(ctx context.Context, formats strfmt.Registry) error {
   135  
   136  	if swag.IsZero(m.Bpf) { // not required
   137  		return nil
   138  	}
   139  
   140  	if err := m.Bpf.ContextValidate(ctx, formats); err != nil {
   141  		if ve, ok := err.(*errors.Validation); ok {
   142  			return ve.ValidateName("bpf")
   143  		} else if ce, ok := err.(*errors.CompositeError); ok {
   144  			return ce.ValidateName("bpf")
   145  		}
   146  		return err
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  func (m *EndpointHealth) contextValidateOverallHealth(ctx context.Context, formats strfmt.Registry) error {
   153  
   154  	if swag.IsZero(m.OverallHealth) { // not required
   155  		return nil
   156  	}
   157  
   158  	if err := m.OverallHealth.ContextValidate(ctx, formats); err != nil {
   159  		if ve, ok := err.(*errors.Validation); ok {
   160  			return ve.ValidateName("overallHealth")
   161  		} else if ce, ok := err.(*errors.CompositeError); ok {
   162  			return ce.ValidateName("overallHealth")
   163  		}
   164  		return err
   165  	}
   166  
   167  	return nil
   168  }
   169  
   170  func (m *EndpointHealth) contextValidatePolicy(ctx context.Context, formats strfmt.Registry) error {
   171  
   172  	if swag.IsZero(m.Policy) { // not required
   173  		return nil
   174  	}
   175  
   176  	if err := m.Policy.ContextValidate(ctx, formats); err != nil {
   177  		if ve, ok := err.(*errors.Validation); ok {
   178  			return ve.ValidateName("policy")
   179  		} else if ce, ok := err.(*errors.CompositeError); ok {
   180  			return ce.ValidateName("policy")
   181  		}
   182  		return err
   183  	}
   184  
   185  	return nil
   186  }
   187  
   188  // MarshalBinary interface implementation
   189  func (m *EndpointHealth) MarshalBinary() ([]byte, error) {
   190  	if m == nil {
   191  		return nil, nil
   192  	}
   193  	return swag.WriteJSON(m)
   194  }
   195  
   196  // UnmarshalBinary interface implementation
   197  func (m *EndpointHealth) UnmarshalBinary(b []byte) error {
   198  	var res EndpointHealth
   199  	if err := swag.ReadJSON(b, &res); err != nil {
   200  		return err
   201  	}
   202  	*m = res
   203  	return nil
   204  }