github.com/kubearmor/cilium@v1.6.12/api/v1/models/backend_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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // BackendAddress Service backend address
    17  // swagger:model BackendAddress
    18  type BackendAddress struct {
    19  
    20  	// Layer 3 address
    21  	// Required: true
    22  	IP *string `json:"ip"`
    23  
    24  	// Layer 4 port number
    25  	Port uint16 `json:"port,omitempty"`
    26  
    27  	// Weight for Round Robin
    28  	Weight uint16 `json:"weight,omitempty"`
    29  }
    30  
    31  // Validate validates this backend address
    32  func (m *BackendAddress) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateIP(formats); err != nil {
    36  		res = append(res, err)
    37  	}
    38  
    39  	if len(res) > 0 {
    40  		return errors.CompositeValidationError(res...)
    41  	}
    42  	return nil
    43  }
    44  
    45  func (m *BackendAddress) validateIP(formats strfmt.Registry) error {
    46  
    47  	if err := validate.Required("ip", "body", m.IP); err != nil {
    48  		return err
    49  	}
    50  
    51  	return nil
    52  }
    53  
    54  // MarshalBinary interface implementation
    55  func (m *BackendAddress) MarshalBinary() ([]byte, error) {
    56  	if m == nil {
    57  		return nil, nil
    58  	}
    59  	return swag.WriteJSON(m)
    60  }
    61  
    62  // UnmarshalBinary interface implementation
    63  func (m *BackendAddress) UnmarshalBinary(b []byte) error {
    64  	var res BackendAddress
    65  	if err := swag.ReadJSON(b, &res); err != nil {
    66  		return err
    67  	}
    68  	*m = res
    69  	return nil
    70  }