github.com/cilium/cilium@v1.16.2/api/v1/models/trace_from.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  // TraceFrom trace from
    20  //
    21  // swagger:model TraceFrom
    22  type TraceFrom struct {
    23  
    24  	// labels
    25  	Labels Labels `json:"labels,omitempty"`
    26  }
    27  
    28  // Validate validates this trace from
    29  func (m *TraceFrom) Validate(formats strfmt.Registry) error {
    30  	var res []error
    31  
    32  	if err := m.validateLabels(formats); err != nil {
    33  		res = append(res, err)
    34  	}
    35  
    36  	if len(res) > 0 {
    37  		return errors.CompositeValidationError(res...)
    38  	}
    39  	return nil
    40  }
    41  
    42  func (m *TraceFrom) validateLabels(formats strfmt.Registry) error {
    43  	if swag.IsZero(m.Labels) { // not required
    44  		return nil
    45  	}
    46  
    47  	if err := m.Labels.Validate(formats); err != nil {
    48  		if ve, ok := err.(*errors.Validation); ok {
    49  			return ve.ValidateName("labels")
    50  		} else if ce, ok := err.(*errors.CompositeError); ok {
    51  			return ce.ValidateName("labels")
    52  		}
    53  		return err
    54  	}
    55  
    56  	return nil
    57  }
    58  
    59  // ContextValidate validate this trace from based on the context it is used
    60  func (m *TraceFrom) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    61  	var res []error
    62  
    63  	if err := m.contextValidateLabels(ctx, formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if len(res) > 0 {
    68  		return errors.CompositeValidationError(res...)
    69  	}
    70  	return nil
    71  }
    72  
    73  func (m *TraceFrom) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error {
    74  
    75  	if err := m.Labels.ContextValidate(ctx, formats); err != nil {
    76  		if ve, ok := err.(*errors.Validation); ok {
    77  			return ve.ValidateName("labels")
    78  		} else if ce, ok := err.(*errors.CompositeError); ok {
    79  			return ce.ValidateName("labels")
    80  		}
    81  		return err
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  // MarshalBinary interface implementation
    88  func (m *TraceFrom) MarshalBinary() ([]byte, error) {
    89  	if m == nil {
    90  		return nil, nil
    91  	}
    92  	return swag.WriteJSON(m)
    93  }
    94  
    95  // UnmarshalBinary interface implementation
    96  func (m *TraceFrom) UnmarshalBinary(b []byte) error {
    97  	var res TraceFrom
    98  	if err := swag.ReadJSON(b, &res); err != nil {
    99  		return err
   100  	}
   101  	*m = res
   102  	return nil
   103  }