add lapi metrics in swagger and models

This commit is contained in:
Sebastien Blot 2024-04-22 16:08:26 +02:00
parent f0853188ce
commit 7b093b925e
No known key found for this signature in database
GPG key ID: DFC2902F40449F6A
2 changed files with 61 additions and 5 deletions

View file

@ -19,6 +19,9 @@ import (
// swagger:model AllMetrics
type AllMetrics struct {
// lapi
Lapi *LapiMetrics `json:"lapi,omitempty"`
// log processors metrics
LogProcessors []*LogProcessorsMetrics `json:"log_processors"`
@ -30,6 +33,10 @@ type AllMetrics struct {
func (m *AllMetrics) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLapi(formats); err != nil {
res = append(res, err)
}
if err := m.validateLogProcessors(formats); err != nil {
res = append(res, err)
}
@ -44,6 +51,25 @@ func (m *AllMetrics) Validate(formats strfmt.Registry) error {
return nil
}
func (m *AllMetrics) validateLapi(formats strfmt.Registry) error {
if swag.IsZero(m.Lapi) { // not required
return nil
}
if m.Lapi != nil {
if err := m.Lapi.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("lapi")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("lapi")
}
return err
}
}
return nil
}
func (m *AllMetrics) validateLogProcessors(formats strfmt.Registry) error {
if swag.IsZero(m.LogProcessors) { // not required
return nil
@ -100,6 +126,10 @@ func (m *AllMetrics) validateRemediationComponents(formats strfmt.Registry) erro
func (m *AllMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateLapi(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLogProcessors(ctx, formats); err != nil {
res = append(res, err)
}
@ -114,6 +144,27 @@ func (m *AllMetrics) ContextValidate(ctx context.Context, formats strfmt.Registr
return nil
}
func (m *AllMetrics) contextValidateLapi(ctx context.Context, formats strfmt.Registry) error {
if m.Lapi != nil {
if swag.IsZero(m.Lapi) { // not required
return nil
}
if err := m.Lapi.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("lapi")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("lapi")
}
return err
}
}
return nil
}
func (m *AllMetrics) contextValidateLogProcessors(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.LogProcessors); i++ {

View file

@ -1060,11 +1060,14 @@ definitions:
last_push:
type: integer
description: last push date
#items:
# allOf:
# - $ref: '#/definitions/BaseMetrics'
# - type: object
LapiMetrics:
title: LapiMetrics
type: object
allOf:
- $ref: '#/definitions/BaseMetrics'
- properties:
console_options:
$ref: '#/definitions/ConsoleOptions'
AllMetrics:
title: AllMetrics
type: object
@ -1079,6 +1082,8 @@ definitions:
items:
$ref: '#/definitions/LogProcessorsMetrics'
description: log processors metrics
lapi:
$ref: '#/definitions/LapiMetrics'
BaseMetrics:
title: BaseMetrics
type: object