github.com/cilium/cilium@v1.16.2/api/v1/models/hubble_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  	"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  // HubbleStatus Status of the Hubble server
    22  //
    23  // +k8s:deepcopy-gen=true
    24  //
    25  // swagger:model HubbleStatus
    26  type HubbleStatus struct {
    27  
    28  	// metrics
    29  	Metrics *HubbleStatusMetrics `json:"metrics,omitempty"`
    30  
    31  	// Human readable status/error/warning message
    32  	Msg string `json:"msg,omitempty"`
    33  
    34  	// observer
    35  	Observer *HubbleStatusObserver `json:"observer,omitempty"`
    36  
    37  	// State the component is in
    38  	// Enum: [Ok Warning Failure Disabled]
    39  	State string `json:"state,omitempty"`
    40  }
    41  
    42  // Validate validates this hubble status
    43  func (m *HubbleStatus) Validate(formats strfmt.Registry) error {
    44  	var res []error
    45  
    46  	if err := m.validateMetrics(formats); err != nil {
    47  		res = append(res, err)
    48  	}
    49  
    50  	if err := m.validateObserver(formats); err != nil {
    51  		res = append(res, err)
    52  	}
    53  
    54  	if err := m.validateState(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if len(res) > 0 {
    59  		return errors.CompositeValidationError(res...)
    60  	}
    61  	return nil
    62  }
    63  
    64  func (m *HubbleStatus) validateMetrics(formats strfmt.Registry) error {
    65  	if swag.IsZero(m.Metrics) { // not required
    66  		return nil
    67  	}
    68  
    69  	if m.Metrics != nil {
    70  		if err := m.Metrics.Validate(formats); err != nil {
    71  			if ve, ok := err.(*errors.Validation); ok {
    72  				return ve.ValidateName("metrics")
    73  			} else if ce, ok := err.(*errors.CompositeError); ok {
    74  				return ce.ValidateName("metrics")
    75  			}
    76  			return err
    77  		}
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *HubbleStatus) validateObserver(formats strfmt.Registry) error {
    84  	if swag.IsZero(m.Observer) { // not required
    85  		return nil
    86  	}
    87  
    88  	if m.Observer != nil {
    89  		if err := m.Observer.Validate(formats); err != nil {
    90  			if ve, ok := err.(*errors.Validation); ok {
    91  				return ve.ValidateName("observer")
    92  			} else if ce, ok := err.(*errors.CompositeError); ok {
    93  				return ce.ValidateName("observer")
    94  			}
    95  			return err
    96  		}
    97  	}
    98  
    99  	return nil
   100  }
   101  
   102  var hubbleStatusTypeStatePropEnum []interface{}
   103  
   104  func init() {
   105  	var res []string
   106  	if err := json.Unmarshal([]byte(`["Ok","Warning","Failure","Disabled"]`), &res); err != nil {
   107  		panic(err)
   108  	}
   109  	for _, v := range res {
   110  		hubbleStatusTypeStatePropEnum = append(hubbleStatusTypeStatePropEnum, v)
   111  	}
   112  }
   113  
   114  const (
   115  
   116  	// HubbleStatusStateOk captures enum value "Ok"
   117  	HubbleStatusStateOk string = "Ok"
   118  
   119  	// HubbleStatusStateWarning captures enum value "Warning"
   120  	HubbleStatusStateWarning string = "Warning"
   121  
   122  	// HubbleStatusStateFailure captures enum value "Failure"
   123  	HubbleStatusStateFailure string = "Failure"
   124  
   125  	// HubbleStatusStateDisabled captures enum value "Disabled"
   126  	HubbleStatusStateDisabled string = "Disabled"
   127  )
   128  
   129  // prop value enum
   130  func (m *HubbleStatus) validateStateEnum(path, location string, value string) error {
   131  	if err := validate.EnumCase(path, location, value, hubbleStatusTypeStatePropEnum, true); err != nil {
   132  		return err
   133  	}
   134  	return nil
   135  }
   136  
   137  func (m *HubbleStatus) validateState(formats strfmt.Registry) error {
   138  	if swag.IsZero(m.State) { // not required
   139  		return nil
   140  	}
   141  
   142  	// value enum
   143  	if err := m.validateStateEnum("state", "body", m.State); err != nil {
   144  		return err
   145  	}
   146  
   147  	return nil
   148  }
   149  
   150  // ContextValidate validate this hubble status based on the context it is used
   151  func (m *HubbleStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   152  	var res []error
   153  
   154  	if err := m.contextValidateMetrics(ctx, formats); err != nil {
   155  		res = append(res, err)
   156  	}
   157  
   158  	if err := m.contextValidateObserver(ctx, formats); err != nil {
   159  		res = append(res, err)
   160  	}
   161  
   162  	if len(res) > 0 {
   163  		return errors.CompositeValidationError(res...)
   164  	}
   165  	return nil
   166  }
   167  
   168  func (m *HubbleStatus) contextValidateMetrics(ctx context.Context, formats strfmt.Registry) error {
   169  
   170  	if m.Metrics != nil {
   171  
   172  		if swag.IsZero(m.Metrics) { // not required
   173  			return nil
   174  		}
   175  
   176  		if err := m.Metrics.ContextValidate(ctx, formats); err != nil {
   177  			if ve, ok := err.(*errors.Validation); ok {
   178  				return ve.ValidateName("metrics")
   179  			} else if ce, ok := err.(*errors.CompositeError); ok {
   180  				return ce.ValidateName("metrics")
   181  			}
   182  			return err
   183  		}
   184  	}
   185  
   186  	return nil
   187  }
   188  
   189  func (m *HubbleStatus) contextValidateObserver(ctx context.Context, formats strfmt.Registry) error {
   190  
   191  	if m.Observer != nil {
   192  
   193  		if swag.IsZero(m.Observer) { // not required
   194  			return nil
   195  		}
   196  
   197  		if err := m.Observer.ContextValidate(ctx, formats); err != nil {
   198  			if ve, ok := err.(*errors.Validation); ok {
   199  				return ve.ValidateName("observer")
   200  			} else if ce, ok := err.(*errors.CompositeError); ok {
   201  				return ce.ValidateName("observer")
   202  			}
   203  			return err
   204  		}
   205  	}
   206  
   207  	return nil
   208  }
   209  
   210  // MarshalBinary interface implementation
   211  func (m *HubbleStatus) MarshalBinary() ([]byte, error) {
   212  	if m == nil {
   213  		return nil, nil
   214  	}
   215  	return swag.WriteJSON(m)
   216  }
   217  
   218  // UnmarshalBinary interface implementation
   219  func (m *HubbleStatus) UnmarshalBinary(b []byte) error {
   220  	var res HubbleStatus
   221  	if err := swag.ReadJSON(b, &res); err != nil {
   222  		return err
   223  	}
   224  	*m = res
   225  	return nil
   226  }
   227  
   228  // HubbleStatusMetrics Status of the Hubble metrics server
   229  //
   230  // swagger:model HubbleStatusMetrics
   231  type HubbleStatusMetrics struct {
   232  
   233  	// State of the Hubble metrics
   234  	// Enum: [Ok Warning Failure Disabled]
   235  	State string `json:"state,omitempty"`
   236  }
   237  
   238  // Validate validates this hubble status metrics
   239  func (m *HubbleStatusMetrics) Validate(formats strfmt.Registry) error {
   240  	var res []error
   241  
   242  	if err := m.validateState(formats); err != nil {
   243  		res = append(res, err)
   244  	}
   245  
   246  	if len(res) > 0 {
   247  		return errors.CompositeValidationError(res...)
   248  	}
   249  	return nil
   250  }
   251  
   252  var hubbleStatusMetricsTypeStatePropEnum []interface{}
   253  
   254  func init() {
   255  	var res []string
   256  	if err := json.Unmarshal([]byte(`["Ok","Warning","Failure","Disabled"]`), &res); err != nil {
   257  		panic(err)
   258  	}
   259  	for _, v := range res {
   260  		hubbleStatusMetricsTypeStatePropEnum = append(hubbleStatusMetricsTypeStatePropEnum, v)
   261  	}
   262  }
   263  
   264  const (
   265  
   266  	// HubbleStatusMetricsStateOk captures enum value "Ok"
   267  	HubbleStatusMetricsStateOk string = "Ok"
   268  
   269  	// HubbleStatusMetricsStateWarning captures enum value "Warning"
   270  	HubbleStatusMetricsStateWarning string = "Warning"
   271  
   272  	// HubbleStatusMetricsStateFailure captures enum value "Failure"
   273  	HubbleStatusMetricsStateFailure string = "Failure"
   274  
   275  	// HubbleStatusMetricsStateDisabled captures enum value "Disabled"
   276  	HubbleStatusMetricsStateDisabled string = "Disabled"
   277  )
   278  
   279  // prop value enum
   280  func (m *HubbleStatusMetrics) validateStateEnum(path, location string, value string) error {
   281  	if err := validate.EnumCase(path, location, value, hubbleStatusMetricsTypeStatePropEnum, true); err != nil {
   282  		return err
   283  	}
   284  	return nil
   285  }
   286  
   287  func (m *HubbleStatusMetrics) validateState(formats strfmt.Registry) error {
   288  	if swag.IsZero(m.State) { // not required
   289  		return nil
   290  	}
   291  
   292  	// value enum
   293  	if err := m.validateStateEnum("metrics"+"."+"state", "body", m.State); err != nil {
   294  		return err
   295  	}
   296  
   297  	return nil
   298  }
   299  
   300  // ContextValidate validates this hubble status metrics based on context it is used
   301  func (m *HubbleStatusMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   302  	return nil
   303  }
   304  
   305  // MarshalBinary interface implementation
   306  func (m *HubbleStatusMetrics) MarshalBinary() ([]byte, error) {
   307  	if m == nil {
   308  		return nil, nil
   309  	}
   310  	return swag.WriteJSON(m)
   311  }
   312  
   313  // UnmarshalBinary interface implementation
   314  func (m *HubbleStatusMetrics) UnmarshalBinary(b []byte) error {
   315  	var res HubbleStatusMetrics
   316  	if err := swag.ReadJSON(b, &res); err != nil {
   317  		return err
   318  	}
   319  	*m = res
   320  	return nil
   321  }
   322  
   323  // HubbleStatusObserver Status of the Hubble observer
   324  //
   325  // +k8s:deepcopy-gen=true
   326  //
   327  // swagger:model HubbleStatusObserver
   328  type HubbleStatusObserver struct {
   329  
   330  	// Current number of flows this Hubble observer stores
   331  	CurrentFlows int64 `json:"current-flows,omitempty"`
   332  
   333  	// Maximum number of flows this Hubble observer is able to store
   334  	MaxFlows int64 `json:"max-flows,omitempty"`
   335  
   336  	// Total number of flows this Hubble observer has seen
   337  	SeenFlows int64 `json:"seen-flows,omitempty"`
   338  
   339  	// Uptime of this Hubble observer instance
   340  	// Format: duration
   341  	Uptime strfmt.Duration `json:"uptime,omitempty"`
   342  }
   343  
   344  // Validate validates this hubble status observer
   345  func (m *HubbleStatusObserver) Validate(formats strfmt.Registry) error {
   346  	var res []error
   347  
   348  	if err := m.validateUptime(formats); err != nil {
   349  		res = append(res, err)
   350  	}
   351  
   352  	if len(res) > 0 {
   353  		return errors.CompositeValidationError(res...)
   354  	}
   355  	return nil
   356  }
   357  
   358  func (m *HubbleStatusObserver) validateUptime(formats strfmt.Registry) error {
   359  	if swag.IsZero(m.Uptime) { // not required
   360  		return nil
   361  	}
   362  
   363  	if err := validate.FormatOf("observer"+"."+"uptime", "body", "duration", m.Uptime.String(), formats); err != nil {
   364  		return err
   365  	}
   366  
   367  	return nil
   368  }
   369  
   370  // ContextValidate validates this hubble status observer based on context it is used
   371  func (m *HubbleStatusObserver) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   372  	return nil
   373  }
   374  
   375  // MarshalBinary interface implementation
   376  func (m *HubbleStatusObserver) MarshalBinary() ([]byte, error) {
   377  	if m == nil {
   378  		return nil, nil
   379  	}
   380  	return swag.WriteJSON(m)
   381  }
   382  
   383  // UnmarshalBinary interface implementation
   384  func (m *HubbleStatusObserver) UnmarshalBinary(b []byte) error {
   385  	var res HubbleStatusObserver
   386  	if err := swag.ReadJSON(b, &res); err != nil {
   387  		return err
   388  	}
   389  	*m = res
   390  	return nil
   391  }