github.com/cilium/cilium@v1.16.2/api/v1/models/endpoint_configuration_status.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  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/strfmt"
    16  	"github.com/go-openapi/swag"
    17  )
    18  
    19  // EndpointConfigurationStatus An endpoint's configuration
    20  //
    21  // swagger:model EndpointConfigurationStatus
    22  type EndpointConfigurationStatus struct {
    23  
    24  	// Most recent error, if applicable
    25  	Error Error `json:"error,omitempty"`
    26  
    27  	// Immutable configuration (read-only)
    28  	Immutable ConfigurationMap `json:"immutable,omitempty"`
    29  
    30  	// currently applied changeable configuration
    31  	Realized *EndpointConfigurationSpec `json:"realized,omitempty"`
    32  }
    33  
    34  // Validate validates this endpoint configuration status
    35  func (m *EndpointConfigurationStatus) Validate(formats strfmt.Registry) error {
    36  	var res []error
    37  
    38  	if err := m.validateError(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if err := m.validateImmutable(formats); err != nil {
    43  		res = append(res, err)
    44  	}
    45  
    46  	if err := m.validateRealized(formats); err != nil {
    47  		res = append(res, err)
    48  	}
    49  
    50  	if len(res) > 0 {
    51  		return errors.CompositeValidationError(res...)
    52  	}
    53  	return nil
    54  }
    55  
    56  func (m *EndpointConfigurationStatus) validateError(formats strfmt.Registry) error {
    57  	if swag.IsZero(m.Error) { // not required
    58  		return nil
    59  	}
    60  
    61  	if err := m.Error.Validate(formats); err != nil {
    62  		if ve, ok := err.(*errors.Validation); ok {
    63  			return ve.ValidateName("error")
    64  		} else if ce, ok := err.(*errors.CompositeError); ok {
    65  			return ce.ValidateName("error")
    66  		}
    67  		return err
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  func (m *EndpointConfigurationStatus) validateImmutable(formats strfmt.Registry) error {
    74  	if swag.IsZero(m.Immutable) { // not required
    75  		return nil
    76  	}
    77  
    78  	if m.Immutable != nil {
    79  		if err := m.Immutable.Validate(formats); err != nil {
    80  			if ve, ok := err.(*errors.Validation); ok {
    81  				return ve.ValidateName("immutable")
    82  			} else if ce, ok := err.(*errors.CompositeError); ok {
    83  				return ce.ValidateName("immutable")
    84  			}
    85  			return err
    86  		}
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  func (m *EndpointConfigurationStatus) validateRealized(formats strfmt.Registry) error {
    93  	if swag.IsZero(m.Realized) { // not required
    94  		return nil
    95  	}
    96  
    97  	if m.Realized != nil {
    98  		if err := m.Realized.Validate(formats); err != nil {
    99  			if ve, ok := err.(*errors.Validation); ok {
   100  				return ve.ValidateName("realized")
   101  			} else if ce, ok := err.(*errors.CompositeError); ok {
   102  				return ce.ValidateName("realized")
   103  			}
   104  			return err
   105  		}
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  // ContextValidate validate this endpoint configuration status based on the context it is used
   112  func (m *EndpointConfigurationStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   113  	var res []error
   114  
   115  	if err := m.contextValidateError(ctx, formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	if err := m.contextValidateImmutable(ctx, formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	if err := m.contextValidateRealized(ctx, formats); err != nil {
   124  		res = append(res, err)
   125  	}
   126  
   127  	if len(res) > 0 {
   128  		return errors.CompositeValidationError(res...)
   129  	}
   130  	return nil
   131  }
   132  
   133  func (m *EndpointConfigurationStatus) contextValidateError(ctx context.Context, formats strfmt.Registry) error {
   134  
   135  	if swag.IsZero(m.Error) { // not required
   136  		return nil
   137  	}
   138  
   139  	if err := m.Error.ContextValidate(ctx, formats); err != nil {
   140  		if ve, ok := err.(*errors.Validation); ok {
   141  			return ve.ValidateName("error")
   142  		} else if ce, ok := err.(*errors.CompositeError); ok {
   143  			return ce.ValidateName("error")
   144  		}
   145  		return err
   146  	}
   147  
   148  	return nil
   149  }
   150  
   151  func (m *EndpointConfigurationStatus) contextValidateImmutable(ctx context.Context, formats strfmt.Registry) error {
   152  
   153  	if swag.IsZero(m.Immutable) { // not required
   154  		return nil
   155  	}
   156  
   157  	if err := m.Immutable.ContextValidate(ctx, formats); err != nil {
   158  		if ve, ok := err.(*errors.Validation); ok {
   159  			return ve.ValidateName("immutable")
   160  		} else if ce, ok := err.(*errors.CompositeError); ok {
   161  			return ce.ValidateName("immutable")
   162  		}
   163  		return err
   164  	}
   165  
   166  	return nil
   167  }
   168  
   169  func (m *EndpointConfigurationStatus) contextValidateRealized(ctx context.Context, formats strfmt.Registry) error {
   170  
   171  	if m.Realized != nil {
   172  
   173  		if swag.IsZero(m.Realized) { // not required
   174  			return nil
   175  		}
   176  
   177  		if err := m.Realized.ContextValidate(ctx, formats); err != nil {
   178  			if ve, ok := err.(*errors.Validation); ok {
   179  				return ve.ValidateName("realized")
   180  			} else if ce, ok := err.(*errors.CompositeError); ok {
   181  				return ce.ValidateName("realized")
   182  			}
   183  			return err
   184  		}
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  // MarshalBinary interface implementation
   191  func (m *EndpointConfigurationStatus) MarshalBinary() ([]byte, error) {
   192  	if m == nil {
   193  		return nil, nil
   194  	}
   195  	return swag.WriteJSON(m)
   196  }
   197  
   198  // UnmarshalBinary interface implementation
   199  func (m *EndpointConfigurationStatus) UnmarshalBinary(b []byte) error {
   200  	var res EndpointConfigurationStatus
   201  	if err := swag.ReadJSON(b, &res); err != nil {
   202  		return err
   203  	}
   204  	*m = res
   205  	return nil
   206  }