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