github.com/kubearmor/cilium@v1.6.12/api/v1/models/ip_a_m_response.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  // IPAMResponse IPAM configuration of an endpoint
    17  // swagger:model IPAMResponse
    18  type IPAMResponse struct {
    19  
    20  	// address
    21  	// Required: true
    22  	Address *AddressPair `json:"address"`
    23  
    24  	// host addressing
    25  	// Required: true
    26  	HostAddressing *NodeAddressing `json:"host-addressing"`
    27  
    28  	// ipv4
    29  	IPV4 *IPAMAddressResponse `json:"ipv4,omitempty"`
    30  
    31  	// ipv6
    32  	IPV6 *IPAMAddressResponse `json:"ipv6,omitempty"`
    33  }
    34  
    35  // Validate validates this IP a m response
    36  func (m *IPAMResponse) Validate(formats strfmt.Registry) error {
    37  	var res []error
    38  
    39  	if err := m.validateAddress(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateHostAddressing(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if err := m.validateIPV4(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validateIPV6(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if len(res) > 0 {
    56  		return errors.CompositeValidationError(res...)
    57  	}
    58  	return nil
    59  }
    60  
    61  func (m *IPAMResponse) validateAddress(formats strfmt.Registry) error {
    62  
    63  	if err := validate.Required("address", "body", m.Address); err != nil {
    64  		return err
    65  	}
    66  
    67  	if m.Address != nil {
    68  		if err := m.Address.Validate(formats); err != nil {
    69  			if ve, ok := err.(*errors.Validation); ok {
    70  				return ve.ValidateName("address")
    71  			}
    72  			return err
    73  		}
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  func (m *IPAMResponse) validateHostAddressing(formats strfmt.Registry) error {
    80  
    81  	if err := validate.Required("host-addressing", "body", m.HostAddressing); err != nil {
    82  		return err
    83  	}
    84  
    85  	if m.HostAddressing != nil {
    86  		if err := m.HostAddressing.Validate(formats); err != nil {
    87  			if ve, ok := err.(*errors.Validation); ok {
    88  				return ve.ValidateName("host-addressing")
    89  			}
    90  			return err
    91  		}
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  func (m *IPAMResponse) validateIPV4(formats strfmt.Registry) error {
    98  
    99  	if swag.IsZero(m.IPV4) { // not required
   100  		return nil
   101  	}
   102  
   103  	if m.IPV4 != nil {
   104  		if err := m.IPV4.Validate(formats); err != nil {
   105  			if ve, ok := err.(*errors.Validation); ok {
   106  				return ve.ValidateName("ipv4")
   107  			}
   108  			return err
   109  		}
   110  	}
   111  
   112  	return nil
   113  }
   114  
   115  func (m *IPAMResponse) validateIPV6(formats strfmt.Registry) error {
   116  
   117  	if swag.IsZero(m.IPV6) { // not required
   118  		return nil
   119  	}
   120  
   121  	if m.IPV6 != nil {
   122  		if err := m.IPV6.Validate(formats); err != nil {
   123  			if ve, ok := err.(*errors.Validation); ok {
   124  				return ve.ValidateName("ipv6")
   125  			}
   126  			return err
   127  		}
   128  	}
   129  
   130  	return nil
   131  }
   132  
   133  // MarshalBinary interface implementation
   134  func (m *IPAMResponse) MarshalBinary() ([]byte, error) {
   135  	if m == nil {
   136  		return nil, nil
   137  	}
   138  	return swag.WriteJSON(m)
   139  }
   140  
   141  // UnmarshalBinary interface implementation
   142  func (m *IPAMResponse) UnmarshalBinary(b []byte) error {
   143  	var res IPAMResponse
   144  	if err := swag.ReadJSON(b, &res); err != nil {
   145  		return err
   146  	}
   147  	*m = res
   148  	return nil
   149  }