update swagger and models
This commit is contained in:
parent
c6ebd7ae04
commit
f0853188ce
7 changed files with 119 additions and 238 deletions
|
@ -125,7 +125,7 @@ func (m *MetricsProvider) metricsPayload() *models.AllMetrics {
|
||||||
FeatureFlags: m.static.featureFlags,
|
FeatureFlags: m.static.featureFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
item0 := &models.LogProcessorsMetricsItems0{
|
met := &models.LogProcessorsMetrics{
|
||||||
BaseMetrics: base,
|
BaseMetrics: base,
|
||||||
ConsoleOptions: m.static.consoleOptions,
|
ConsoleOptions: m.static.consoleOptions,
|
||||||
Datasources: m.static.datasourceMap,
|
Datasources: m.static.datasourceMap,
|
||||||
|
@ -135,7 +135,7 @@ func (m *MetricsProvider) metricsPayload() *models.AllMetrics {
|
||||||
// TODO: more metric details... ?
|
// TODO: more metric details... ?
|
||||||
|
|
||||||
return &models.AllMetrics{
|
return &models.AllMetrics{
|
||||||
LogProcessors: []models.LogProcessorsMetrics{{item0}},
|
LogProcessors: []*models.LogProcessorsMetrics{met},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ func (m *MetricsProvider) Run(ctx context.Context, myTomb *tomb.Tomb) error {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
met.LogProcessors[0][0].Meta.UtcNowTimestamp = time.Now().Unix()
|
met.LogProcessors[0].Meta.UtcNowTimestamp = time.Now().Unix()
|
||||||
|
|
||||||
ctxTime, cancel := context.WithTimeout(ctx, 10*time.Second)
|
ctxTime, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (a *apic) GetUsageMetrics() (*models.AllMetrics, []int, error) {
|
||||||
|
|
||||||
for _, lpsMetric := range lpsMetrics {
|
for _, lpsMetric := range lpsMetrics {
|
||||||
lpName := lpsMetric.GeneratedBy
|
lpName := lpsMetric.GeneratedBy
|
||||||
metrics := models.LogProcessorsMetricsItems0{}
|
metrics := models.LogProcessorsMetrics{}
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(lpsMetric.Payload), &metrics)
|
err := json.Unmarshal([]byte(lpsMetric.Payload), &metrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,13 +78,13 @@ func (a *apic) GetUsageMetrics() (*models.AllMetrics, []int, error) {
|
||||||
metrics.Name = lpName
|
metrics.Name = lpName
|
||||||
metrics.LastPush = lp.LastPush.UTC().Unix()
|
metrics.LastPush = lp.LastPush.UTC().Unix()
|
||||||
|
|
||||||
allMetrics.LogProcessors = append(allMetrics.LogProcessors, models.LogProcessorsMetrics{&metrics})
|
allMetrics.LogProcessors = append(allMetrics.LogProcessors, &metrics)
|
||||||
metricsIds = append(metricsIds, lpsMetric.ID)
|
metricsIds = append(metricsIds, lpsMetric.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bouncersMetric := range bouncersMetrics {
|
for _, bouncersMetric := range bouncersMetrics {
|
||||||
bouncerName := bouncersMetric.GeneratedBy
|
bouncerName := bouncersMetric.GeneratedBy
|
||||||
metrics := models.RemediationComponentsMetricsItems0{}
|
metrics := models.RemediationComponentsMetrics{}
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(bouncersMetric.Payload), &metrics)
|
err := json.Unmarshal([]byte(bouncersMetric.Payload), &metrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -114,7 +114,7 @@ func (a *apic) GetUsageMetrics() (*models.AllMetrics, []int, error) {
|
||||||
metrics.Name = bouncerName
|
metrics.Name = bouncerName
|
||||||
metrics.LastPull = bouncer.LastPull.UTC().Unix()
|
metrics.LastPull = bouncer.LastPull.UTC().Unix()
|
||||||
|
|
||||||
allMetrics.RemediationComponents = append(allMetrics.RemediationComponents, models.RemediationComponentsMetrics{&metrics})
|
allMetrics.RemediationComponents = append(allMetrics.RemediationComponents, &metrics)
|
||||||
metricsIds = append(metricsIds, bouncersMetric.ID)
|
metricsIds = append(metricsIds, bouncersMetric.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (c *Controller) UsageMetrics(gctx *gin.Context) {
|
||||||
case 1:
|
case 1:
|
||||||
// the final slice can't have more than one item,
|
// the final slice can't have more than one item,
|
||||||
// guaranteed by the swagger schema
|
// guaranteed by the swagger schema
|
||||||
item0 := input.LogProcessors[0][0]
|
item0 := input.LogProcessors[0]
|
||||||
payload = map[string]any{
|
payload = map[string]any{
|
||||||
"console_options": item0.ConsoleOptions,
|
"console_options": item0.ConsoleOptions,
|
||||||
"datasources": item0.Datasources,
|
"datasources": item0.Datasources,
|
||||||
|
@ -103,7 +103,7 @@ func (c *Controller) UsageMetrics(gctx *gin.Context) {
|
||||||
case 0:
|
case 0:
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
item0 := input.RemediationComponents[0][0]
|
item0 := input.RemediationComponents[0]
|
||||||
payload = map[string]any{
|
payload = map[string]any{
|
||||||
"type": item0.Type,
|
"type": item0.Type,
|
||||||
"metrics": item0.Metrics,
|
"metrics": item0.Metrics,
|
||||||
|
|
|
@ -20,10 +20,10 @@ import (
|
||||||
type AllMetrics struct {
|
type AllMetrics struct {
|
||||||
|
|
||||||
// log processors metrics
|
// log processors metrics
|
||||||
LogProcessors []LogProcessorsMetrics `json:"log_processors"`
|
LogProcessors []*LogProcessorsMetrics `json:"log_processors"`
|
||||||
|
|
||||||
// remediation components metrics
|
// remediation components metrics
|
||||||
RemediationComponents []RemediationComponentsMetrics `json:"remediation_components"`
|
RemediationComponents []*RemediationComponentsMetrics `json:"remediation_components"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this all metrics
|
// Validate validates this all metrics
|
||||||
|
@ -50,14 +50,19 @@ func (m *AllMetrics) validateLogProcessors(formats strfmt.Registry) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(m.LogProcessors); i++ {
|
for i := 0; i < len(m.LogProcessors); i++ {
|
||||||
|
if swag.IsZero(m.LogProcessors[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if err := m.LogProcessors[i].Validate(formats); err != nil {
|
if m.LogProcessors[i] != nil {
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
if err := m.LogProcessors[i].Validate(formats); err != nil {
|
||||||
return ve.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
return ve.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
||||||
return ce.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 err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,14 +76,19 @@ func (m *AllMetrics) validateRemediationComponents(formats strfmt.Registry) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(m.RemediationComponents); i++ {
|
for i := 0; i < len(m.RemediationComponents); i++ {
|
||||||
|
if swag.IsZero(m.RemediationComponents[i]) { // not required
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if err := m.RemediationComponents[i].Validate(formats); err != nil {
|
if m.RemediationComponents[i] != nil {
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
if err := m.RemediationComponents[i].Validate(formats); err != nil {
|
||||||
return ve.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
return ve.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
||||||
return ce.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 err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,13 +118,20 @@ func (m *AllMetrics) contextValidateLogProcessors(ctx context.Context, formats s
|
||||||
|
|
||||||
for i := 0; i < len(m.LogProcessors); i++ {
|
for i := 0; i < len(m.LogProcessors); i++ {
|
||||||
|
|
||||||
if err := m.LogProcessors[i].ContextValidate(ctx, formats); err != nil {
|
if m.LogProcessors[i] != nil {
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
if swag.IsZero(m.LogProcessors[i]) { // not required
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
return nil
|
||||||
return ce.ValidateName("log_processors" + "." + strconv.Itoa(i))
|
}
|
||||||
|
|
||||||
|
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 err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -126,13 +143,20 @@ func (m *AllMetrics) contextValidateRemediationComponents(ctx context.Context, f
|
||||||
|
|
||||||
for i := 0; i < len(m.RemediationComponents); i++ {
|
for i := 0; i < len(m.RemediationComponents); i++ {
|
||||||
|
|
||||||
if err := m.RemediationComponents[i].ContextValidate(ctx, formats); err != nil {
|
if m.RemediationComponents[i] != nil {
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
if swag.IsZero(m.RemediationComponents[i]) { // not required
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
return nil
|
||||||
return ce.ValidateName("remediation_components" + "." + strconv.Itoa(i))
|
}
|
||||||
|
|
||||||
|
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 err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1026,46 +1026,45 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
RemediationComponentsMetrics:
|
RemediationComponentsMetrics:
|
||||||
title: RemediationComponentsMetrics
|
title: RemediationComponentsMetrics
|
||||||
type: array
|
type: object
|
||||||
maxItems: 1
|
allOf:
|
||||||
items:
|
- $ref: '#/definitions/BaseMetrics'
|
||||||
allOf:
|
- properties:
|
||||||
- $ref: '#/definitions/BaseMetrics'
|
type:
|
||||||
- type: object
|
type: string
|
||||||
properties:
|
description: type of the remediation component
|
||||||
type:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: type of the remediation component
|
description: name of the remediation component
|
||||||
name:
|
last_pull:
|
||||||
type: string
|
type: integer
|
||||||
description: name of the remediation component
|
description: last pull date
|
||||||
last_pull:
|
|
||||||
type: integer
|
|
||||||
description: last pull date
|
|
||||||
LogProcessorsMetrics:
|
LogProcessorsMetrics:
|
||||||
title: LogProcessorsMetrics
|
title: LogProcessorsMetrics
|
||||||
type: array
|
type: object
|
||||||
maxItems: 1
|
allOf:
|
||||||
items:
|
- $ref: '#/definitions/BaseMetrics'
|
||||||
allOf:
|
- properties:
|
||||||
- $ref: '#/definitions/BaseMetrics'
|
console_options:
|
||||||
- type: object
|
$ref: '#/definitions/ConsoleOptions'
|
||||||
properties:
|
hub_items:
|
||||||
console_options:
|
$ref: '#/definitions/HubItems'
|
||||||
$ref: '#/definitions/ConsoleOptions'
|
datasources:
|
||||||
hub_items:
|
type: object
|
||||||
$ref: '#/definitions/HubItems'
|
description: Number of datasources per type
|
||||||
datasources:
|
additionalProperties:
|
||||||
type: object
|
|
||||||
description: Number of datasources per type
|
|
||||||
additionalProperties:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
description: name of the log processor
|
|
||||||
last_push:
|
|
||||||
type: integer
|
type: integer
|
||||||
description: last push date
|
name:
|
||||||
|
type: string
|
||||||
|
description: name of the log processor
|
||||||
|
last_push:
|
||||||
|
type: integer
|
||||||
|
description: last push date
|
||||||
|
#items:
|
||||||
|
# allOf:
|
||||||
|
# - $ref: '#/definitions/BaseMetrics'
|
||||||
|
# - type: object
|
||||||
|
|
||||||
AllMetrics:
|
AllMetrics:
|
||||||
title: AllMetrics
|
title: AllMetrics
|
||||||
type: object
|
type: object
|
||||||
|
|
|
@ -7,87 +7,16 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
"github.com/go-openapi/validate"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LogProcessorsMetrics LogProcessorsMetrics
|
// LogProcessorsMetrics LogProcessorsMetrics
|
||||||
//
|
//
|
||||||
// swagger:model LogProcessorsMetrics
|
// swagger:model LogProcessorsMetrics
|
||||||
type LogProcessorsMetrics []*LogProcessorsMetricsItems0
|
type LogProcessorsMetrics struct {
|
||||||
|
|
||||||
// Validate validates this log processors metrics
|
|
||||||
func (m LogProcessorsMetrics) Validate(formats strfmt.Registry) error {
|
|
||||||
var res []error
|
|
||||||
|
|
||||||
iLogProcessorsMetricsSize := int64(len(m))
|
|
||||||
|
|
||||||
if err := validate.MaxItems("", "body", iLogProcessorsMetricsSize, 1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < len(m); i++ {
|
|
||||||
if swag.IsZero(m[i]) { // not required
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if m[i] != nil {
|
|
||||||
if err := m[i].Validate(formats); err != nil {
|
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName(strconv.Itoa(i))
|
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
||||||
return ce.ValidateName(strconv.Itoa(i))
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(res) > 0 {
|
|
||||||
return errors.CompositeValidationError(res...)
|
|
||||||
}
|
|
||||||
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
|
|
||||||
|
|
||||||
for i := 0; i < len(m); i++ {
|
|
||||||
|
|
||||||
if m[i] != nil {
|
|
||||||
|
|
||||||
if swag.IsZero(m[i]) { // not required
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := m[i].ContextValidate(ctx, formats); err != nil {
|
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName(strconv.Itoa(i))
|
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
||||||
return ce.ValidateName(strconv.Itoa(i))
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(res) > 0 {
|
|
||||||
return errors.CompositeValidationError(res...)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogProcessorsMetricsItems0 log processors metrics items0
|
|
||||||
//
|
|
||||||
// swagger:model LogProcessorsMetricsItems0
|
|
||||||
type LogProcessorsMetricsItems0 struct {
|
|
||||||
BaseMetrics
|
BaseMetrics
|
||||||
|
|
||||||
// console options
|
// console options
|
||||||
|
@ -107,7 +36,7 @@ type LogProcessorsMetricsItems0 struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||||
func (m *LogProcessorsMetricsItems0) UnmarshalJSON(raw []byte) error {
|
func (m *LogProcessorsMetrics) UnmarshalJSON(raw []byte) error {
|
||||||
// AO0
|
// AO0
|
||||||
var aO0 BaseMetrics
|
var aO0 BaseMetrics
|
||||||
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
||||||
|
@ -145,7 +74,7 @@ func (m *LogProcessorsMetricsItems0) UnmarshalJSON(raw []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON marshals this object to a JSON structure
|
// MarshalJSON marshals this object to a JSON structure
|
||||||
func (m LogProcessorsMetricsItems0) MarshalJSON() ([]byte, error) {
|
func (m LogProcessorsMetrics) MarshalJSON() ([]byte, error) {
|
||||||
_parts := make([][]byte, 0, 2)
|
_parts := make([][]byte, 0, 2)
|
||||||
|
|
||||||
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
||||||
|
@ -183,8 +112,8 @@ func (m LogProcessorsMetricsItems0) MarshalJSON() ([]byte, error) {
|
||||||
return swag.ConcatJSON(_parts...), nil
|
return swag.ConcatJSON(_parts...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this log processors metrics items0
|
// Validate validates this log processors metrics
|
||||||
func (m *LogProcessorsMetricsItems0) Validate(formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) Validate(formats strfmt.Registry) error {
|
||||||
var res []error
|
var res []error
|
||||||
|
|
||||||
// validation for a type composition with BaseMetrics
|
// validation for a type composition with BaseMetrics
|
||||||
|
@ -206,7 +135,7 @@ func (m *LogProcessorsMetricsItems0) Validate(formats strfmt.Registry) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LogProcessorsMetricsItems0) validateConsoleOptions(formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) validateConsoleOptions(formats strfmt.Registry) error {
|
||||||
|
|
||||||
if swag.IsZero(m.ConsoleOptions) { // not required
|
if swag.IsZero(m.ConsoleOptions) { // not required
|
||||||
return nil
|
return nil
|
||||||
|
@ -224,7 +153,7 @@ func (m *LogProcessorsMetricsItems0) validateConsoleOptions(formats strfmt.Regis
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LogProcessorsMetricsItems0) validateHubItems(formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) validateHubItems(formats strfmt.Registry) error {
|
||||||
|
|
||||||
if swag.IsZero(m.HubItems) { // not required
|
if swag.IsZero(m.HubItems) { // not required
|
||||||
return nil
|
return nil
|
||||||
|
@ -244,8 +173,8 @@ func (m *LogProcessorsMetricsItems0) validateHubItems(formats strfmt.Registry) e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContextValidate validate this log processors metrics items0 based on the context it is used
|
// ContextValidate validate this log processors metrics based on the context it is used
|
||||||
func (m *LogProcessorsMetricsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
var res []error
|
var res []error
|
||||||
|
|
||||||
// validation for a type composition with BaseMetrics
|
// validation for a type composition with BaseMetrics
|
||||||
|
@ -267,7 +196,7 @@ func (m *LogProcessorsMetricsItems0) ContextValidate(ctx context.Context, format
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LogProcessorsMetricsItems0) contextValidateConsoleOptions(ctx context.Context, formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) contextValidateConsoleOptions(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
if err := m.ConsoleOptions.ContextValidate(ctx, formats); err != nil {
|
if err := m.ConsoleOptions.ContextValidate(ctx, formats); err != nil {
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
@ -281,7 +210,7 @@ func (m *LogProcessorsMetricsItems0) contextValidateConsoleOptions(ctx context.C
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LogProcessorsMetricsItems0) contextValidateHubItems(ctx context.Context, formats strfmt.Registry) error {
|
func (m *LogProcessorsMetrics) contextValidateHubItems(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
|
||||||
if swag.IsZero(m.HubItems) { // not required
|
if swag.IsZero(m.HubItems) { // not required
|
||||||
return nil
|
return nil
|
||||||
|
@ -300,7 +229,7 @@ func (m *LogProcessorsMetricsItems0) contextValidateHubItems(ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalBinary interface implementation
|
// MarshalBinary interface implementation
|
||||||
func (m *LogProcessorsMetricsItems0) MarshalBinary() ([]byte, error) {
|
func (m *LogProcessorsMetrics) MarshalBinary() ([]byte, error) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -308,8 +237,8 @@ func (m *LogProcessorsMetricsItems0) MarshalBinary() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalBinary interface implementation
|
// UnmarshalBinary interface implementation
|
||||||
func (m *LogProcessorsMetricsItems0) UnmarshalBinary(b []byte) error {
|
func (m *LogProcessorsMetrics) UnmarshalBinary(b []byte) error {
|
||||||
var res LogProcessorsMetricsItems0
|
var res LogProcessorsMetrics
|
||||||
if err := swag.ReadJSON(b, &res); err != nil {
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,87 +7,16 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
"github.com/go-openapi/validate"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RemediationComponentsMetrics RemediationComponentsMetrics
|
// RemediationComponentsMetrics RemediationComponentsMetrics
|
||||||
//
|
//
|
||||||
// swagger:model RemediationComponentsMetrics
|
// swagger:model RemediationComponentsMetrics
|
||||||
type RemediationComponentsMetrics []*RemediationComponentsMetricsItems0
|
type RemediationComponentsMetrics struct {
|
||||||
|
|
||||||
// Validate validates this remediation components metrics
|
|
||||||
func (m RemediationComponentsMetrics) Validate(formats strfmt.Registry) error {
|
|
||||||
var res []error
|
|
||||||
|
|
||||||
iRemediationComponentsMetricsSize := int64(len(m))
|
|
||||||
|
|
||||||
if err := validate.MaxItems("", "body", iRemediationComponentsMetricsSize, 1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < len(m); i++ {
|
|
||||||
if swag.IsZero(m[i]) { // not required
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if m[i] != nil {
|
|
||||||
if err := m[i].Validate(formats); err != nil {
|
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName(strconv.Itoa(i))
|
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
||||||
return ce.ValidateName(strconv.Itoa(i))
|
|
||||||
}
|
|
||||||
return 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
|
|
||||||
|
|
||||||
for i := 0; i < len(m); i++ {
|
|
||||||
|
|
||||||
if m[i] != nil {
|
|
||||||
|
|
||||||
if swag.IsZero(m[i]) { // not required
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := m[i].ContextValidate(ctx, formats); err != nil {
|
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
|
||||||
return ve.ValidateName(strconv.Itoa(i))
|
|
||||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
||||||
return ce.ValidateName(strconv.Itoa(i))
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(res) > 0 {
|
|
||||||
return errors.CompositeValidationError(res...)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemediationComponentsMetricsItems0 remediation components metrics items0
|
|
||||||
//
|
|
||||||
// swagger:model RemediationComponentsMetricsItems0
|
|
||||||
type RemediationComponentsMetricsItems0 struct {
|
|
||||||
BaseMetrics
|
BaseMetrics
|
||||||
|
|
||||||
// last pull date
|
// last pull date
|
||||||
|
@ -101,7 +30,7 @@ type RemediationComponentsMetricsItems0 struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||||
func (m *RemediationComponentsMetricsItems0) UnmarshalJSON(raw []byte) error {
|
func (m *RemediationComponentsMetrics) UnmarshalJSON(raw []byte) error {
|
||||||
// AO0
|
// AO0
|
||||||
var aO0 BaseMetrics
|
var aO0 BaseMetrics
|
||||||
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
if err := swag.ReadJSON(raw, &aO0); err != nil {
|
||||||
|
@ -131,7 +60,7 @@ func (m *RemediationComponentsMetricsItems0) UnmarshalJSON(raw []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON marshals this object to a JSON structure
|
// MarshalJSON marshals this object to a JSON structure
|
||||||
func (m RemediationComponentsMetricsItems0) MarshalJSON() ([]byte, error) {
|
func (m RemediationComponentsMetrics) MarshalJSON() ([]byte, error) {
|
||||||
_parts := make([][]byte, 0, 2)
|
_parts := make([][]byte, 0, 2)
|
||||||
|
|
||||||
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
aO0, err := swag.WriteJSON(m.BaseMetrics)
|
||||||
|
@ -161,8 +90,8 @@ func (m RemediationComponentsMetricsItems0) MarshalJSON() ([]byte, error) {
|
||||||
return swag.ConcatJSON(_parts...), nil
|
return swag.ConcatJSON(_parts...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this remediation components metrics items0
|
// Validate validates this remediation components metrics
|
||||||
func (m *RemediationComponentsMetricsItems0) Validate(formats strfmt.Registry) error {
|
func (m *RemediationComponentsMetrics) Validate(formats strfmt.Registry) error {
|
||||||
var res []error
|
var res []error
|
||||||
|
|
||||||
// validation for a type composition with BaseMetrics
|
// validation for a type composition with BaseMetrics
|
||||||
|
@ -176,8 +105,8 @@ func (m *RemediationComponentsMetricsItems0) Validate(formats strfmt.Registry) e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContextValidate validate this remediation components metrics items0 based on the context it is used
|
// ContextValidate validate this remediation components metrics based on the context it is used
|
||||||
func (m *RemediationComponentsMetricsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
func (m *RemediationComponentsMetrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
var res []error
|
var res []error
|
||||||
|
|
||||||
// validation for a type composition with BaseMetrics
|
// validation for a type composition with BaseMetrics
|
||||||
|
@ -192,7 +121,7 @@ func (m *RemediationComponentsMetricsItems0) ContextValidate(ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalBinary interface implementation
|
// MarshalBinary interface implementation
|
||||||
func (m *RemediationComponentsMetricsItems0) MarshalBinary() ([]byte, error) {
|
func (m *RemediationComponentsMetrics) MarshalBinary() ([]byte, error) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -200,8 +129,8 @@ func (m *RemediationComponentsMetricsItems0) MarshalBinary() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalBinary interface implementation
|
// UnmarshalBinary interface implementation
|
||||||
func (m *RemediationComponentsMetricsItems0) UnmarshalBinary(b []byte) error {
|
func (m *RemediationComponentsMetrics) UnmarshalBinary(b []byte) error {
|
||||||
var res RemediationComponentsMetricsItems0
|
var res RemediationComponentsMetrics
|
||||||
if err := swag.ReadJSON(b, &res); err != nil {
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue