github.com/cilium/cilium@v1.16.2/api/v1/models/srv6.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  // Srv6 Status of the SRv6
    22  //
    23  // +k8s:deepcopy-gen=true
    24  //
    25  // swagger:model Srv6
    26  type Srv6 struct {
    27  
    28  	// enabled
    29  	Enabled bool `json:"enabled,omitempty"`
    30  
    31  	// srv6 encap mode
    32  	// Enum: [SRH Reduced]
    33  	Srv6EncapMode string `json:"srv6EncapMode,omitempty"`
    34  }
    35  
    36  // Validate validates this srv6
    37  func (m *Srv6) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateSrv6EncapMode(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 srv6TypeSrv6EncapModePropEnum []interface{}
    51  
    52  func init() {
    53  	var res []string
    54  	if err := json.Unmarshal([]byte(`["SRH","Reduced"]`), &res); err != nil {
    55  		panic(err)
    56  	}
    57  	for _, v := range res {
    58  		srv6TypeSrv6EncapModePropEnum = append(srv6TypeSrv6EncapModePropEnum, v)
    59  	}
    60  }
    61  
    62  const (
    63  
    64  	// Srv6Srv6EncapModeSRH captures enum value "SRH"
    65  	Srv6Srv6EncapModeSRH string = "SRH"
    66  
    67  	// Srv6Srv6EncapModeReduced captures enum value "Reduced"
    68  	Srv6Srv6EncapModeReduced string = "Reduced"
    69  )
    70  
    71  // prop value enum
    72  func (m *Srv6) validateSrv6EncapModeEnum(path, location string, value string) error {
    73  	if err := validate.EnumCase(path, location, value, srv6TypeSrv6EncapModePropEnum, true); err != nil {
    74  		return err
    75  	}
    76  	return nil
    77  }
    78  
    79  func (m *Srv6) validateSrv6EncapMode(formats strfmt.Registry) error {
    80  	if swag.IsZero(m.Srv6EncapMode) { // not required
    81  		return nil
    82  	}
    83  
    84  	// value enum
    85  	if err := m.validateSrv6EncapModeEnum("srv6EncapMode", "body", m.Srv6EncapMode); err != nil {
    86  		return err
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  // ContextValidate validates this srv6 based on context it is used
    93  func (m *Srv6) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    94  	return nil
    95  }
    96  
    97  // MarshalBinary interface implementation
    98  func (m *Srv6) MarshalBinary() ([]byte, error) {
    99  	if m == nil {
   100  		return nil, nil
   101  	}
   102  	return swag.WriteJSON(m)
   103  }
   104  
   105  // UnmarshalBinary interface implementation
   106  func (m *Srv6) UnmarshalBinary(b []byte) error {
   107  	var res Srv6
   108  	if err := swag.ReadJSON(b, &res); err != nil {
   109  		return err
   110  	}
   111  	*m = res
   112  	return nil
   113  }