github.com/cilium/cilium@v1.16.2/api/v1/models/recorder.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  // Recorder Collection of wildcard filters for pcap recorder
    20  //
    21  // swagger:model Recorder
    22  type Recorder struct {
    23  
    24  	// spec
    25  	Spec *RecorderSpec `json:"spec,omitempty"`
    26  
    27  	// status
    28  	Status *RecorderStatus `json:"status,omitempty"`
    29  }
    30  
    31  // Validate validates this recorder
    32  func (m *Recorder) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateSpec(formats); err != nil {
    36  		res = append(res, err)
    37  	}
    38  
    39  	if err := m.validateStatus(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if len(res) > 0 {
    44  		return errors.CompositeValidationError(res...)
    45  	}
    46  	return nil
    47  }
    48  
    49  func (m *Recorder) validateSpec(formats strfmt.Registry) error {
    50  	if swag.IsZero(m.Spec) { // not required
    51  		return nil
    52  	}
    53  
    54  	if m.Spec != nil {
    55  		if err := m.Spec.Validate(formats); err != nil {
    56  			if ve, ok := err.(*errors.Validation); ok {
    57  				return ve.ValidateName("spec")
    58  			} else if ce, ok := err.(*errors.CompositeError); ok {
    59  				return ce.ValidateName("spec")
    60  			}
    61  			return err
    62  		}
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  func (m *Recorder) validateStatus(formats strfmt.Registry) error {
    69  	if swag.IsZero(m.Status) { // not required
    70  		return nil
    71  	}
    72  
    73  	if m.Status != nil {
    74  		if err := m.Status.Validate(formats); err != nil {
    75  			if ve, ok := err.(*errors.Validation); ok {
    76  				return ve.ValidateName("status")
    77  			} else if ce, ok := err.(*errors.CompositeError); ok {
    78  				return ce.ValidateName("status")
    79  			}
    80  			return err
    81  		}
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  // ContextValidate validate this recorder based on the context it is used
    88  func (m *Recorder) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    89  	var res []error
    90  
    91  	if err := m.contextValidateSpec(ctx, formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.contextValidateStatus(ctx, formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if len(res) > 0 {
   100  		return errors.CompositeValidationError(res...)
   101  	}
   102  	return nil
   103  }
   104  
   105  func (m *Recorder) contextValidateSpec(ctx context.Context, formats strfmt.Registry) error {
   106  
   107  	if m.Spec != nil {
   108  
   109  		if swag.IsZero(m.Spec) { // not required
   110  			return nil
   111  		}
   112  
   113  		if err := m.Spec.ContextValidate(ctx, formats); err != nil {
   114  			if ve, ok := err.(*errors.Validation); ok {
   115  				return ve.ValidateName("spec")
   116  			} else if ce, ok := err.(*errors.CompositeError); ok {
   117  				return ce.ValidateName("spec")
   118  			}
   119  			return err
   120  		}
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  func (m *Recorder) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if m.Status != nil {
   129  
   130  		if swag.IsZero(m.Status) { // not required
   131  			return nil
   132  		}
   133  
   134  		if err := m.Status.ContextValidate(ctx, formats); err != nil {
   135  			if ve, ok := err.(*errors.Validation); ok {
   136  				return ve.ValidateName("status")
   137  			} else if ce, ok := err.(*errors.CompositeError); ok {
   138  				return ce.ValidateName("status")
   139  			}
   140  			return err
   141  		}
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  // MarshalBinary interface implementation
   148  func (m *Recorder) MarshalBinary() ([]byte, error) {
   149  	if m == nil {
   150  		return nil, nil
   151  	}
   152  	return swag.WriteJSON(m)
   153  }
   154  
   155  // UnmarshalBinary interface implementation
   156  func (m *Recorder) UnmarshalBinary(b []byte) error {
   157  	var res Recorder
   158  	if err := swag.ReadJSON(b, &res); err != nil {
   159  		return err
   160  	}
   161  	*m = res
   162  	return nil
   163  }