mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
lapi detailed metrics: API spec + models (#3100)
* lapi detailed metrics: API spec + models * models+db: split hubstate by item type
This commit is contained in:
parent
b1cf83975e
commit
4635d04b22
20 changed files with 1962 additions and 10 deletions
|
@ -48,7 +48,7 @@ type Machine struct {
|
||||||
// Featureflags holds the value of the "featureflags" field.
|
// Featureflags holds the value of the "featureflags" field.
|
||||||
Featureflags string `json:"featureflags,omitempty"`
|
Featureflags string `json:"featureflags,omitempty"`
|
||||||
// Hubstate holds the value of the "hubstate" field.
|
// Hubstate holds the value of the "hubstate" field.
|
||||||
Hubstate map[string]schema.ItemState `json:"hubstate,omitempty"`
|
Hubstate map[string][]schema.ItemState `json:"hubstate,omitempty"`
|
||||||
// Datasources holds the value of the "datasources" field.
|
// Datasources holds the value of the "datasources" field.
|
||||||
Datasources map[string]int64 `json:"datasources,omitempty"`
|
Datasources map[string]int64 `json:"datasources,omitempty"`
|
||||||
// Edges holds the relations/edges for other nodes in the graph.
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
|
|
@ -195,7 +195,7 @@ func (mc *MachineCreate) SetNillableFeatureflags(s *string) *MachineCreate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHubstate sets the "hubstate" field.
|
// SetHubstate sets the "hubstate" field.
|
||||||
func (mc *MachineCreate) SetHubstate(ms map[string]schema.ItemState) *MachineCreate {
|
func (mc *MachineCreate) SetHubstate(ms map[string][]schema.ItemState) *MachineCreate {
|
||||||
mc.mutation.SetHubstate(ms)
|
mc.mutation.SetHubstate(ms)
|
||||||
return mc
|
return mc
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ func (mu *MachineUpdate) ClearFeatureflags() *MachineUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHubstate sets the "hubstate" field.
|
// SetHubstate sets the "hubstate" field.
|
||||||
func (mu *MachineUpdate) SetHubstate(ms map[string]schema.ItemState) *MachineUpdate {
|
func (mu *MachineUpdate) SetHubstate(ms map[string][]schema.ItemState) *MachineUpdate {
|
||||||
mu.mutation.SetHubstate(ms)
|
mu.mutation.SetHubstate(ms)
|
||||||
return mu
|
return mu
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@ func (muo *MachineUpdateOne) ClearFeatureflags() *MachineUpdateOne {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHubstate sets the "hubstate" field.
|
// SetHubstate sets the "hubstate" field.
|
||||||
func (muo *MachineUpdateOne) SetHubstate(ms map[string]schema.ItemState) *MachineUpdateOne {
|
func (muo *MachineUpdateOne) SetHubstate(ms map[string][]schema.ItemState) *MachineUpdateOne {
|
||||||
muo.mutation.SetHubstate(ms)
|
muo.mutation.SetHubstate(ms)
|
||||||
return muo
|
return muo
|
||||||
}
|
}
|
||||||
|
|
|
@ -6542,7 +6542,7 @@ type MachineMutation struct {
|
||||||
osname *string
|
osname *string
|
||||||
osversion *string
|
osversion *string
|
||||||
featureflags *string
|
featureflags *string
|
||||||
hubstate *map[string]schema.ItemState
|
hubstate *map[string][]schema.ItemState
|
||||||
datasources *map[string]int64
|
datasources *map[string]int64
|
||||||
clearedFields map[string]struct{}
|
clearedFields map[string]struct{}
|
||||||
alerts map[int]struct{}
|
alerts map[int]struct{}
|
||||||
|
@ -7247,12 +7247,12 @@ func (m *MachineMutation) ResetFeatureflags() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHubstate sets the "hubstate" field.
|
// SetHubstate sets the "hubstate" field.
|
||||||
func (m *MachineMutation) SetHubstate(ms map[string]schema.ItemState) {
|
func (m *MachineMutation) SetHubstate(ms map[string][]schema.ItemState) {
|
||||||
m.hubstate = &ms
|
m.hubstate = &ms
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hubstate returns the value of the "hubstate" field in the mutation.
|
// Hubstate returns the value of the "hubstate" field in the mutation.
|
||||||
func (m *MachineMutation) Hubstate() (r map[string]schema.ItemState, exists bool) {
|
func (m *MachineMutation) Hubstate() (r map[string][]schema.ItemState, exists bool) {
|
||||||
v := m.hubstate
|
v := m.hubstate
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return
|
return
|
||||||
|
@ -7263,7 +7263,7 @@ func (m *MachineMutation) Hubstate() (r map[string]schema.ItemState, exists bool
|
||||||
// OldHubstate returns the old "hubstate" field's value of the Machine entity.
|
// OldHubstate returns the old "hubstate" field's value of the Machine entity.
|
||||||
// If the Machine object wasn't provided to the builder, the object is fetched from the database.
|
// If the Machine object wasn't provided to the builder, the object is fetched from the database.
|
||||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||||
func (m *MachineMutation) OldHubstate(ctx context.Context) (v map[string]schema.ItemState, err error) {
|
func (m *MachineMutation) OldHubstate(ctx context.Context) (v map[string][]schema.ItemState, err error) {
|
||||||
if !m.op.Is(OpUpdateOne) {
|
if !m.op.Is(OpUpdateOne) {
|
||||||
return v, errors.New("OldHubstate is only allowed on UpdateOne operations")
|
return v, errors.New("OldHubstate is only allowed on UpdateOne operations")
|
||||||
}
|
}
|
||||||
|
@ -7670,7 +7670,7 @@ func (m *MachineMutation) SetField(name string, value ent.Value) error {
|
||||||
m.SetFeatureflags(v)
|
m.SetFeatureflags(v)
|
||||||
return nil
|
return nil
|
||||||
case machine.FieldHubstate:
|
case machine.FieldHubstate:
|
||||||
v, ok := value.(map[string]schema.ItemState)
|
v, ok := value.(map[string][]schema.ItemState)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (Machine) Fields() []ent.Field {
|
||||||
field.String("osname").Optional(),
|
field.String("osname").Optional(),
|
||||||
field.String("osversion").Optional(),
|
field.String("osversion").Optional(),
|
||||||
field.String("featureflags").Optional(),
|
field.String("featureflags").Optional(),
|
||||||
field.JSON("hubstate", map[string]ItemState{}).Optional(),
|
field.JSON("hubstate", map[string][]ItemState{}).Optional(),
|
||||||
field.JSON("datasources", map[string]int64{}).Optional(),
|
field.JSON("datasources", map[string]int64{}).Optional(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
234
pkg/models/all_metrics.go
Normal file
234
pkg/models/all_metrics.go
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
// 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"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AllMetrics AllMetrics
|
||||||
|
//
|
||||||
|
// swagger:model AllMetrics
|
||||||
|
type AllMetrics struct {
|
||||||
|
|
||||||
|
// lapi
|
||||||
|
Lapi *LapiMetrics `json:"lapi,omitempty"`
|
||||||
|
|
||||||
|
// log processors metrics
|
||||||
|
LogProcessors []*LogProcessorsMetrics `json:"log_processors"`
|
||||||
|
|
||||||
|
// remediation components metrics
|
||||||
|
RemediationComponents []*RemediationComponentsMetrics `json:"remediation_components"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this all metrics
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateRemediationComponents(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(m.LogProcessors); i++ {
|
||||||
|
if swag.IsZero(m.LogProcessors[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.LogProcessors[i] != nil {
|
||||||
|
if err := m.LogProcessors[i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AllMetrics) validateRemediationComponents(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(m.RemediationComponents) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(m.RemediationComponents); i++ {
|
||||||
|
if swag.IsZero(m.RemediationComponents[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.RemediationComponents[i] != nil {
|
||||||
|
if err := m.RemediationComponents[i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this all metrics based on the context it is used
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.contextValidateRemediationComponents(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
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++ {
|
||||||
|
|
||||||
|
if m.LogProcessors[i] != nil {
|
||||||
|
|
||||||
|
if swag.IsZero(m.LogProcessors[i]) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.LogProcessors[i].ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *AllMetrics) contextValidateRemediationComponents(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
for i := 0; i < len(m.RemediationComponents); i++ {
|
||||||
|
|
||||||
|
if m.RemediationComponents[i] != nil {
|
||||||
|
|
||||||
|
if swag.IsZero(m.RemediationComponents[i]) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.RemediationComponents[i].ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *AllMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *AllMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res AllMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
210
pkg/models/base_metrics.go
Normal file
210
pkg/models/base_metrics.go
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
// 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"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaseMetrics BaseMetrics
|
||||||
|
//
|
||||||
|
// swagger:model BaseMetrics
|
||||||
|
type BaseMetrics struct {
|
||||||
|
|
||||||
|
// feature flags (expected to be empty for remediation components)
|
||||||
|
FeatureFlags []string `json:"feature_flags"`
|
||||||
|
|
||||||
|
// metrics details
|
||||||
|
Metrics []*DetailedMetrics `json:"metrics"`
|
||||||
|
|
||||||
|
// os
|
||||||
|
Os *OSversion `json:"os,omitempty"`
|
||||||
|
|
||||||
|
// UTC timestamp of the startup of the software
|
||||||
|
// Required: true
|
||||||
|
UtcStartupTimestamp *int64 `json:"utc_startup_timestamp"`
|
||||||
|
|
||||||
|
// version of the remediation component
|
||||||
|
// Required: true
|
||||||
|
Version *string `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this base metrics
|
||||||
|
func (m *BaseMetrics) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateMetrics(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateOs(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateUtcStartupTimestamp(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateVersion(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) validateMetrics(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(m.Metrics) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(m.Metrics); i++ {
|
||||||
|
if swag.IsZero(m.Metrics[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Metrics[i] != nil {
|
||||||
|
if err := m.Metrics[i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("metrics" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("metrics" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) validateOs(formats strfmt.Registry) error {
|
||||||
|
if swag.IsZero(m.Os) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Os != nil {
|
||||||
|
if err := m.Os.Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("os")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("os")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) validateUtcStartupTimestamp(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("utc_startup_timestamp", "body", m.UtcStartupTimestamp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) validateVersion(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("version", "body", m.Version); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this base metrics based on the context it is used
|
||||||
|
func (m *BaseMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.contextValidateMetrics(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.contextValidateOs(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) contextValidateMetrics(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
for i := 0; i < len(m.Metrics); i++ {
|
||||||
|
|
||||||
|
if m.Metrics[i] != nil {
|
||||||
|
|
||||||
|
if swag.IsZero(m.Metrics[i]) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.Metrics[i].ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("metrics" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("metrics" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseMetrics) contextValidateOs(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if m.Os != nil {
|
||||||
|
|
||||||
|
if swag.IsZero(m.Os) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.Os.ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("os")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("os")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *BaseMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *BaseMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res BaseMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
27
pkg/models/console_options.go
Normal file
27
pkg/models/console_options.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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/strfmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConsoleOptions ConsoleOptions
|
||||||
|
//
|
||||||
|
// swagger:model ConsoleOptions
|
||||||
|
type ConsoleOptions []string
|
||||||
|
|
||||||
|
// Validate validates this console options
|
||||||
|
func (m ConsoleOptions) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this console options based on context it is used
|
||||||
|
func (m ConsoleOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
173
pkg/models/detailed_metrics.go
Normal file
173
pkg/models/detailed_metrics.go
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
// 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"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DetailedMetrics DetailedMetrics
|
||||||
|
//
|
||||||
|
// swagger:model DetailedMetrics
|
||||||
|
type DetailedMetrics struct {
|
||||||
|
|
||||||
|
// items
|
||||||
|
// Required: true
|
||||||
|
Items []*MetricsDetailItem `json:"items"`
|
||||||
|
|
||||||
|
// meta
|
||||||
|
// Required: true
|
||||||
|
Meta *MetricsMeta `json:"meta"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this detailed metrics
|
||||||
|
func (m *DetailedMetrics) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateItems(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateMeta(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DetailedMetrics) validateItems(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("items", "body", m.Items); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(m.Items); i++ {
|
||||||
|
if swag.IsZero(m.Items[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Items[i] != nil {
|
||||||
|
if err := m.Items[i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("items" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("items" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DetailedMetrics) validateMeta(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("meta", "body", m.Meta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Meta != nil {
|
||||||
|
if err := m.Meta.Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("meta")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("meta")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this detailed metrics based on the context it is used
|
||||||
|
func (m *DetailedMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.contextValidateItems(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.contextValidateMeta(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DetailedMetrics) contextValidateItems(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
for i := 0; i < len(m.Items); i++ {
|
||||||
|
|
||||||
|
if m.Items[i] != nil {
|
||||||
|
|
||||||
|
if swag.IsZero(m.Items[i]) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.Items[i].ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("items" + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("items" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DetailedMetrics) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if m.Meta != nil {
|
||||||
|
|
||||||
|
if err := m.Meta.ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("meta")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("meta")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *DetailedMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *DetailedMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res DetailedMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
56
pkg/models/hub_item.go
Normal file
56
pkg/models/hub_item.go
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
// 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/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HubItem HubItem
|
||||||
|
//
|
||||||
|
// swagger:model HubItem
|
||||||
|
type HubItem struct {
|
||||||
|
|
||||||
|
// name of the hub item
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// status of the hub item (official, custom, tainted, etc.)
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
|
||||||
|
// version of the hub item
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this hub item
|
||||||
|
func (m *HubItem) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this hub item based on context it is used
|
||||||
|
func (m *HubItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *HubItem) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *HubItem) UnmarshalBinary(b []byte) error {
|
||||||
|
var res HubItem
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
83
pkg/models/hub_items.go
Normal file
83
pkg/models/hub_items.go
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
// 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"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HubItems HubItems
|
||||||
|
//
|
||||||
|
// swagger:model HubItems
|
||||||
|
type HubItems map[string][]HubItem
|
||||||
|
|
||||||
|
// Validate validates this hub items
|
||||||
|
func (m HubItems) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
for k := range m {
|
||||||
|
|
||||||
|
if err := validate.Required(k, "body", m[k]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(m[k]); i++ {
|
||||||
|
|
||||||
|
if err := m[k][i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName(k + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName(k + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this hub items based on the context it is used
|
||||||
|
func (m HubItems) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
for k := range m {
|
||||||
|
|
||||||
|
for i := 0; i < len(m[k]); i++ {
|
||||||
|
|
||||||
|
if swag.IsZero(m[k][i]) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m[k][i].ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName(k + "." + strconv.Itoa(i))
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName(k + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
157
pkg/models/lapi_metrics.go
Normal file
157
pkg/models/lapi_metrics.go
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LapiMetrics LapiMetrics
|
||||||
|
//
|
||||||
|
// swagger:model LapiMetrics
|
||||||
|
type LapiMetrics struct {
|
||||||
|
BaseMetrics
|
||||||
|
|
||||||
|
// console options
|
||||||
|
ConsoleOptions ConsoleOptions `json:"console_options,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||||
|
func (m *LapiMetrics) UnmarshalJSON(raw []byte) error {
|
||||||
|
// AO0
|
||||||
|
var aO0 BaseMetrics
|
||||||
|
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.BaseMetrics = aO0
|
||||||
|
|
||||||
|
// AO1
|
||||||
|
var dataAO1 struct {
|
||||||
|
ConsoleOptions ConsoleOptions `json:"console_options,omitempty"`
|
||||||
|
}
|
||||||
|
if err := swag.ReadJSON(raw, &dataAO1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
m.ConsoleOptions = dataAO1.ConsoleOptions
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON marshals this object to a JSON structure
|
||||||
|
func (m LapiMetrics) MarshalJSON() ([]byte, error) {
|
||||||
|
_parts := make([][]byte, 0, 2)
|
||||||
|
|
||||||
|
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_parts = append(_parts, aO0)
|
||||||
|
var dataAO1 struct {
|
||||||
|
ConsoleOptions ConsoleOptions `json:"console_options,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
dataAO1.ConsoleOptions = m.ConsoleOptions
|
||||||
|
|
||||||
|
jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
|
||||||
|
if errAO1 != nil {
|
||||||
|
return nil, errAO1
|
||||||
|
}
|
||||||
|
_parts = append(_parts, jsonDataAO1)
|
||||||
|
return swag.ConcatJSON(_parts...), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this lapi metrics
|
||||||
|
func (m *LapiMetrics) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.Validate(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateConsoleOptions(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LapiMetrics) validateConsoleOptions(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if swag.IsZero(m.ConsoleOptions) { // not required
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.ConsoleOptions.Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("console_options")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("console_options")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this lapi metrics based on the context it is used
|
||||||
|
func (m *LapiMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.ContextValidate(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.contextValidateConsoleOptions(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LapiMetrics) contextValidateConsoleOptions(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := m.ConsoleOptions.ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("console_options")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("console_options")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *LapiMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *LapiMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res LapiMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -684,6 +684,36 @@ paths:
|
||||||
$ref: "#/definitions/ErrorResponse"
|
$ref: "#/definitions/ErrorResponse"
|
||||||
security:
|
security:
|
||||||
- JWTAuthorizer: []
|
- JWTAuthorizer: []
|
||||||
|
/usage-metrics:
|
||||||
|
post:
|
||||||
|
description: Post usage metrics from a LP or a bouncer
|
||||||
|
summary: Send usage metrics
|
||||||
|
tags:
|
||||||
|
- Remediation component
|
||||||
|
- watchers
|
||||||
|
operationId: usage-metrics
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- name: body
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/AllMetrics'
|
||||||
|
description: 'All metrics'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/SuccessResponse'
|
||||||
|
headers: {}
|
||||||
|
'400':
|
||||||
|
description: "400 response"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ErrorResponse"
|
||||||
|
security:
|
||||||
|
- APIKeyAuthorizer: []
|
||||||
|
- JWTAuthorizer: []
|
||||||
definitions:
|
definitions:
|
||||||
WatcherRegistrationRequest:
|
WatcherRegistrationRequest:
|
||||||
title: WatcherRegistrationRequest
|
title: WatcherRegistrationRequest
|
||||||
|
@ -994,6 +1024,186 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
value:
|
value:
|
||||||
type: string
|
type: string
|
||||||
|
RemediationComponentsMetrics:
|
||||||
|
title: RemediationComponentsMetrics
|
||||||
|
type: object
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/BaseMetrics'
|
||||||
|
- properties:
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
description: type of the remediation component
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the remediation component
|
||||||
|
last_pull:
|
||||||
|
type: integer
|
||||||
|
description: last pull date
|
||||||
|
LogProcessorsMetrics:
|
||||||
|
title: LogProcessorsMetrics
|
||||||
|
type: object
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/BaseMetrics'
|
||||||
|
- properties:
|
||||||
|
hub_items:
|
||||||
|
$ref: '#/definitions/HubItems'
|
||||||
|
datasources:
|
||||||
|
type: object
|
||||||
|
description: Number of datasources per type
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the log processor
|
||||||
|
last_push:
|
||||||
|
type: integer
|
||||||
|
description: last push date
|
||||||
|
last_update:
|
||||||
|
type: integer
|
||||||
|
description: last update date
|
||||||
|
required:
|
||||||
|
- hub_items
|
||||||
|
- datasources
|
||||||
|
LapiMetrics:
|
||||||
|
title: LapiMetrics
|
||||||
|
type: object
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/BaseMetrics'
|
||||||
|
- properties:
|
||||||
|
console_options:
|
||||||
|
$ref: '#/definitions/ConsoleOptions'
|
||||||
|
AllMetrics:
|
||||||
|
title: AllMetrics
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
remediation_components:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/RemediationComponentsMetrics'
|
||||||
|
description: remediation components metrics
|
||||||
|
log_processors:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/LogProcessorsMetrics'
|
||||||
|
description: log processors metrics
|
||||||
|
lapi:
|
||||||
|
$ref: '#/definitions/LapiMetrics'
|
||||||
|
BaseMetrics:
|
||||||
|
title: BaseMetrics
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
version:
|
||||||
|
type: string
|
||||||
|
description: version of the remediation component
|
||||||
|
os:
|
||||||
|
$ref: '#/definitions/OSversion'
|
||||||
|
metrics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/DetailedMetrics'
|
||||||
|
description: metrics details
|
||||||
|
feature_flags:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: feature flags (expected to be empty for remediation components)
|
||||||
|
utc_startup_timestamp:
|
||||||
|
type: integer
|
||||||
|
description: UTC timestamp of the startup of the software
|
||||||
|
required:
|
||||||
|
- version
|
||||||
|
- utc_startup_timestamp
|
||||||
|
OSversion:
|
||||||
|
title: OSversion
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the OS
|
||||||
|
version:
|
||||||
|
type: string
|
||||||
|
description: version of the OS
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- version
|
||||||
|
DetailedMetrics:
|
||||||
|
type: object
|
||||||
|
title: DetailedMetrics
|
||||||
|
properties:
|
||||||
|
items:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/MetricsDetailItem'
|
||||||
|
meta:
|
||||||
|
$ref: '#/definitions/MetricsMeta'
|
||||||
|
required:
|
||||||
|
- meta
|
||||||
|
- items
|
||||||
|
MetricsDetailItem:
|
||||||
|
title: MetricsDetailItem
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the metric
|
||||||
|
value:
|
||||||
|
type: number
|
||||||
|
description: value of the metric
|
||||||
|
unit:
|
||||||
|
type: string
|
||||||
|
description: unit of the metric
|
||||||
|
labels:
|
||||||
|
$ref: '#/definitions/MetricsLabels'
|
||||||
|
description: labels of the metric
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- value
|
||||||
|
- unit
|
||||||
|
MetricsMeta:
|
||||||
|
title: MetricsMeta
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
window_size_seconds:
|
||||||
|
type: integer
|
||||||
|
description: Size, in seconds, of the window used to compute the metric
|
||||||
|
utc_now_timestamp:
|
||||||
|
type: integer
|
||||||
|
description: UTC timestamp of the current time
|
||||||
|
required:
|
||||||
|
- window_size_seconds
|
||||||
|
- utc_now_timestamp
|
||||||
|
MetricsLabels:
|
||||||
|
title: MetricsLabels
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
description: label of the metric
|
||||||
|
ConsoleOptions:
|
||||||
|
title: ConsoleOptions
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: enabled console options
|
||||||
|
HubItems:
|
||||||
|
title: HubItems
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/HubItem'
|
||||||
|
HubItem:
|
||||||
|
title: HubItem
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the hub item
|
||||||
|
version:
|
||||||
|
type: string
|
||||||
|
description: version of the hub item
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: status of the hub item (official, custom, tainted, etc.)
|
||||||
ErrorResponse:
|
ErrorResponse:
|
||||||
type: "object"
|
type: "object"
|
||||||
required:
|
required:
|
||||||
|
@ -1007,6 +1217,16 @@ definitions:
|
||||||
description: "more detail on individual errors"
|
description: "more detail on individual errors"
|
||||||
title: "error response"
|
title: "error response"
|
||||||
description: "error response return by the API"
|
description: "error response return by the API"
|
||||||
|
SuccessResponse:
|
||||||
|
type: "object"
|
||||||
|
required:
|
||||||
|
- "message"
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
type: "string"
|
||||||
|
description: "message"
|
||||||
|
title: "success response"
|
||||||
|
description: "success response return by the API"
|
||||||
tags:
|
tags:
|
||||||
- name: Remediation component
|
- name: Remediation component
|
||||||
description: 'Operations about decisions : bans, captcha, rate-limit etc.'
|
description: 'Operations about decisions : bans, captcha, rate-limit etc.'
|
||||||
|
|
219
pkg/models/log_processors_metrics.go
Normal file
219
pkg/models/log_processors_metrics.go
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LogProcessorsMetrics LogProcessorsMetrics
|
||||||
|
//
|
||||||
|
// swagger:model LogProcessorsMetrics
|
||||||
|
type LogProcessorsMetrics struct {
|
||||||
|
BaseMetrics
|
||||||
|
|
||||||
|
// Number of datasources per type
|
||||||
|
// Required: true
|
||||||
|
Datasources map[string]int64 `json:"datasources"`
|
||||||
|
|
||||||
|
// hub items
|
||||||
|
// Required: true
|
||||||
|
HubItems HubItems `json:"hub_items"`
|
||||||
|
|
||||||
|
// last push date
|
||||||
|
LastPush int64 `json:"last_push,omitempty"`
|
||||||
|
|
||||||
|
// last update date
|
||||||
|
LastUpdate int64 `json:"last_update,omitempty"`
|
||||||
|
|
||||||
|
// name of the log processor
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||||
|
func (m *LogProcessorsMetrics) UnmarshalJSON(raw []byte) error {
|
||||||
|
// AO0
|
||||||
|
var aO0 BaseMetrics
|
||||||
|
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.BaseMetrics = aO0
|
||||||
|
|
||||||
|
// AO1
|
||||||
|
var dataAO1 struct {
|
||||||
|
Datasources map[string]int64 `json:"datasources"`
|
||||||
|
|
||||||
|
HubItems HubItems `json:"hub_items"`
|
||||||
|
|
||||||
|
LastPush int64 `json:"last_push,omitempty"`
|
||||||
|
|
||||||
|
LastUpdate int64 `json:"last_update,omitempty"`
|
||||||
|
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
if err := swag.ReadJSON(raw, &dataAO1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Datasources = dataAO1.Datasources
|
||||||
|
|
||||||
|
m.HubItems = dataAO1.HubItems
|
||||||
|
|
||||||
|
m.LastPush = dataAO1.LastPush
|
||||||
|
|
||||||
|
m.LastUpdate = dataAO1.LastUpdate
|
||||||
|
|
||||||
|
m.Name = dataAO1.Name
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON marshals this object to a JSON structure
|
||||||
|
func (m LogProcessorsMetrics) MarshalJSON() ([]byte, error) {
|
||||||
|
_parts := make([][]byte, 0, 2)
|
||||||
|
|
||||||
|
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_parts = append(_parts, aO0)
|
||||||
|
var dataAO1 struct {
|
||||||
|
Datasources map[string]int64 `json:"datasources"`
|
||||||
|
|
||||||
|
HubItems HubItems `json:"hub_items"`
|
||||||
|
|
||||||
|
LastPush int64 `json:"last_push,omitempty"`
|
||||||
|
|
||||||
|
LastUpdate int64 `json:"last_update,omitempty"`
|
||||||
|
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
dataAO1.Datasources = m.Datasources
|
||||||
|
|
||||||
|
dataAO1.HubItems = m.HubItems
|
||||||
|
|
||||||
|
dataAO1.LastPush = m.LastPush
|
||||||
|
|
||||||
|
dataAO1.LastUpdate = m.LastUpdate
|
||||||
|
|
||||||
|
dataAO1.Name = m.Name
|
||||||
|
|
||||||
|
jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
|
||||||
|
if errAO1 != nil {
|
||||||
|
return nil, errAO1
|
||||||
|
}
|
||||||
|
_parts = append(_parts, jsonDataAO1)
|
||||||
|
return swag.ConcatJSON(_parts...), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this log processors metrics
|
||||||
|
func (m *LogProcessorsMetrics) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.Validate(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateDatasources(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateHubItems(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LogProcessorsMetrics) validateDatasources(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("datasources", "body", m.Datasources); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LogProcessorsMetrics) validateHubItems(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("hub_items", "body", m.HubItems); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.HubItems != nil {
|
||||||
|
if err := m.HubItems.Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("hub_items")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("hub_items")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this log processors metrics based on the context it is used
|
||||||
|
func (m *LogProcessorsMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.ContextValidate(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.contextValidateHubItems(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *LogProcessorsMetrics) contextValidateHubItems(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := m.HubItems.ContextValidate(ctx, formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("hub_items")
|
||||||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||||
|
return ce.ValidateName("hub_items")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *LogProcessorsMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *LogProcessorsMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res LogProcessorsMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
158
pkg/models/metrics_detail_item.go
Normal file
158
pkg/models/metrics_detail_item.go
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MetricsDetailItem MetricsDetailItem
|
||||||
|
//
|
||||||
|
// swagger:model MetricsDetailItem
|
||||||
|
type MetricsDetailItem struct {
|
||||||
|
|
||||||
|
// labels of the metric
|
||||||
|
Labels MetricsLabels `json:"labels,omitempty"`
|
||||||
|
|
||||||
|
// name of the metric
|
||||||
|
// Required: true
|
||||||
|
Name *string `json:"name"`
|
||||||
|
|
||||||
|
// unit of the metric
|
||||||
|
// Required: true
|
||||||
|
Unit *string `json:"unit"`
|
||||||
|
|
||||||
|
// value of the metric
|
||||||
|
// Required: true
|
||||||
|
Value *float64 `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 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...)
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
27
pkg/models/metrics_labels.go
Normal file
27
pkg/models/metrics_labels.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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/strfmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MetricsLabels MetricsLabels
|
||||||
|
//
|
||||||
|
// swagger:model MetricsLabels
|
||||||
|
type MetricsLabels map[string]string
|
||||||
|
|
||||||
|
// Validate validates this metrics labels
|
||||||
|
func (m MetricsLabels) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this metrics labels based on context it is used
|
||||||
|
func (m MetricsLabels) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
88
pkg/models/metrics_meta.go
Normal file
88
pkg/models/metrics_meta.go
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MetricsMeta MetricsMeta
|
||||||
|
//
|
||||||
|
// swagger:model MetricsMeta
|
||||||
|
type MetricsMeta struct {
|
||||||
|
|
||||||
|
// UTC timestamp of the current time
|
||||||
|
// Required: true
|
||||||
|
UtcNowTimestamp *int64 `json:"utc_now_timestamp"`
|
||||||
|
|
||||||
|
// Size, in seconds, of the window used to compute the metric
|
||||||
|
// Required: true
|
||||||
|
WindowSizeSeconds *int64 `json:"window_size_seconds"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this metrics meta
|
||||||
|
func (m *MetricsMeta) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateUtcNowTimestamp(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateWindowSizeSeconds(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MetricsMeta) validateUtcNowTimestamp(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("utc_now_timestamp", "body", m.UtcNowTimestamp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MetricsMeta) validateWindowSizeSeconds(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("window_size_seconds", "body", m.WindowSizeSeconds); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this metrics meta based on context it is used
|
||||||
|
func (m *MetricsMeta) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *MetricsMeta) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *MetricsMeta) UnmarshalBinary(b []byte) error {
|
||||||
|
var res MetricsMeta
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
88
pkg/models/o_sversion.go
Normal file
88
pkg/models/o_sversion.go
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OSversion OSversion
|
||||||
|
//
|
||||||
|
// swagger:model OSversion
|
||||||
|
type OSversion struct {
|
||||||
|
|
||||||
|
// name of the OS
|
||||||
|
// Required: true
|
||||||
|
Name *string `json:"name"`
|
||||||
|
|
||||||
|
// version of the OS
|
||||||
|
// Required: true
|
||||||
|
Version *string `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this o sversion
|
||||||
|
func (m *OSversion) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateName(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateVersion(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *OSversion) validateName(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *OSversion) validateVersion(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("version", "body", m.Version); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this o sversion based on context it is used
|
||||||
|
func (m *OSversion) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *OSversion) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *OSversion) UnmarshalBinary(b []byte) error {
|
||||||
|
var res OSversion
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
139
pkg/models/remediation_components_metrics.go
Normal file
139
pkg/models/remediation_components_metrics.go
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RemediationComponentsMetrics RemediationComponentsMetrics
|
||||||
|
//
|
||||||
|
// swagger:model RemediationComponentsMetrics
|
||||||
|
type RemediationComponentsMetrics struct {
|
||||||
|
BaseMetrics
|
||||||
|
|
||||||
|
// last pull date
|
||||||
|
LastPull int64 `json:"last_pull,omitempty"`
|
||||||
|
|
||||||
|
// name of the remediation component
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// type of the remediation component
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||||
|
func (m *RemediationComponentsMetrics) UnmarshalJSON(raw []byte) error {
|
||||||
|
// AO0
|
||||||
|
var aO0 BaseMetrics
|
||||||
|
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.BaseMetrics = aO0
|
||||||
|
|
||||||
|
// AO1
|
||||||
|
var dataAO1 struct {
|
||||||
|
LastPull int64 `json:"last_pull,omitempty"`
|
||||||
|
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
if err := swag.ReadJSON(raw, &dataAO1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
m.LastPull = dataAO1.LastPull
|
||||||
|
|
||||||
|
m.Name = dataAO1.Name
|
||||||
|
|
||||||
|
m.Type = dataAO1.Type
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON marshals this object to a JSON structure
|
||||||
|
func (m RemediationComponentsMetrics) MarshalJSON() ([]byte, error) {
|
||||||
|
_parts := make([][]byte, 0, 2)
|
||||||
|
|
||||||
|
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_parts = append(_parts, aO0)
|
||||||
|
var dataAO1 struct {
|
||||||
|
LastPull int64 `json:"last_pull,omitempty"`
|
||||||
|
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
dataAO1.LastPull = m.LastPull
|
||||||
|
|
||||||
|
dataAO1.Name = m.Name
|
||||||
|
|
||||||
|
dataAO1.Type = m.Type
|
||||||
|
|
||||||
|
jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)
|
||||||
|
if errAO1 != nil {
|
||||||
|
return nil, errAO1
|
||||||
|
}
|
||||||
|
_parts = append(_parts, jsonDataAO1)
|
||||||
|
return swag.ConcatJSON(_parts...), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this remediation components metrics
|
||||||
|
func (m *RemediationComponentsMetrics) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.Validate(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validate this remediation components metrics based on the context it is used
|
||||||
|
func (m *RemediationComponentsMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
// validation for a type composition with BaseMetrics
|
||||||
|
if err := m.BaseMetrics.ContextValidate(ctx, formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *RemediationComponentsMetrics) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *RemediationComponentsMetrics) UnmarshalBinary(b []byte) error {
|
||||||
|
var res RemediationComponentsMetrics
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
73
pkg/models/success_response.go
Normal file
73
pkg/models/success_response.go
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SuccessResponse success response
|
||||||
|
//
|
||||||
|
// success response return by the API
|
||||||
|
//
|
||||||
|
// swagger:model SuccessResponse
|
||||||
|
type SuccessResponse struct {
|
||||||
|
|
||||||
|
// message
|
||||||
|
// Required: true
|
||||||
|
Message *string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this success response
|
||||||
|
func (m *SuccessResponse) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateMessage(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SuccessResponse) validateMessage(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("message", "body", m.Message); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this success response based on context it is used
|
||||||
|
func (m *SuccessResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *SuccessResponse) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *SuccessResponse) UnmarshalBinary(b []byte) error {
|
||||||
|
var res SuccessResponse
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue