github.com/cilium/cilium@v1.16.2/api/v1/models/endpoint_networking.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  // EndpointNetworking Unique identifiers for this endpoint from outside cilium
    21  //
    22  // swagger:model EndpointNetworking
    23  type EndpointNetworking struct {
    24  
    25  	// IP4/6 addresses assigned to this Endpoint
    26  	Addressing []*AddressPair `json:"addressing"`
    27  
    28  	// Name of network device in container netns
    29  	ContainerInterfaceName string `json:"container-interface-name,omitempty"`
    30  
    31  	// host addressing
    32  	HostAddressing *NodeAddressing `json:"host-addressing,omitempty"`
    33  
    34  	// MAC address
    35  	HostMac string `json:"host-mac,omitempty"`
    36  
    37  	// Index of network device in host netns
    38  	InterfaceIndex int64 `json:"interface-index,omitempty"`
    39  
    40  	// Name of network device in host netns
    41  	InterfaceName string `json:"interface-name,omitempty"`
    42  
    43  	// MAC address
    44  	Mac string `json:"mac,omitempty"`
    45  }
    46  
    47  // Validate validates this endpoint networking
    48  func (m *EndpointNetworking) Validate(formats strfmt.Registry) error {
    49  	var res []error
    50  
    51  	if err := m.validateAddressing(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if err := m.validateHostAddressing(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if len(res) > 0 {
    60  		return errors.CompositeValidationError(res...)
    61  	}
    62  	return nil
    63  }
    64  
    65  func (m *EndpointNetworking) validateAddressing(formats strfmt.Registry) error {
    66  	if swag.IsZero(m.Addressing) { // not required
    67  		return nil
    68  	}
    69  
    70  	for i := 0; i < len(m.Addressing); i++ {
    71  		if swag.IsZero(m.Addressing[i]) { // not required
    72  			continue
    73  		}
    74  
    75  		if m.Addressing[i] != nil {
    76  			if err := m.Addressing[i].Validate(formats); err != nil {
    77  				if ve, ok := err.(*errors.Validation); ok {
    78  					return ve.ValidateName("addressing" + "." + strconv.Itoa(i))
    79  				} else if ce, ok := err.(*errors.CompositeError); ok {
    80  					return ce.ValidateName("addressing" + "." + strconv.Itoa(i))
    81  				}
    82  				return err
    83  			}
    84  		}
    85  
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  func (m *EndpointNetworking) validateHostAddressing(formats strfmt.Registry) error {
    92  	if swag.IsZero(m.HostAddressing) { // not required
    93  		return nil
    94  	}
    95  
    96  	if m.HostAddressing != nil {
    97  		if err := m.HostAddressing.Validate(formats); err != nil {
    98  			if ve, ok := err.(*errors.Validation); ok {
    99  				return ve.ValidateName("host-addressing")
   100  			} else if ce, ok := err.(*errors.CompositeError); ok {
   101  				return ce.ValidateName("host-addressing")
   102  			}
   103  			return err
   104  		}
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  // ContextValidate validate this endpoint networking based on the context it is used
   111  func (m *EndpointNetworking) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   112  	var res []error
   113  
   114  	if err := m.contextValidateAddressing(ctx, formats); err != nil {
   115  		res = append(res, err)
   116  	}
   117  
   118  	if err := m.contextValidateHostAddressing(ctx, formats); err != nil {
   119  		res = append(res, err)
   120  	}
   121  
   122  	if len(res) > 0 {
   123  		return errors.CompositeValidationError(res...)
   124  	}
   125  	return nil
   126  }
   127  
   128  func (m *EndpointNetworking) contextValidateAddressing(ctx context.Context, formats strfmt.Registry) error {
   129  
   130  	for i := 0; i < len(m.Addressing); i++ {
   131  
   132  		if m.Addressing[i] != nil {
   133  
   134  			if swag.IsZero(m.Addressing[i]) { // not required
   135  				return nil
   136  			}
   137  
   138  			if err := m.Addressing[i].ContextValidate(ctx, formats); err != nil {
   139  				if ve, ok := err.(*errors.Validation); ok {
   140  					return ve.ValidateName("addressing" + "." + strconv.Itoa(i))
   141  				} else if ce, ok := err.(*errors.CompositeError); ok {
   142  					return ce.ValidateName("addressing" + "." + strconv.Itoa(i))
   143  				}
   144  				return err
   145  			}
   146  		}
   147  
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  func (m *EndpointNetworking) contextValidateHostAddressing(ctx context.Context, formats strfmt.Registry) error {
   154  
   155  	if m.HostAddressing != nil {
   156  
   157  		if swag.IsZero(m.HostAddressing) { // not required
   158  			return nil
   159  		}
   160  
   161  		if err := m.HostAddressing.ContextValidate(ctx, formats); err != nil {
   162  			if ve, ok := err.(*errors.Validation); ok {
   163  				return ve.ValidateName("host-addressing")
   164  			} else if ce, ok := err.(*errors.CompositeError); ok {
   165  				return ce.ValidateName("host-addressing")
   166  			}
   167  			return err
   168  		}
   169  	}
   170  
   171  	return nil
   172  }
   173  
   174  // MarshalBinary interface implementation
   175  func (m *EndpointNetworking) MarshalBinary() ([]byte, error) {
   176  	if m == nil {
   177  		return nil, nil
   178  	}
   179  	return swag.WriteJSON(m)
   180  }
   181  
   182  // UnmarshalBinary interface implementation
   183  func (m *EndpointNetworking) UnmarshalBinary(b []byte) error {
   184  	var res EndpointNetworking
   185  	if err := swag.ReadJSON(b, &res); err != nil {
   186  		return err
   187  	}
   188  	*m = res
   189  	return nil
   190  }