crowdsec/pkg/models/metrics_detail_item.go
2024-03-19 15:33:55 +01:00

116 lines
2.6 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// MetricsDetailItem MetricsDetailItem
//
// swagger:model MetricsDetailItem
type MetricsDetailItem struct {
// labels of the metric
Labels MetricsLabels `json:"labels,omitempty"`
// name of the metric
Name string `json:"name,omitempty"`
// unit of the metric
Unit string `json:"unit,omitempty"`
// value of the metric
Value float64 `json:"value,omitempty"`
}
// Validate validates this metrics detail item
func (m *MetricsDetailItem) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *MetricsDetailItem) validateLabels(formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
}
if m.Labels != nil {
if err := m.Labels.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("labels")
}
return err
}
}
return nil
}
// ContextValidate validate this metrics detail item based on the context it is used
func (m *MetricsDetailItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateLabels(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *MetricsDetailItem) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
}
if err := m.Labels.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("labels")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *MetricsDetailItem) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *MetricsDetailItem) UnmarshalBinary(b []byte) error {
var res MetricsDetailItem
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}