github.com/cilium/cilium@v1.16.2/api/v1/models/backend_address.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  // BackendAddress Service backend address
    22  //
    23  // swagger:model BackendAddress
    24  type BackendAddress struct {
    25  
    26  	// Layer 3 address
    27  	// Required: true
    28  	IP *string `json:"ip"`
    29  
    30  	// Optional name of the node on which this backend runs
    31  	NodeName string `json:"nodeName,omitempty"`
    32  
    33  	// Layer 4 port number
    34  	Port uint16 `json:"port,omitempty"`
    35  
    36  	// Indicator if this backend is preferred in the context of clustermesh service affinity. The value is set based
    37  	// on related annotation of global service. Applicable for active state only.
    38  	Preferred bool `json:"preferred,omitempty"`
    39  
    40  	// State of the backend for load-balancing service traffic
    41  	// Enum: [active terminating quarantined maintenance]
    42  	State string `json:"state,omitempty"`
    43  
    44  	// Backend weight
    45  	Weight *uint16 `json:"weight,omitempty"`
    46  
    47  	// Optional name of the zone in which this backend runs
    48  	Zone string `json:"zone,omitempty"`
    49  }
    50  
    51  // Validate validates this backend address
    52  func (m *BackendAddress) Validate(formats strfmt.Registry) error {
    53  	var res []error
    54  
    55  	if err := m.validateIP(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validateState(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if len(res) > 0 {
    64  		return errors.CompositeValidationError(res...)
    65  	}
    66  	return nil
    67  }
    68  
    69  func (m *BackendAddress) validateIP(formats strfmt.Registry) error {
    70  
    71  	if err := validate.Required("ip", "body", m.IP); err != nil {
    72  		return err
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  var backendAddressTypeStatePropEnum []interface{}
    79  
    80  func init() {
    81  	var res []string
    82  	if err := json.Unmarshal([]byte(`["active","terminating","quarantined","maintenance"]`), &res); err != nil {
    83  		panic(err)
    84  	}
    85  	for _, v := range res {
    86  		backendAddressTypeStatePropEnum = append(backendAddressTypeStatePropEnum, v)
    87  	}
    88  }
    89  
    90  const (
    91  
    92  	// BackendAddressStateActive captures enum value "active"
    93  	BackendAddressStateActive string = "active"
    94  
    95  	// BackendAddressStateTerminating captures enum value "terminating"
    96  	BackendAddressStateTerminating string = "terminating"
    97  
    98  	// BackendAddressStateQuarantined captures enum value "quarantined"
    99  	BackendAddressStateQuarantined string = "quarantined"
   100  
   101  	// BackendAddressStateMaintenance captures enum value "maintenance"
   102  	BackendAddressStateMaintenance string = "maintenance"
   103  )
   104  
   105  // prop value enum
   106  func (m *BackendAddress) validateStateEnum(path, location string, value string) error {
   107  	if err := validate.EnumCase(path, location, value, backendAddressTypeStatePropEnum, true); err != nil {
   108  		return err
   109  	}
   110  	return nil
   111  }
   112  
   113  func (m *BackendAddress) validateState(formats strfmt.Registry) error {
   114  	if swag.IsZero(m.State) { // not required
   115  		return nil
   116  	}
   117  
   118  	// value enum
   119  	if err := m.validateStateEnum("state", "body", m.State); err != nil {
   120  		return err
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  // ContextValidate validates this backend address based on context it is used
   127  func (m *BackendAddress) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   128  	return nil
   129  }
   130  
   131  // MarshalBinary interface implementation
   132  func (m *BackendAddress) MarshalBinary() ([]byte, error) {
   133  	if m == nil {
   134  		return nil, nil
   135  	}
   136  	return swag.WriteJSON(m)
   137  }
   138  
   139  // UnmarshalBinary interface implementation
   140  func (m *BackendAddress) UnmarshalBinary(b []byte) error {
   141  	var res BackendAddress
   142  	if err := swag.ReadJSON(b, &res); err != nil {
   143  		return err
   144  	}
   145  	*m = res
   146  	return nil
   147  }