2019-03-07 16:18:18 +00:00
|
|
|
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
|
|
|
|
// Copyright Prometheus Team
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
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 (
|
2022-11-30 16:06:57 +00:00
|
|
|
"context"
|
2019-03-07 16:18:18 +00:00
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/go-openapi/errors"
|
2021-03-10 18:00:22 +00:00
|
|
|
"github.com/go-openapi/strfmt"
|
2019-03-07 16:18:18 +00:00
|
|
|
"github.com/go-openapi/swag"
|
2019-04-27 10:44:12 +00:00
|
|
|
"github.com/go-openapi/validate"
|
2019-03-07 16:18:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// AlertGroup alert group
|
2021-03-10 18:00:22 +00:00
|
|
|
//
|
2019-03-07 16:18:18 +00:00
|
|
|
// swagger:model alertGroup
|
|
|
|
type AlertGroup struct {
|
|
|
|
|
|
|
|
// alerts
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
2019-03-07 16:18:18 +00:00
|
|
|
Alerts []*GettableAlert `json:"alerts"`
|
|
|
|
|
|
|
|
// labels
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
|
|
|
Labels LabelSet `json:"labels"`
|
2019-03-07 16:18:18 +00:00
|
|
|
|
|
|
|
// receiver
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
|
|
|
Receiver *Receiver `json:"receiver"`
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Validate validates this alert group
|
|
|
|
func (m *AlertGroup) Validate(formats strfmt.Registry) error {
|
|
|
|
var res []error
|
|
|
|
|
|
|
|
if err := m.validateAlerts(formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.validateLabels(formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.validateReceiver(formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(res) > 0 {
|
|
|
|
return errors.CompositeValidationError(res...)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error {
|
|
|
|
|
2019-04-27 10:44:12 +00:00
|
|
|
if err := validate.Required("alerts", "body", m.Alerts); err != nil {
|
|
|
|
return err
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < len(m.Alerts); i++ {
|
|
|
|
if swag.IsZero(m.Alerts[i]) { // not required
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if m.Alerts[i] != nil {
|
|
|
|
if err := m.Alerts[i].Validate(formats); err != nil {
|
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
|
return ve.ValidateName("alerts" + "." + strconv.Itoa(i))
|
2022-11-30 16:06:57 +00:00
|
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
|
return ce.ValidateName("alerts" + "." + strconv.Itoa(i))
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) validateLabels(formats strfmt.Registry) error {
|
|
|
|
|
2022-11-30 16:06:57 +00:00
|
|
|
if err := validate.Required("labels", "body", m.Labels); err != nil {
|
2019-03-07 16:18:18 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:06:57 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-07 16:18:18 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error {
|
|
|
|
|
2019-04-27 10:44:12 +00:00
|
|
|
if err := validate.Required("receiver", "body", m.Receiver); err != nil {
|
|
|
|
return err
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if m.Receiver != nil {
|
|
|
|
if err := m.Receiver.Validate(formats); err != nil {
|
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
|
return ve.ValidateName("receiver")
|
2022-11-30 16:06:57 +00:00
|
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
|
return ce.ValidateName("receiver")
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContextValidate validate this alert group based on the context it is used
|
|
|
|
func (m *AlertGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
var res []error
|
|
|
|
|
|
|
|
if err := m.contextValidateAlerts(ctx, formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.contextValidateLabels(ctx, formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := m.contextValidateReceiver(ctx, formats); err != nil {
|
|
|
|
res = append(res, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(res) > 0 {
|
|
|
|
return errors.CompositeValidationError(res...)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) contextValidateAlerts(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
|
|
|
|
for i := 0; i < len(m.Alerts); i++ {
|
|
|
|
|
|
|
|
if m.Alerts[i] != nil {
|
2023-10-19 11:10:32 +00:00
|
|
|
|
|
|
|
if swag.IsZero(m.Alerts[i]) { // not required
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:06:57 +00:00
|
|
|
if err := m.Alerts[i].ContextValidate(ctx, formats); err != nil {
|
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
|
return ve.ValidateName("alerts" + "." + strconv.Itoa(i))
|
|
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
|
return ce.ValidateName("alerts" + "." + strconv.Itoa(i))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *AlertGroup) contextValidateReceiver(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
|
|
|
|
if m.Receiver != nil {
|
2023-10-19 11:10:32 +00:00
|
|
|
|
2022-11-30 16:06:57 +00:00
|
|
|
if err := m.Receiver.ContextValidate(ctx, formats); err != nil {
|
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
|
return ve.ValidateName("receiver")
|
|
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
|
return ce.ValidateName("receiver")
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalBinary interface implementation
|
|
|
|
func (m *AlertGroup) MarshalBinary() ([]byte, error) {
|
|
|
|
if m == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return swag.WriteJSON(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalBinary interface implementation
|
|
|
|
func (m *AlertGroup) UnmarshalBinary(b []byte) error {
|
|
|
|
var res AlertGroup
|
|
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*m = res
|
|
|
|
return nil
|
|
|
|
}
|