mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
131 lines
2.7 KiB
Go
131 lines
2.7 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
package rest_model_zrok
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
)
|
|
|
|
// Metrics metrics
|
|
//
|
|
// swagger:model metrics
|
|
type Metrics struct {
|
|
|
|
// id
|
|
ID string `json:"id,omitempty"`
|
|
|
|
// period
|
|
Period float64 `json:"period,omitempty"`
|
|
|
|
// samples
|
|
Samples []*MetricsSample `json:"samples"`
|
|
|
|
// scope
|
|
Scope string `json:"scope,omitempty"`
|
|
}
|
|
|
|
// Validate validates this metrics
|
|
func (m *Metrics) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateSamples(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Metrics) validateSamples(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.Samples) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Samples); i++ {
|
|
if swag.IsZero(m.Samples[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Samples[i] != nil {
|
|
if err := m.Samples[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("samples" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("samples" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this metrics based on the context it is used
|
|
func (m *Metrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateSamples(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Metrics) contextValidateSamples(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Samples); i++ {
|
|
|
|
if m.Samples[i] != nil {
|
|
|
|
if swag.IsZero(m.Samples[i]) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := m.Samples[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("samples" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("samples" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *Metrics) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *Metrics) UnmarshalBinary(b []byte) error {
|
|
var res Metrics
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|