github.com/kubearmor/cilium@v1.6.12/api/v1/models/b_p_f_map_entry.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  	"encoding/json"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // BPFMapEntry BPF map cache entry"
    19  // swagger:model BPFMapEntry
    20  type BPFMapEntry struct {
    21  
    22  	// Desired action to be performed
    23  	// Enum: [ok insert delete]
    24  	DesiredAction string `json:"desired-action,omitempty"`
    25  
    26  	// Key of map entry
    27  	Key string `json:"key,omitempty"`
    28  
    29  	// Last error seen while performing desired action
    30  	LastError string `json:"last-error,omitempty"`
    31  
    32  	// Value of map entry
    33  	Value string `json:"value,omitempty"`
    34  }
    35  
    36  // Validate validates this b p f map entry
    37  func (m *BPFMapEntry) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateDesiredAction(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if len(res) > 0 {
    45  		return errors.CompositeValidationError(res...)
    46  	}
    47  	return nil
    48  }
    49  
    50  var bPFMapEntryTypeDesiredActionPropEnum []interface{}
    51  
    52  func init() {
    53  	var res []string
    54  	if err := json.Unmarshal([]byte(`["ok","insert","delete"]`), &res); err != nil {
    55  		panic(err)
    56  	}
    57  	for _, v := range res {
    58  		bPFMapEntryTypeDesiredActionPropEnum = append(bPFMapEntryTypeDesiredActionPropEnum, v)
    59  	}
    60  }
    61  
    62  const (
    63  
    64  	// BPFMapEntryDesiredActionOk captures enum value "ok"
    65  	BPFMapEntryDesiredActionOk string = "ok"
    66  
    67  	// BPFMapEntryDesiredActionInsert captures enum value "insert"
    68  	BPFMapEntryDesiredActionInsert string = "insert"
    69  
    70  	// BPFMapEntryDesiredActionDelete captures enum value "delete"
    71  	BPFMapEntryDesiredActionDelete string = "delete"
    72  )
    73  
    74  // prop value enum
    75  func (m *BPFMapEntry) validateDesiredActionEnum(path, location string, value string) error {
    76  	if err := validate.Enum(path, location, value, bPFMapEntryTypeDesiredActionPropEnum); err != nil {
    77  		return err
    78  	}
    79  	return nil
    80  }
    81  
    82  func (m *BPFMapEntry) validateDesiredAction(formats strfmt.Registry) error {
    83  
    84  	if swag.IsZero(m.DesiredAction) { // not required
    85  		return nil
    86  	}
    87  
    88  	// value enum
    89  	if err := m.validateDesiredActionEnum("desired-action", "body", m.DesiredAction); err != nil {
    90  		return err
    91  	}
    92  
    93  	return nil
    94  }
    95  
    96  // MarshalBinary interface implementation
    97  func (m *BPFMapEntry) MarshalBinary() ([]byte, error) {
    98  	if m == nil {
    99  		return nil, nil
   100  	}
   101  	return swag.WriteJSON(m)
   102  }
   103  
   104  // UnmarshalBinary interface implementation
   105  func (m *BPFMapEntry) UnmarshalBinary(b []byte) error {
   106  	var res BPFMapEntry
   107  	if err := swag.ReadJSON(b, &res); err != nil {
   108  		return err
   109  	}
   110  	*m = res
   111  	return nil
   112  }