github.com/cilium/cilium@v1.16.2/api/v1/health/models/path_status.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  // PathStatus Connectivity status via different paths, for example using different
    20  // policies or service redirection
    21  //
    22  // swagger:model PathStatus
    23  type PathStatus struct {
    24  
    25  	// Connectivity status without policy applied
    26  	HTTP *ConnectivityStatus `json:"http,omitempty"`
    27  
    28  	// Basic ping connectivity status to node IP
    29  	Icmp *ConnectivityStatus `json:"icmp,omitempty"`
    30  
    31  	// IP address queried for the connectivity status
    32  	IP string `json:"ip,omitempty"`
    33  }
    34  
    35  // Validate validates this path status
    36  func (m *PathStatus) Validate(formats strfmt.Registry) error {
    37  	var res []error
    38  
    39  	if err := m.validateHTTP(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateIcmp(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 *PathStatus) validateHTTP(formats strfmt.Registry) error {
    54  	if swag.IsZero(m.HTTP) { // not required
    55  		return nil
    56  	}
    57  
    58  	if m.HTTP != nil {
    59  		if err := m.HTTP.Validate(formats); err != nil {
    60  			if ve, ok := err.(*errors.Validation); ok {
    61  				return ve.ValidateName("http")
    62  			} else if ce, ok := err.(*errors.CompositeError); ok {
    63  				return ce.ValidateName("http")
    64  			}
    65  			return err
    66  		}
    67  	}
    68  
    69  	return nil
    70  }
    71  
    72  func (m *PathStatus) validateIcmp(formats strfmt.Registry) error {
    73  	if swag.IsZero(m.Icmp) { // not required
    74  		return nil
    75  	}
    76  
    77  	if m.Icmp != nil {
    78  		if err := m.Icmp.Validate(formats); err != nil {
    79  			if ve, ok := err.(*errors.Validation); ok {
    80  				return ve.ValidateName("icmp")
    81  			} else if ce, ok := err.(*errors.CompositeError); ok {
    82  				return ce.ValidateName("icmp")
    83  			}
    84  			return err
    85  		}
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  // ContextValidate validate this path status based on the context it is used
    92  func (m *PathStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    93  	var res []error
    94  
    95  	if err := m.contextValidateHTTP(ctx, formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if err := m.contextValidateIcmp(ctx, formats); err != nil {
   100  		res = append(res, err)
   101  	}
   102  
   103  	if len(res) > 0 {
   104  		return errors.CompositeValidationError(res...)
   105  	}
   106  	return nil
   107  }
   108  
   109  func (m *PathStatus) contextValidateHTTP(ctx context.Context, formats strfmt.Registry) error {
   110  
   111  	if m.HTTP != nil {
   112  
   113  		if swag.IsZero(m.HTTP) { // not required
   114  			return nil
   115  		}
   116  
   117  		if err := m.HTTP.ContextValidate(ctx, formats); err != nil {
   118  			if ve, ok := err.(*errors.Validation); ok {
   119  				return ve.ValidateName("http")
   120  			} else if ce, ok := err.(*errors.CompositeError); ok {
   121  				return ce.ValidateName("http")
   122  			}
   123  			return err
   124  		}
   125  	}
   126  
   127  	return nil
   128  }
   129  
   130  func (m *PathStatus) contextValidateIcmp(ctx context.Context, formats strfmt.Registry) error {
   131  
   132  	if m.Icmp != nil {
   133  
   134  		if swag.IsZero(m.Icmp) { // not required
   135  			return nil
   136  		}
   137  
   138  		if err := m.Icmp.ContextValidate(ctx, formats); err != nil {
   139  			if ve, ok := err.(*errors.Validation); ok {
   140  				return ve.ValidateName("icmp")
   141  			} else if ce, ok := err.(*errors.CompositeError); ok {
   142  				return ce.ValidateName("icmp")
   143  			}
   144  			return err
   145  		}
   146  	}
   147  
   148  	return nil
   149  }
   150  
   151  // MarshalBinary interface implementation
   152  func (m *PathStatus) MarshalBinary() ([]byte, error) {
   153  	if m == nil {
   154  		return nil, nil
   155  	}
   156  	return swag.WriteJSON(m)
   157  }
   158  
   159  // UnmarshalBinary interface implementation
   160  func (m *PathStatus) UnmarshalBinary(b []byte) error {
   161  	var res PathStatus
   162  	if err := swag.ReadJSON(b, &res); err != nil {
   163  		return err
   164  	}
   165  	*m = res
   166  	return nil
   167  }