github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/partial_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  // PartialNetworkInterface Defines a partial network interface structure, used to update the rate limiters for that interface, after microvm start.
    17  // swagger:model PartialNetworkInterface
    18  type PartialNetworkInterface struct {
    19  
    20  	// iface id
    21  	// Required: true
    22  	IfaceID *string `json:"iface_id"`
    23  
    24  	// rx rate limiter
    25  	RxRateLimiter *RateLimiter `json:"rx_rate_limiter,omitempty"`
    26  
    27  	// tx rate limiter
    28  	TxRateLimiter *RateLimiter `json:"tx_rate_limiter,omitempty"`
    29  }
    30  
    31  // Validate validates this partial network interface
    32  func (m *PartialNetworkInterface) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateIfaceID(formats); err != nil {
    36  		res = append(res, err)
    37  	}
    38  
    39  	if err := m.validateRxRateLimiter(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateTxRateLimiter(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 *PartialNetworkInterface) validateIfaceID(formats strfmt.Registry) error {
    54  
    55  	if err := validate.Required("iface_id", "body", m.IfaceID); err != nil {
    56  		return err
    57  	}
    58  
    59  	return nil
    60  }
    61  
    62  func (m *PartialNetworkInterface) validateRxRateLimiter(formats strfmt.Registry) error {
    63  
    64  	if swag.IsZero(m.RxRateLimiter) { // not required
    65  		return nil
    66  	}
    67  
    68  	if m.RxRateLimiter != nil {
    69  		if err := m.RxRateLimiter.Validate(formats); err != nil {
    70  			if ve, ok := err.(*errors.Validation); ok {
    71  				return ve.ValidateName("rx_rate_limiter")
    72  			}
    73  			return err
    74  		}
    75  	}
    76  
    77  	return nil
    78  }
    79  
    80  func (m *PartialNetworkInterface) validateTxRateLimiter(formats strfmt.Registry) error {
    81  
    82  	if swag.IsZero(m.TxRateLimiter) { // not required
    83  		return nil
    84  	}
    85  
    86  	if m.TxRateLimiter != nil {
    87  		if err := m.TxRateLimiter.Validate(formats); err != nil {
    88  			if ve, ok := err.(*errors.Validation); ok {
    89  				return ve.ValidateName("tx_rate_limiter")
    90  			}
    91  			return err
    92  		}
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  // MarshalBinary interface implementation
    99  func (m *PartialNetworkInterface) MarshalBinary() ([]byte, error) {
   100  	if m == nil {
   101  		return nil, nil
   102  	}
   103  	return swag.WriteJSON(m)
   104  }
   105  
   106  // UnmarshalBinary interface implementation
   107  func (m *PartialNetworkInterface) UnmarshalBinary(b []byte) error {
   108  	var res PartialNetworkInterface
   109  	if err := swag.ReadJSON(b, &res); err != nil {
   110  		return err
   111  	}
   112  	*m = res
   113  	return nil
   114  }