github.com/kubearmor/cilium@v1.6.12/api/v1/models/trace_to.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  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  )
    16  
    17  // TraceTo trace to
    18  // swagger:model TraceTo
    19  type TraceTo struct {
    20  
    21  	// List of Layer 4 port and protocol pairs which will be used in communication
    22  	// from the source identity to the destination identity.
    23  	//
    24  	Dports []*Port `json:"dports"`
    25  
    26  	// labels
    27  	Labels Labels `json:"labels,omitempty"`
    28  }
    29  
    30  // Validate validates this trace to
    31  func (m *TraceTo) Validate(formats strfmt.Registry) error {
    32  	var res []error
    33  
    34  	if err := m.validateDports(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if err := m.validateLabels(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if len(res) > 0 {
    43  		return errors.CompositeValidationError(res...)
    44  	}
    45  	return nil
    46  }
    47  
    48  func (m *TraceTo) validateDports(formats strfmt.Registry) error {
    49  
    50  	if swag.IsZero(m.Dports) { // not required
    51  		return nil
    52  	}
    53  
    54  	for i := 0; i < len(m.Dports); i++ {
    55  		if swag.IsZero(m.Dports[i]) { // not required
    56  			continue
    57  		}
    58  
    59  		if m.Dports[i] != nil {
    60  			if err := m.Dports[i].Validate(formats); err != nil {
    61  				if ve, ok := err.(*errors.Validation); ok {
    62  					return ve.ValidateName("dports" + "." + strconv.Itoa(i))
    63  				}
    64  				return err
    65  			}
    66  		}
    67  
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  func (m *TraceTo) validateLabels(formats strfmt.Registry) error {
    74  
    75  	if swag.IsZero(m.Labels) { // not required
    76  		return nil
    77  	}
    78  
    79  	if err := m.Labels.Validate(formats); err != nil {
    80  		if ve, ok := err.(*errors.Validation); ok {
    81  			return ve.ValidateName("labels")
    82  		}
    83  		return err
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  // MarshalBinary interface implementation
    90  func (m *TraceTo) MarshalBinary() ([]byte, error) {
    91  	if m == nil {
    92  		return nil, nil
    93  	}
    94  	return swag.WriteJSON(m)
    95  }
    96  
    97  // UnmarshalBinary interface implementation
    98  func (m *TraceTo) UnmarshalBinary(b []byte) error {
    99  	var res TraceTo
   100  	if err := swag.ReadJSON(b, &res); err != nil {
   101  		return err
   102  	}
   103  	*m = res
   104  	return nil
   105  }