// 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 }