diff --git a/pkg/models/localapi_swagger.yaml b/pkg/models/localapi_swagger.yaml index 6e40a47ef..42437be70 100644 --- a/pkg/models/localapi_swagger.yaml +++ b/pkg/models/localapi_swagger.yaml @@ -1142,6 +1142,10 @@ definitions: labels: $ref: '#/definitions/MetricsLabels' description: labels of the metric + required: + - name + - value + - unit MetricsMeta: title: MetricsMeta type: object diff --git a/pkg/models/metrics_detail_item.go b/pkg/models/metrics_detail_item.go index ed13470ee..889f7e263 100644 --- a/pkg/models/metrics_detail_item.go +++ b/pkg/models/metrics_detail_item.go @@ -11,6 +11,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // MetricsDetailItem MetricsDetailItem @@ -22,13 +23,16 @@ type MetricsDetailItem struct { Labels MetricsLabels `json:"labels,omitempty"` // name of the metric - Name string `json:"name,omitempty"` + // Required: true + Name *string `json:"name"` // unit of the metric - Unit string `json:"unit,omitempty"` + // Required: true + Unit *string `json:"unit"` // value of the metric - Value float64 `json:"value,omitempty"` + // Required: true + Value *float64 `json:"value"` } // Validate validates this metrics detail item @@ -39,6 +43,18 @@ func (m *MetricsDetailItem) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUnit(formats); err != nil { + res = append(res, err) + } + + if err := m.validateValue(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -64,6 +80,33 @@ func (m *MetricsDetailItem) validateLabels(formats strfmt.Registry) error { return nil } +func (m *MetricsDetailItem) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *MetricsDetailItem) validateUnit(formats strfmt.Registry) error { + + if err := validate.Required("unit", "body", m.Unit); err != nil { + return err + } + + return nil +} + +func (m *MetricsDetailItem) validateValue(formats strfmt.Registry) error { + + if err := validate.Required("value", "body", m.Value); err != nil { + 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