github.com/kubearmor/cilium@v1.6.12/api/v1/models/proxy_statistics.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  // ProxyStatistics Statistics of a set of proxy redirects for an endpoint
    19  // swagger:model ProxyStatistics
    20  // +k8s:deepcopy-gen=true
    21  type ProxyStatistics struct {
    22  
    23  	// The port the proxy is listening on
    24  	AllocatedProxyPort int64 `json:"allocated-proxy-port,omitempty"`
    25  
    26  	// Location of where the redirect is installed
    27  	// Enum: [ingress egress]
    28  	Location string `json:"location,omitempty"`
    29  
    30  	// The port subject to the redirect
    31  	Port int64 `json:"port,omitempty"`
    32  
    33  	// Name of the L7 protocol
    34  	Protocol string `json:"protocol,omitempty"`
    35  
    36  	// Statistics of this set of proxy redirect
    37  	Statistics *RequestResponseStatistics `json:"statistics,omitempty"`
    38  }
    39  
    40  // Validate validates this proxy statistics
    41  func (m *ProxyStatistics) Validate(formats strfmt.Registry) error {
    42  	var res []error
    43  
    44  	if err := m.validateLocation(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if err := m.validateStatistics(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if len(res) > 0 {
    53  		return errors.CompositeValidationError(res...)
    54  	}
    55  	return nil
    56  }
    57  
    58  var proxyStatisticsTypeLocationPropEnum []interface{}
    59  
    60  func init() {
    61  	var res []string
    62  	if err := json.Unmarshal([]byte(`["ingress","egress"]`), &res); err != nil {
    63  		panic(err)
    64  	}
    65  	for _, v := range res {
    66  		proxyStatisticsTypeLocationPropEnum = append(proxyStatisticsTypeLocationPropEnum, v)
    67  	}
    68  }
    69  
    70  const (
    71  
    72  	// ProxyStatisticsLocationIngress captures enum value "ingress"
    73  	ProxyStatisticsLocationIngress string = "ingress"
    74  
    75  	// ProxyStatisticsLocationEgress captures enum value "egress"
    76  	ProxyStatisticsLocationEgress string = "egress"
    77  )
    78  
    79  // prop value enum
    80  func (m *ProxyStatistics) validateLocationEnum(path, location string, value string) error {
    81  	if err := validate.Enum(path, location, value, proxyStatisticsTypeLocationPropEnum); err != nil {
    82  		return err
    83  	}
    84  	return nil
    85  }
    86  
    87  func (m *ProxyStatistics) validateLocation(formats strfmt.Registry) error {
    88  
    89  	if swag.IsZero(m.Location) { // not required
    90  		return nil
    91  	}
    92  
    93  	// value enum
    94  	if err := m.validateLocationEnum("location", "body", m.Location); err != nil {
    95  		return err
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  func (m *ProxyStatistics) validateStatistics(formats strfmt.Registry) error {
   102  
   103  	if swag.IsZero(m.Statistics) { // not required
   104  		return nil
   105  	}
   106  
   107  	if m.Statistics != nil {
   108  		if err := m.Statistics.Validate(formats); err != nil {
   109  			if ve, ok := err.(*errors.Validation); ok {
   110  				return ve.ValidateName("statistics")
   111  			}
   112  			return err
   113  		}
   114  	}
   115  
   116  	return nil
   117  }
   118  
   119  // MarshalBinary interface implementation
   120  func (m *ProxyStatistics) MarshalBinary() ([]byte, error) {
   121  	if m == nil {
   122  		return nil, nil
   123  	}
   124  	return swag.WriteJSON(m)
   125  }
   126  
   127  // UnmarshalBinary interface implementation
   128  func (m *ProxyStatistics) UnmarshalBinary(b []byte) error {
   129  	var res ProxyStatistics
   130  	if err := swag.ReadJSON(b, &res); err != nil {
   131  		return err
   132  	}
   133  	*m = res
   134  	return nil
   135  }