github.com/kubearmor/cilium@v1.6.12/api/v1/models/frontend_address.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  // FrontendAddress Layer 4 address. The protocol is currently ignored, all services will
    19  // behave as if protocol any is specified. To restrict to a particular
    20  // protocol, use policy.
    21  //
    22  // swagger:model FrontendAddress
    23  type FrontendAddress struct {
    24  
    25  	// Layer 3 address
    26  	IP string `json:"ip,omitempty"`
    27  
    28  	// Layer 4 port number
    29  	Port uint16 `json:"port,omitempty"`
    30  
    31  	// Layer 4 protocol
    32  	// Enum: [tcp udp any]
    33  	Protocol string `json:"protocol,omitempty"`
    34  }
    35  
    36  // Validate validates this frontend address
    37  func (m *FrontendAddress) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateProtocol(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 frontendAddressTypeProtocolPropEnum []interface{}
    51  
    52  func init() {
    53  	var res []string
    54  	if err := json.Unmarshal([]byte(`["tcp","udp","any"]`), &res); err != nil {
    55  		panic(err)
    56  	}
    57  	for _, v := range res {
    58  		frontendAddressTypeProtocolPropEnum = append(frontendAddressTypeProtocolPropEnum, v)
    59  	}
    60  }
    61  
    62  const (
    63  
    64  	// FrontendAddressProtocolTCP captures enum value "tcp"
    65  	FrontendAddressProtocolTCP string = "tcp"
    66  
    67  	// FrontendAddressProtocolUDP captures enum value "udp"
    68  	FrontendAddressProtocolUDP string = "udp"
    69  
    70  	// FrontendAddressProtocolAny captures enum value "any"
    71  	FrontendAddressProtocolAny string = "any"
    72  )
    73  
    74  // prop value enum
    75  func (m *FrontendAddress) validateProtocolEnum(path, location string, value string) error {
    76  	if err := validate.Enum(path, location, value, frontendAddressTypeProtocolPropEnum); err != nil {
    77  		return err
    78  	}
    79  	return nil
    80  }
    81  
    82  func (m *FrontendAddress) validateProtocol(formats strfmt.Registry) error {
    83  
    84  	if swag.IsZero(m.Protocol) { // not required
    85  		return nil
    86  	}
    87  
    88  	// value enum
    89  	if err := m.validateProtocolEnum("protocol", "body", m.Protocol); err != nil {
    90  		return err
    91  	}
    92  
    93  	return nil
    94  }
    95  
    96  // MarshalBinary interface implementation
    97  func (m *FrontendAddress) 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 *FrontendAddress) UnmarshalBinary(b []byte) error {
   106  	var res FrontendAddress
   107  	if err := swag.ReadJSON(b, &res); err != nil {
   108  		return err
   109  	}
   110  	*m = res
   111  	return nil
   112  }