github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/network_interface.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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // NetworkInterface Defines a network interface.
    17  // swagger:model NetworkInterface
    18  type NetworkInterface struct {
    19  
    20  	// If this field is set, the device model will reply to HTTP GET requests sent to the MMDS address via this interface. In this case, both ARP requests for 169.254.169.254 and TCP segments heading to the same address are intercepted by the device model, and do not reach the associated TAP device.
    21  	AllowMmdsRequests bool `json:"allow_mmds_requests,omitempty"`
    22  
    23  	// guest mac
    24  	GuestMac string `json:"guest_mac,omitempty"`
    25  
    26  	// Host level path for the guest network interface
    27  	// Required: true
    28  	HostDevName *string `json:"host_dev_name"`
    29  
    30  	// iface id
    31  	// Required: true
    32  	IfaceID *string `json:"iface_id"`
    33  
    34  	// rx rate limiter
    35  	RxRateLimiter *RateLimiter `json:"rx_rate_limiter,omitempty"`
    36  
    37  	// tx rate limiter
    38  	TxRateLimiter *RateLimiter `json:"tx_rate_limiter,omitempty"`
    39  }
    40  
    41  // Validate validates this network interface
    42  func (m *NetworkInterface) Validate(formats strfmt.Registry) error {
    43  	var res []error
    44  
    45  	if err := m.validateHostDevName(formats); err != nil {
    46  		res = append(res, err)
    47  	}
    48  
    49  	if err := m.validateIfaceID(formats); err != nil {
    50  		res = append(res, err)
    51  	}
    52  
    53  	if err := m.validateRxRateLimiter(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateTxRateLimiter(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if len(res) > 0 {
    62  		return errors.CompositeValidationError(res...)
    63  	}
    64  	return nil
    65  }
    66  
    67  func (m *NetworkInterface) validateHostDevName(formats strfmt.Registry) error {
    68  
    69  	if err := validate.Required("host_dev_name", "body", m.HostDevName); err != nil {
    70  		return err
    71  	}
    72  
    73  	return nil
    74  }
    75  
    76  func (m *NetworkInterface) validateIfaceID(formats strfmt.Registry) error {
    77  
    78  	if err := validate.Required("iface_id", "body", m.IfaceID); err != nil {
    79  		return err
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  func (m *NetworkInterface) validateRxRateLimiter(formats strfmt.Registry) error {
    86  
    87  	if swag.IsZero(m.RxRateLimiter) { // not required
    88  		return nil
    89  	}
    90  
    91  	if m.RxRateLimiter != nil {
    92  		if err := m.RxRateLimiter.Validate(formats); err != nil {
    93  			if ve, ok := err.(*errors.Validation); ok {
    94  				return ve.ValidateName("rx_rate_limiter")
    95  			}
    96  			return err
    97  		}
    98  	}
    99  
   100  	return nil
   101  }
   102  
   103  func (m *NetworkInterface) validateTxRateLimiter(formats strfmt.Registry) error {
   104  
   105  	if swag.IsZero(m.TxRateLimiter) { // not required
   106  		return nil
   107  	}
   108  
   109  	if m.TxRateLimiter != nil {
   110  		if err := m.TxRateLimiter.Validate(formats); err != nil {
   111  			if ve, ok := err.(*errors.Validation); ok {
   112  				return ve.ValidateName("tx_rate_limiter")
   113  			}
   114  			return err
   115  		}
   116  	}
   117  
   118  	return nil
   119  }
   120  
   121  // MarshalBinary interface implementation
   122  func (m *NetworkInterface) MarshalBinary() ([]byte, error) {
   123  	if m == nil {
   124  		return nil, nil
   125  	}
   126  	return swag.WriteJSON(m)
   127  }
   128  
   129  // UnmarshalBinary interface implementation
   130  func (m *NetworkInterface) UnmarshalBinary(b []byte) error {
   131  	var res NetworkInterface
   132  	if err := swag.ReadJSON(b, &res); err != nil {
   133  		return err
   134  	}
   135  	*m = res
   136  	return nil
   137  }